/* Generated by Cython 0.21.1 */

#define PY_SSIZE_T_CLEAN
#ifndef CYTHON_USE_PYLONG_INTERNALS
#ifdef PYLONG_BITS_IN_DIGIT
#define CYTHON_USE_PYLONG_INTERNALS 0
#else
#include "pyconfig.h"
#ifdef PYLONG_BITS_IN_DIGIT
#define CYTHON_USE_PYLONG_INTERNALS 1
#else
#define CYTHON_USE_PYLONG_INTERNALS 0
#endif
#endif
#endif
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
    #error Cython requires Python 2.6+ or Python 3.2+.
#else
#define CYTHON_ABI "0_21_1"
#include <stddef.h>
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
#define CYTHON_COMPILING_IN_PYPY 1
#define CYTHON_COMPILING_IN_CPYTHON 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_CPYTHON 1
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600
#define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyType_Type
#endif
#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#if PY_VERSION_HEX < 0x030400a1 && !defined(Py_TPFLAGS_HAVE_FINALIZE)
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ? \
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
#else
  #define CYTHON_PEP393_ENABLED 0
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#endif
#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
  #define __Pyx_PyFrozenSet_Size(s)         PyObject_Size(s)
#else
  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \
      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  #define __Pyx_PyFrozenSet_Size(s)         PySet_Size(s)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  #ifndef PyUnicode_InternFromString
    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  #endif
#endif
#if PY_VERSION_HEX < 0x030200A4
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and
   a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is
   a quiet NaN. */
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif
#ifdef __cplusplus
template<typename T>
void __Pyx_call_destructor(T* x) {
    x->~T();
}
#endif


#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE__lurrn__sparsmat
#define __PYX_HAVE_API__lurrn__sparsmat
#include "string.h"
#include "math.h"
#include "math_stuff.h"
#include "stdio.h"
#include "stdlib.h"
#include "numpy/arrayobject.h"
#include "numpy/ufuncobject.h"
#include "cxx_gram.h"
#include "pythread.h"
#include "pystate.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif

#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (    \
    (sizeof(type) < sizeof(Py_ssize_t))  ||             \
    (sizeof(type) > sizeof(Py_ssize_t) &&               \
          likely(v < (type)PY_SSIZE_T_MAX ||            \
                 v == (type)PY_SSIZE_T_MAX)  &&         \
          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||       \
                                v == (type)PY_SSIZE_T_MIN)))  ||  \
    (sizeof(type) == sizeof(Py_ssize_t) &&              \
          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||        \
                               v == (type)PY_SSIZE_T_MAX)))  )
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyObject_AsSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromUString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromUString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromUString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromUString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((const char*)s)
#if PY_MAJOR_VERSION < 3
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
{
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return (size_t)(u_end - u - 1);
}
#else
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
#endif
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_COMPILING_IN_CPYTHON
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    const char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    if (strcmp(default_encoding_c, "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (!ascii_chars_u) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
        Py_DECREF(ascii_chars_u);
        Py_DECREF(ascii_chars_b);
    }
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


/* Test for GCC > 2.95 */
#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */

static PyObject *__pyx_m;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;

#if !defined(CYTHON_CCOMPLEX)
  #if defined(__cplusplus)
    #define CYTHON_CCOMPLEX 1
  #elif defined(_Complex_I)
    #define CYTHON_CCOMPLEX 1
  #else
    #define CYTHON_CCOMPLEX 0
  #endif
#endif
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    #include <complex>
  #else
    #include <complex.h>
  #endif
#endif
#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
  #undef _Complex_I
  #define _Complex_I 1.0fj
#endif


static const char *__pyx_f[] = {
  "lurrn/sparsmat.pyx",
  "__init__.pxd",
  "stringsource",
  "type.pxd",
};
#define IS_UNSIGNED(type) (((type) -1) > 0)
struct __Pyx_StructField_;
#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
typedef struct {
  const char* name;
  struct __Pyx_StructField_* fields;
  size_t size;
  size_t arraysize[8];
  int ndim;
  char typegroup;
  char is_unsigned;
  int flags;
} __Pyx_TypeInfo;
typedef struct __Pyx_StructField_ {
  __Pyx_TypeInfo* type;
  const char* name;
  size_t offset;
} __Pyx_StructField;
typedef struct {
  __Pyx_StructField* field;
  size_t parent_offset;
} __Pyx_BufFmt_StackElem;
typedef struct {
  __Pyx_StructField root;
  __Pyx_BufFmt_StackElem* head;
  size_t fmt_offset;
  size_t new_count, enc_count;
  size_t struct_alignment;
  int is_complex;
  char enc_type;
  char new_packmode;
  char enc_packmode;
  char is_valid_array;
} __Pyx_BufFmt_Context;

struct __pyx_memoryview_obj;
typedef struct {
  struct __pyx_memoryview_obj *memview;
  char *data;
  Py_ssize_t shape[8];
  Py_ssize_t strides[8];
  Py_ssize_t suboffsets[8];
} __Pyx_memviewslice;

#include <pythread.h>
#ifndef CYTHON_ATOMICS
    #define CYTHON_ATOMICS 1
#endif
#define __pyx_atomic_int_type int
#if CYTHON_ATOMICS && __GNUC__ >= 4 && (__GNUC_MINOR__ > 1 ||           \
                    (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL >= 2)) && \
                    !defined(__i386__)
    #define __pyx_atomic_incr_aligned(value, lock) __sync_fetch_and_add(value, 1)
    #define __pyx_atomic_decr_aligned(value, lock) __sync_fetch_and_sub(value, 1)
    #ifdef __PYX_DEBUG_ATOMICS
        #warning "Using GNU atomics"
    #endif
#elif CYTHON_ATOMICS && MSC_VER
    #include <Windows.h>
    #define __pyx_atomic_int_type LONG
    #define __pyx_atomic_incr_aligned(value, lock) InterlockedIncrement(value)
    #define __pyx_atomic_decr_aligned(value, lock) InterlockedDecrement(value)
    #ifdef __PYX_DEBUG_ATOMICS
        #warning "Using MSVC atomics"
    #endif
#elif CYTHON_ATOMICS && (defined(__ICC) || defined(__INTEL_COMPILER)) && 0
    #define __pyx_atomic_incr_aligned(value, lock) _InterlockedIncrement(value)
    #define __pyx_atomic_decr_aligned(value, lock) _InterlockedDecrement(value)
    #ifdef __PYX_DEBUG_ATOMICS
        #warning "Using Intel atomics"
    #endif
#else
    #undef CYTHON_ATOMICS
    #define CYTHON_ATOMICS 0
    #ifdef __PYX_DEBUG_ATOMICS
        #warning "Not using atomics"
    #endif
#endif
typedef volatile __pyx_atomic_int_type __pyx_atomic_int;
#if CYTHON_ATOMICS
    #define __pyx_add_acquisition_count(memview) \
             __pyx_atomic_incr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
    #define __pyx_sub_acquisition_count(memview) \
            __pyx_atomic_decr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
#else
    #define __pyx_add_acquisition_count(memview) \
            __pyx_add_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
    #define __pyx_sub_acquisition_count(memview) \
            __pyx_sub_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
#endif


/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":723
 * # in Cython to enable them only on the right systems.
 * 
 * ctypedef npy_int8       int8_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t
 */
typedef npy_int8 __pyx_t_5numpy_int8_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":724
 * 
 * ctypedef npy_int8       int8_t
 * ctypedef npy_int16      int16_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int32      int32_t
 * ctypedef npy_int64      int64_t
 */
typedef npy_int16 __pyx_t_5numpy_int16_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":725
 * ctypedef npy_int8       int8_t
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int64      int64_t
 * #ctypedef npy_int96      int96_t
 */
typedef npy_int32 __pyx_t_5numpy_int32_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":726
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t
 * ctypedef npy_int64      int64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_int96      int96_t
 * #ctypedef npy_int128     int128_t
 */
typedef npy_int64 __pyx_t_5numpy_int64_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":730
 * #ctypedef npy_int128     int128_t
 * 
 * ctypedef npy_uint8      uint8_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t
 */
typedef npy_uint8 __pyx_t_5numpy_uint8_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":731
 * 
 * ctypedef npy_uint8      uint8_t
 * ctypedef npy_uint16     uint16_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint32     uint32_t
 * ctypedef npy_uint64     uint64_t
 */
typedef npy_uint16 __pyx_t_5numpy_uint16_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":732
 * ctypedef npy_uint8      uint8_t
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint64     uint64_t
 * #ctypedef npy_uint96     uint96_t
 */
typedef npy_uint32 __pyx_t_5numpy_uint32_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":733
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t
 * ctypedef npy_uint64     uint64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_uint96     uint96_t
 * #ctypedef npy_uint128    uint128_t
 */
typedef npy_uint64 __pyx_t_5numpy_uint64_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":737
 * #ctypedef npy_uint128    uint128_t
 * 
 * ctypedef npy_float32    float32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_float64    float64_t
 * #ctypedef npy_float80    float80_t
 */
typedef npy_float32 __pyx_t_5numpy_float32_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":738
 * 
 * ctypedef npy_float32    float32_t
 * ctypedef npy_float64    float64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_float80    float80_t
 * #ctypedef npy_float128   float128_t
 */
typedef npy_float64 __pyx_t_5numpy_float64_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":747
 * # The int types are mapped a bit surprising --
 * # numpy.int corresponds to 'l' and numpy.long to 'q'
 * ctypedef npy_long       int_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longlong   long_t
 * ctypedef npy_longlong   longlong_t
 */
typedef npy_long __pyx_t_5numpy_int_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":748
 * # numpy.int corresponds to 'l' and numpy.long to 'q'
 * ctypedef npy_long       int_t
 * ctypedef npy_longlong   long_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longlong   longlong_t
 * 
 */
typedef npy_longlong __pyx_t_5numpy_long_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":749
 * ctypedef npy_long       int_t
 * ctypedef npy_longlong   long_t
 * ctypedef npy_longlong   longlong_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_ulong      uint_t
 */
typedef npy_longlong __pyx_t_5numpy_longlong_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":751
 * ctypedef npy_longlong   longlong_t
 * 
 * ctypedef npy_ulong      uint_t             # <<<<<<<<<<<<<<
 * ctypedef npy_ulonglong  ulong_t
 * ctypedef npy_ulonglong  ulonglong_t
 */
typedef npy_ulong __pyx_t_5numpy_uint_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":752
 * 
 * ctypedef npy_ulong      uint_t
 * ctypedef npy_ulonglong  ulong_t             # <<<<<<<<<<<<<<
 * ctypedef npy_ulonglong  ulonglong_t
 * 
 */
typedef npy_ulonglong __pyx_t_5numpy_ulong_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":753
 * ctypedef npy_ulong      uint_t
 * ctypedef npy_ulonglong  ulong_t
 * ctypedef npy_ulonglong  ulonglong_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_intp       intp_t
 */
typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":755
 * ctypedef npy_ulonglong  ulonglong_t
 * 
 * ctypedef npy_intp       intp_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uintp      uintp_t
 * 
 */
typedef npy_intp __pyx_t_5numpy_intp_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":756
 * 
 * ctypedef npy_intp       intp_t
 * ctypedef npy_uintp      uintp_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_double     float_t
 */
typedef npy_uintp __pyx_t_5numpy_uintp_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":758
 * ctypedef npy_uintp      uintp_t
 * 
 * ctypedef npy_double     float_t             # <<<<<<<<<<<<<<
 * ctypedef npy_double     double_t
 * ctypedef npy_longdouble longdouble_t
 */
typedef npy_double __pyx_t_5numpy_float_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":759
 * 
 * ctypedef npy_double     float_t
 * ctypedef npy_double     double_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longdouble longdouble_t
 * 
 */
typedef npy_double __pyx_t_5numpy_double_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":760
 * ctypedef npy_double     float_t
 * ctypedef npy_double     double_t
 * ctypedef npy_longdouble longdouble_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_cfloat      cfloat_t
 */
typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    typedef ::std::complex< float > __pyx_t_float_complex;
  #else
    typedef float _Complex __pyx_t_float_complex;
  #endif
#else
    typedef struct { float real, imag; } __pyx_t_float_complex;
#endif

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    typedef ::std::complex< double > __pyx_t_double_complex;
  #else
    typedef double _Complex __pyx_t_double_complex;
  #endif
#else
    typedef struct { double real, imag; } __pyx_t_double_complex;
#endif


/*--- Type declarations ---*/
struct __pyx_obj_5lurrn_8sparsmat_VecI1;
struct __pyx_obj_5lurrn_8sparsmat_VecI2;
struct __pyx_obj_5lurrn_8sparsmat_VecI3;
struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI;
struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI;
struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI;
struct __pyx_obj_5lurrn_8sparsmat_VecF1;
struct __pyx_obj_5lurrn_8sparsmat_VecF2;
struct __pyx_obj_5lurrn_8sparsmat_VecF3;
struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF;
struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF;
struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF;
struct __pyx_obj_5lurrn_8sparsmat_VecD1;
struct __pyx_obj_5lurrn_8sparsmat_VecD2;
struct __pyx_obj_5lurrn_8sparsmat_VecD3;
struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD;
struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD;
struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD;
struct __pyx_obj_5lurrn_8sparsmat_VecV1;
struct __pyx_obj_5lurrn_8sparsmat_VecV2;
struct __pyx_obj_5lurrn_8sparsmat_VecV3;
struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter;
struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter;
struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter;
struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter;
struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1;
struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter;
struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2;
struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter;
struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3;
struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter;
struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1;
struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter;
struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2;
struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter;
struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3;
struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter;
struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1;
struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter;
struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2;
struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter;
struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3;
struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter;
struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1;
struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter;
struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2;
struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter;
struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3;
struct __pyx_array_obj;
struct __pyx_MemviewEnum_obj;
struct __pyx_memoryview_obj;
struct __pyx_memoryviewslice_obj;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":762
 * ctypedef npy_longdouble longdouble_t
 * 
 * ctypedef npy_cfloat      cfloat_t             # <<<<<<<<<<<<<<
 * ctypedef npy_cdouble     cdouble_t
 * ctypedef npy_clongdouble clongdouble_t
 */
typedef npy_cfloat __pyx_t_5numpy_cfloat_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":763
 * 
 * ctypedef npy_cfloat      cfloat_t
 * ctypedef npy_cdouble     cdouble_t             # <<<<<<<<<<<<<<
 * ctypedef npy_clongdouble clongdouble_t
 * 
 */
typedef npy_cdouble __pyx_t_5numpy_cdouble_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":764
 * ctypedef npy_cfloat      cfloat_t
 * ctypedef npy_cdouble     cdouble_t
 * ctypedef npy_clongdouble clongdouble_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_cdouble     complex_t
 */
typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":766
 * ctypedef npy_clongdouble clongdouble_t
 * 
 * ctypedef npy_cdouble     complex_t             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew1(a):
 */
typedef npy_cdouble __pyx_t_5numpy_complex_t;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecI1_get_maxcol;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecI1_get_type_counts;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecI2_get_maxcol;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecI2_get_type_counts;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecI3_get_maxcol;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecI3_get_type_counts;
struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsI_add;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecF1_get_maxcol;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecF1_get_type_counts;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecF2_get_maxcol;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecF2_get_type_counts;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecF3_get_maxcol;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecF3_get_type_counts;
struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsF_add;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecD1_get_maxcol;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecD1_get_type_counts;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecD2_get_maxcol;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecD2_get_type_counts;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecD3_get_maxcol;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecD3_get_type_counts;
struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsD_add;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecV1_get_maxcol;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecV1_get_type_counts;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecV2_get_maxcol;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecV2_get_type_counts;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecV3_get_maxcol;
struct __pyx_opt_args_5lurrn_8sparsmat_5VecV3_get_type_counts;

/* "lurrn/sparsmat.pxd":441
 *     cdef void c_add(self, coordinate_t k0, int item)
 *     cpdef SparseVectorI to_sparse(self)
 *     cpdef int get_maxcol(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)
 *     cpdef VecI1 remap(self, int k, numpy.ndarray filt)
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecI1_get_maxcol {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":442
 *     cpdef SparseVectorI to_sparse(self)
 *     cpdef int get_maxcol(self, int k=*)
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef VecI1 remap(self, int k, numpy.ndarray filt)
 * 
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecI1_get_type_counts {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":454
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1, int item)
 *     cpdef CSRMatrixI to_csr(self)
 *     cpdef int get_maxcol(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)
 *     cpdef VecI2 remap(self, int k, numpy.ndarray filt)
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecI2_get_maxcol {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":455
 *     cpdef CSRMatrixI to_csr(self)
 *     cpdef int get_maxcol(self, int k=*)
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef VecI2 remap(self, int k, numpy.ndarray filt)
 * 
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecI2_get_type_counts {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":466
 *     cdef void ensure_compact(self)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, int item)
 *     cpdef int get_maxcol(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)
 *     cpdef VecI3 remap(self, int k, numpy.ndarray filt)
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecI3_get_maxcol {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":467
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, int item)
 *     cpdef int get_maxcol(self, int k=*)
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef VecI3 remap(self, int k, numpy.ndarray filt)
 * cdef class CSRMatrixI:
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecI3_get_type_counts {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":511
 *     cdef c_VectorI weights
 *     cpdef SparseVectorI to_vec(self)
 *     cpdef add(self, SparseVectorI vec, int weight=*)             # <<<<<<<<<<<<<<
 *     cdef int _dotFull(self, const_int_ptr full_ptr)
 * ## F -> float
 */
struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsI_add {
  int __pyx_n;
  int weight;
};

/* "lurrn/sparsmat.pxd":526
 *     cdef void c_add(self, coordinate_t k0, float item)
 *     cpdef SparseVectorF to_sparse(self)
 *     cpdef int get_maxcol(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)
 *     cpdef VecF1 remap(self, int k, numpy.ndarray filt)
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecF1_get_maxcol {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":527
 *     cpdef SparseVectorF to_sparse(self)
 *     cpdef int get_maxcol(self, int k=*)
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef VecF1 remap(self, int k, numpy.ndarray filt)
 * 
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecF1_get_type_counts {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":539
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1, float item)
 *     cpdef CSRMatrixF to_csr(self)
 *     cpdef int get_maxcol(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)
 *     cpdef VecF2 remap(self, int k, numpy.ndarray filt)
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecF2_get_maxcol {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":540
 *     cpdef CSRMatrixF to_csr(self)
 *     cpdef int get_maxcol(self, int k=*)
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef VecF2 remap(self, int k, numpy.ndarray filt)
 * 
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecF2_get_type_counts {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":551
 *     cdef void ensure_compact(self)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, float item)
 *     cpdef int get_maxcol(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)
 *     cpdef VecF3 remap(self, int k, numpy.ndarray filt)
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecF3_get_maxcol {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":552
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, float item)
 *     cpdef int get_maxcol(self, int k=*)
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef VecF3 remap(self, int k, numpy.ndarray filt)
 * cdef class CSRMatrixF:
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecF3_get_type_counts {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":596
 *     cdef c_VectorF weights
 *     cpdef SparseVectorF to_vec(self)
 *     cpdef add(self, SparseVectorF vec, float weight=*)             # <<<<<<<<<<<<<<
 *     cdef float _dotFull(self, const_float_ptr full_ptr)
 * ## D -> double
 */
struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsF_add {
  int __pyx_n;
  float weight;
};

/* "lurrn/sparsmat.pxd":611
 *     cdef void c_add(self, coordinate_t k0, double item)
 *     cpdef SparseVectorD to_sparse(self)
 *     cpdef int get_maxcol(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)
 *     cpdef VecD1 remap(self, int k, numpy.ndarray filt)
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecD1_get_maxcol {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":612
 *     cpdef SparseVectorD to_sparse(self)
 *     cpdef int get_maxcol(self, int k=*)
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef VecD1 remap(self, int k, numpy.ndarray filt)
 * 
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecD1_get_type_counts {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":624
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1, double item)
 *     cpdef CSRMatrixD to_csr(self)
 *     cpdef int get_maxcol(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)
 *     cpdef VecD2 remap(self, int k, numpy.ndarray filt)
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecD2_get_maxcol {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":625
 *     cpdef CSRMatrixD to_csr(self)
 *     cpdef int get_maxcol(self, int k=*)
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef VecD2 remap(self, int k, numpy.ndarray filt)
 * 
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecD2_get_type_counts {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":636
 *     cdef void ensure_compact(self)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, double item)
 *     cpdef int get_maxcol(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)
 *     cpdef VecD3 remap(self, int k, numpy.ndarray filt)
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecD3_get_maxcol {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":637
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, double item)
 *     cpdef int get_maxcol(self, int k=*)
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef VecD3 remap(self, int k, numpy.ndarray filt)
 * cdef class CSRMatrixD:
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecD3_get_type_counts {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":681
 *     cdef c_VectorD weights
 *     cpdef SparseVectorD to_vec(self)
 *     cpdef add(self, SparseVectorD vec, double weight=*)             # <<<<<<<<<<<<<<
 *     cdef double _dotFull(self, const_double_ptr full_ptr)
 * ## V -> void
 */
struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsD_add {
  int __pyx_n;
  double weight;
};

/* "lurrn/sparsmat.pxd":693
 *     cdef void ensure_compact(self)
 *     cdef void c_add(self, coordinate_t k0)
 *     cpdef int get_maxcol(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)
 *     cpdef VecV1 remap(self, int k, numpy.ndarray filt)
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecV1_get_maxcol {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":694
 *     cdef void c_add(self, coordinate_t k0)
 *     cpdef int get_maxcol(self, int k=*)
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef VecV1 remap(self, int k, numpy.ndarray filt)
 * 
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecV1_get_type_counts {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":705
 *     cdef void ensure_compact(self)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1)
 *     cpdef int get_maxcol(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)
 *     cpdef VecV2 remap(self, int k, numpy.ndarray filt)
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecV2_get_maxcol {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":706
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1)
 *     cpdef int get_maxcol(self, int k=*)
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef VecV2 remap(self, int k, numpy.ndarray filt)
 * 
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecV2_get_type_counts {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":717
 *     cdef void ensure_compact(self)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2)
 *     cpdef int get_maxcol(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)
 *     cpdef VecV3 remap(self, int k, numpy.ndarray filt)
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecV3_get_maxcol {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":718
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2)
 *     cpdef int get_maxcol(self, int k=*)
 *     cpdef numpy.ndarray get_type_counts(self, int k=*)             # <<<<<<<<<<<<<<
 *     cpdef VecV3 remap(self, int k, numpy.ndarray filt)
 */
struct __pyx_opt_args_5lurrn_8sparsmat_5VecV3_get_type_counts {
  int __pyx_n;
  int k;
};

/* "lurrn/sparsmat.pxd":433
 * 
 * 
 * cdef class VecI1:             # <<<<<<<<<<<<<<
 *     cdef c_VecI1 vec
 *     cdef bint is_compact
 */
struct __pyx_obj_5lurrn_8sparsmat_VecI1 {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI1 *__pyx_vtab;
  struct std::vector<CountItem<1,int> > vec;
  int is_compact;
};


/* "lurrn/sparsmat.pxd":446
 * 
 * 
 * cdef class VecI2:             # <<<<<<<<<<<<<<
 *     cdef c_VecI2 vec
 *     cdef bint is_compact
 */
struct __pyx_obj_5lurrn_8sparsmat_VecI2 {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *__pyx_vtab;
  struct std::vector<CountItem<2,int> > vec;
  int is_compact;
};


/* "lurrn/sparsmat.pxd":459
 * 
 * 
 * cdef class VecI3:             # <<<<<<<<<<<<<<
 *     cdef c_VecI3 vec
 *     cdef bint is_compact
 */
struct __pyx_obj_5lurrn_8sparsmat_VecI3 {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI3 *__pyx_vtab;
  struct std::vector<CountItem<3,int> > vec;
  int is_compact;
};


/* "lurrn/sparsmat.pxd":429
 * 
 * ## I -> int
 * cdef class CSRMatrixI             # <<<<<<<<<<<<<<
 * cdef class SparseVectorI
 * 
 */
struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixI *__pyx_vtab;
  struct CSRMatrix<int> *mat;
  int cache_maxcol;
  PyObject *buf;
};


/* "lurrn/sparsmat.pxd":430
 * ## I -> int
 * cdef class CSRMatrixI
 * cdef class SparseVectorI             # <<<<<<<<<<<<<<
 * 
 * 
 */
struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorI *__pyx_vtab;
  PyObject *buf;
  int *vals_ptr;
  coordinate_t *idx_ptr;
  unsigned int my_len;
};


/* "lurrn/sparsmat.pxd":507
 *     cpdef double norm_l2(self)
 *     cpdef double norm_lp(self, double p)
 * cdef class SparseVectorsI:             # <<<<<<<<<<<<<<
 *     cdef object vecs
 *     cdef c_VectorI weights
 */
struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsI *__pyx_vtab;
  PyObject *vecs;
  struct std::vector<int> weights;
};


/* "lurrn/sparsmat.pxd":518
 * 
 * 
 * cdef class VecF1:             # <<<<<<<<<<<<<<
 *     cdef c_VecF1 vec
 *     cdef bint is_compact
 */
struct __pyx_obj_5lurrn_8sparsmat_VecF1 {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF1 *__pyx_vtab;
  struct std::vector<CountItem<1,float> > vec;
  int is_compact;
};


/* "lurrn/sparsmat.pxd":531
 * 
 * 
 * cdef class VecF2:             # <<<<<<<<<<<<<<
 *     cdef c_VecF2 vec
 *     cdef bint is_compact
 */
struct __pyx_obj_5lurrn_8sparsmat_VecF2 {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF2 *__pyx_vtab;
  struct std::vector<CountItem<2,float> > vec;
  int is_compact;
};


/* "lurrn/sparsmat.pxd":544
 * 
 * 
 * cdef class VecF3:             # <<<<<<<<<<<<<<
 *     cdef c_VecF3 vec
 *     cdef bint is_compact
 */
struct __pyx_obj_5lurrn_8sparsmat_VecF3 {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF3 *__pyx_vtab;
  struct std::vector<CountItem<3,float> > vec;
  int is_compact;
};


/* "lurrn/sparsmat.pxd":514
 *     cdef int _dotFull(self, const_int_ptr full_ptr)
 * ## F -> float
 * cdef class CSRMatrixF             # <<<<<<<<<<<<<<
 * cdef class SparseVectorF
 * 
 */
struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixF *__pyx_vtab;
  struct CSRMatrix<float> *mat;
  int cache_maxcol;
  PyObject *buf;
};


/* "lurrn/sparsmat.pxd":515
 * ## F -> float
 * cdef class CSRMatrixF
 * cdef class SparseVectorF             # <<<<<<<<<<<<<<
 * 
 * 
 */
struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorF *__pyx_vtab;
  PyObject *buf;
  float *vals_ptr;
  coordinate_t *idx_ptr;
  unsigned int my_len;
};


/* "lurrn/sparsmat.pxd":592
 *     cpdef double norm_l2(self)
 *     cpdef double norm_lp(self, double p)
 * cdef class SparseVectorsF:             # <<<<<<<<<<<<<<
 *     cdef object vecs
 *     cdef c_VectorF weights
 */
struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsF *__pyx_vtab;
  PyObject *vecs;
  struct std::vector<float> weights;
};


/* "lurrn/sparsmat.pxd":603
 * 
 * 
 * cdef class VecD1:             # <<<<<<<<<<<<<<
 *     cdef c_VecD1 vec
 *     cdef bint is_compact
 */
struct __pyx_obj_5lurrn_8sparsmat_VecD1 {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD1 *__pyx_vtab;
  struct std::vector<CountItem<1,double> > vec;
  int is_compact;
};


/* "lurrn/sparsmat.pxd":616
 * 
 * 
 * cdef class VecD2:             # <<<<<<<<<<<<<<
 *     cdef c_VecD2 vec
 *     cdef bint is_compact
 */
struct __pyx_obj_5lurrn_8sparsmat_VecD2 {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *__pyx_vtab;
  struct std::vector<CountItem<2,double> > vec;
  int is_compact;
};


/* "lurrn/sparsmat.pxd":629
 * 
 * 
 * cdef class VecD3:             # <<<<<<<<<<<<<<
 *     cdef c_VecD3 vec
 *     cdef bint is_compact
 */
struct __pyx_obj_5lurrn_8sparsmat_VecD3 {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD3 *__pyx_vtab;
  struct std::vector<CountItem<3,double> > vec;
  int is_compact;
};


/* "lurrn/sparsmat.pxd":426
 *     ctypedef char* const_char_ptr "const char*"
 * 
 * cdef class CSRMatrixD             # <<<<<<<<<<<<<<
 * 
 * ## I -> int
 */
struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixD *__pyx_vtab;
  struct CSRMatrix<double> *mat;
  int cache_maxcol;
  PyObject *buf;
};


/* "lurrn/sparsmat.pxd":600
 * ## D -> double
 * cdef class CSRMatrixD
 * cdef class SparseVectorD             # <<<<<<<<<<<<<<
 * 
 * 
 */
struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorD *__pyx_vtab;
  PyObject *buf;
  double *vals_ptr;
  coordinate_t *idx_ptr;
  unsigned int my_len;
};


/* "lurrn/sparsmat.pxd":677
 *     cpdef double norm_l2(self)
 *     cpdef double norm_lp(self, double p)
 * cdef class SparseVectorsD:             # <<<<<<<<<<<<<<
 *     cdef object vecs
 *     cdef c_VectorD weights
 */
struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsD *__pyx_vtab;
  PyObject *vecs;
  struct std::vector<double> weights;
};


/* "lurrn/sparsmat.pxd":686
 * 
 * 
 * cdef class VecV1:             # <<<<<<<<<<<<<<
 *     cdef c_VecV1 vec
 *     cdef bint is_compact
 */
struct __pyx_obj_5lurrn_8sparsmat_VecV1 {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV1 *__pyx_vtab;
  struct std::vector<CountItem<1,void> > vec;
  int is_compact;
};


/* "lurrn/sparsmat.pxd":698
 * 
 * 
 * cdef class VecV2:             # <<<<<<<<<<<<<<
 *     cdef c_VecV2 vec
 *     cdef bint is_compact
 */
struct __pyx_obj_5lurrn_8sparsmat_VecV2 {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV2 *__pyx_vtab;
  struct std::vector<CountItem<2,void> > vec;
  int is_compact;
};


/* "lurrn/sparsmat.pxd":710
 * 
 * 
 * cdef class VecV3:             # <<<<<<<<<<<<<<
 *     cdef c_VecV3 vec
 *     cdef bint is_compact
 */
struct __pyx_obj_5lurrn_8sparsmat_VecV3 {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV3 *__pyx_vtab;
  struct std::vector<CountItem<3,void> > vec;
  int is_compact;
};


/* "lurrn/sparsmat.pyx":22
 * 
 * cdef class VecI2
 * cdef class CSRMatrixI_item_iter             # <<<<<<<<<<<<<<
 * cdef class SparseVectorI
 * cdef SparseVectorI emptyvec_I
 */
struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter {
  PyObject_HEAD
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *mat;
  struct CSRMatrix<int> *matC;
  coordinate_t k;
  int off;
};


/* "lurrn/sparsmat.pyx":476
 * 
 * cdef class VecF2
 * cdef class CSRMatrixF_item_iter             # <<<<<<<<<<<<<<
 * cdef class SparseVectorF
 * cdef SparseVectorF emptyvec_F
 */
struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter {
  PyObject_HEAD
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *mat;
  struct CSRMatrix<float> *matC;
  coordinate_t k;
  int off;
};


/* "lurrn/sparsmat.pyx":930
 * 
 * cdef class VecD2
 * cdef class CSRMatrixD_item_iter             # <<<<<<<<<<<<<<
 * cdef class SparseVectorD
 * cdef SparseVectorD emptyvec_D
 */
struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter {
  PyObject_HEAD
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *mat;
  struct CSRMatrix<double> *matC;
  coordinate_t k;
  int off;
};


/* "lurrn/sparsmat.pyx":1442
 * 
 * 
 * cdef class IVecI1_iter             # <<<<<<<<<<<<<<
 * 
 * cdef class VecI1:
 */
struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter {
  PyObject_HEAD
  struct __pyx_obj_5lurrn_8sparsmat_VecI1 *vec;
  struct std::vector<CountItem<1,int> > *vecC;
  unsigned int k;
};


/* "lurrn/sparsmat.pyx":1651
 *                 res.item)
 * 
 * cdef class LargeVecI1:             # <<<<<<<<<<<<<<
 *     cdef public object compact
 *     cdef public VecI1 loose
 */
struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 {
  PyObject_HEAD
  PyObject *compact;
  struct __pyx_obj_5lurrn_8sparsmat_VecI1 *loose;
};


/* "lurrn/sparsmat.pyx":1705
 * 
 * 
 * cdef class IVecI2_iter             # <<<<<<<<<<<<<<
 * 
 * cdef class VecI2:
 */
struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter {
  PyObject_HEAD
  struct __pyx_obj_5lurrn_8sparsmat_VecI2 *vec;
  struct std::vector<CountItem<2,int> > *vecC;
  unsigned int k;
};


/* "lurrn/sparsmat.pyx":1904
 *                 res.item)
 * 
 * cdef class LargeVecI2:             # <<<<<<<<<<<<<<
 *     cdef public object compact
 *     cdef public VecI2 loose
 */
struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_LargeVecI2 *__pyx_vtab;
  PyObject *compact;
  struct __pyx_obj_5lurrn_8sparsmat_VecI2 *loose;
};


/* "lurrn/sparsmat.pyx":1962
 * 
 * 
 * cdef class IVecI3_iter             # <<<<<<<<<<<<<<
 * 
 * cdef class VecI3:
 */
struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter {
  PyObject_HEAD
  struct __pyx_obj_5lurrn_8sparsmat_VecI3 *vec;
  struct std::vector<CountItem<3,int> > *vecC;
  unsigned int k;
};


/* "lurrn/sparsmat.pyx":2157
 *                 res.item)
 * 
 * cdef class LargeVecI3:             # <<<<<<<<<<<<<<
 *     cdef public object compact
 *     cdef public VecI3 loose
 */
struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 {
  PyObject_HEAD
  PyObject *compact;
  struct __pyx_obj_5lurrn_8sparsmat_VecI3 *loose;
};


/* "lurrn/sparsmat.pyx":2926
 * 
 * 
 * cdef class IVecF1_iter             # <<<<<<<<<<<<<<
 * 
 * cdef class VecF1:
 */
struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter {
  PyObject_HEAD
  struct __pyx_obj_5lurrn_8sparsmat_VecF1 *vec;
  struct std::vector<CountItem<1,float> > *vecC;
  unsigned int k;
};


/* "lurrn/sparsmat.pyx":3135
 *                 res.item)
 * 
 * cdef class LargeVecF1:             # <<<<<<<<<<<<<<
 *     cdef public object compact
 *     cdef public VecF1 loose
 */
struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 {
  PyObject_HEAD
  PyObject *compact;
  struct __pyx_obj_5lurrn_8sparsmat_VecF1 *loose;
};


/* "lurrn/sparsmat.pyx":3189
 * 
 * 
 * cdef class IVecF2_iter             # <<<<<<<<<<<<<<
 * 
 * cdef class VecF2:
 */
struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter {
  PyObject_HEAD
  struct __pyx_obj_5lurrn_8sparsmat_VecF2 *vec;
  struct std::vector<CountItem<2,float> > *vecC;
  unsigned int k;
};


/* "lurrn/sparsmat.pyx":3388
 *                 res.item)
 * 
 * cdef class LargeVecF2:             # <<<<<<<<<<<<<<
 *     cdef public object compact
 *     cdef public VecF2 loose
 */
struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_LargeVecF2 *__pyx_vtab;
  PyObject *compact;
  struct __pyx_obj_5lurrn_8sparsmat_VecF2 *loose;
};


/* "lurrn/sparsmat.pyx":3446
 * 
 * 
 * cdef class IVecF3_iter             # <<<<<<<<<<<<<<
 * 
 * cdef class VecF3:
 */
struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter {
  PyObject_HEAD
  struct __pyx_obj_5lurrn_8sparsmat_VecF3 *vec;
  struct std::vector<CountItem<3,float> > *vecC;
  unsigned int k;
};


/* "lurrn/sparsmat.pyx":3641
 *                 res.item)
 * 
 * cdef class LargeVecF3:             # <<<<<<<<<<<<<<
 *     cdef public object compact
 *     cdef public VecF3 loose
 */
struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 {
  PyObject_HEAD
  PyObject *compact;
  struct __pyx_obj_5lurrn_8sparsmat_VecF3 *loose;
};


/* "lurrn/sparsmat.pyx":4410
 * 
 * 
 * cdef class IVecD1_iter             # <<<<<<<<<<<<<<
 * 
 * cdef class VecD1:
 */
struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter {
  PyObject_HEAD
  struct __pyx_obj_5lurrn_8sparsmat_VecD1 *vec;
  struct std::vector<CountItem<1,double> > *vecC;
  unsigned int k;
};


/* "lurrn/sparsmat.pyx":4619
 *                 res.item)
 * 
 * cdef class LargeVecD1:             # <<<<<<<<<<<<<<
 *     cdef public object compact
 *     cdef public VecD1 loose
 */
struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 {
  PyObject_HEAD
  PyObject *compact;
  struct __pyx_obj_5lurrn_8sparsmat_VecD1 *loose;
};


/* "lurrn/sparsmat.pyx":4673
 * 
 * 
 * cdef class IVecD2_iter             # <<<<<<<<<<<<<<
 * 
 * cdef class VecD2:
 */
struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter {
  PyObject_HEAD
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *vec;
  struct std::vector<CountItem<2,double> > *vecC;
  unsigned int k;
};


/* "lurrn/sparsmat.pyx":4872
 *                 res.item)
 * 
 * cdef class LargeVecD2:             # <<<<<<<<<<<<<<
 *     cdef public object compact
 *     cdef public VecD2 loose
 */
struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 {
  PyObject_HEAD
  struct __pyx_vtabstruct_5lurrn_8sparsmat_LargeVecD2 *__pyx_vtab;
  PyObject *compact;
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *loose;
};


/* "lurrn/sparsmat.pyx":4930
 * 
 * 
 * cdef class IVecD3_iter             # <<<<<<<<<<<<<<
 * 
 * cdef class VecD3:
 */
struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter {
  PyObject_HEAD
  struct __pyx_obj_5lurrn_8sparsmat_VecD3 *vec;
  struct std::vector<CountItem<3,double> > *vecC;
  unsigned int k;
};


/* "lurrn/sparsmat.pyx":5125
 *                 res.item)
 * 
 * cdef class LargeVecD3:             # <<<<<<<<<<<<<<
 *     cdef public object compact
 *     cdef public VecD3 loose
 */
struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 {
  PyObject_HEAD
  PyObject *compact;
  struct __pyx_obj_5lurrn_8sparsmat_VecD3 *loose;
};


/* "lurrn/sparsmat.pyx":5894
 * 
 * 
 * cdef class IVecV1_iter             # <<<<<<<<<<<<<<
 * 
 * cdef class VecV1:
 */
struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter {
  PyObject_HEAD
  struct __pyx_obj_5lurrn_8sparsmat_VecV1 *vec;
  struct std::vector<CountItem<1,void> > *vecC;
  unsigned int k;
};


/* "lurrn/sparsmat.pyx":6089
 *         return res.addr[0]
 * 
 * cdef class LargeVecV1:             # <<<<<<<<<<<<<<
 *     cdef public object compact
 *     cdef public VecV1 loose
 */
struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 {
  PyObject_HEAD
  PyObject *compact;
  struct __pyx_obj_5lurrn_8sparsmat_VecV1 *loose;
};


/* "lurrn/sparsmat.pyx":6143
 * 
 * 
 * cdef class IVecV2_iter             # <<<<<<<<<<<<<<
 * 
 * cdef class VecV2:
 */
struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter {
  PyObject_HEAD
  struct __pyx_obj_5lurrn_8sparsmat_VecV2 *vec;
  struct std::vector<CountItem<2,void> > *vecC;
  unsigned int k;
};


/* "lurrn/sparsmat.pyx":6332
 *                 res.addr[1])
 * 
 * cdef class LargeVecV2:             # <<<<<<<<<<<<<<
 *     cdef public object compact
 *     cdef public VecV2 loose
 */
struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 {
  PyObject_HEAD
  PyObject *compact;
  struct __pyx_obj_5lurrn_8sparsmat_VecV2 *loose;
};


/* "lurrn/sparsmat.pyx":6386
 * 
 * 
 * cdef class IVecV3_iter             # <<<<<<<<<<<<<<
 * 
 * cdef class VecV3:
 */
struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter {
  PyObject_HEAD
  struct __pyx_obj_5lurrn_8sparsmat_VecV3 *vec;
  struct std::vector<CountItem<3,void> > *vecC;
  unsigned int k;
};


/* "lurrn/sparsmat.pyx":6578
 *                 res.addr[2])
 * 
 * cdef class LargeVecV3:             # <<<<<<<<<<<<<<
 *     cdef public object compact
 *     cdef public VecV3 loose
 */
struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 {
  PyObject_HEAD
  PyObject *compact;
  struct __pyx_obj_5lurrn_8sparsmat_VecV3 *loose;
};


/* "View.MemoryView":99
 * 
 * @cname("__pyx_array")
 * cdef class array:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_array_obj {
  PyObject_HEAD
  char *data;
  Py_ssize_t len;
  char *format;
  int ndim;
  Py_ssize_t *_shape;
  Py_ssize_t *_strides;
  Py_ssize_t itemsize;
  PyObject *mode;
  PyObject *_format;
  void (*callback_free_data)(void *);
  int free_data;
  int dtype_is_object;
};


/* "View.MemoryView":269
 * 
 * @cname('__pyx_MemviewEnum')
 * cdef class Enum(object):             # <<<<<<<<<<<<<<
 *     cdef object name
 *     def __init__(self, name):
 */
struct __pyx_MemviewEnum_obj {
  PyObject_HEAD
  PyObject *name;
};


/* "View.MemoryView":302
 * 
 * @cname('__pyx_memoryview')
 * cdef class memoryview(object):             # <<<<<<<<<<<<<<
 * 
 *     cdef object obj
 */
struct __pyx_memoryview_obj {
  PyObject_HEAD
  struct __pyx_vtabstruct_memoryview *__pyx_vtab;
  PyObject *obj;
  PyObject *_size;
  PyObject *_array_interface;
  PyThread_type_lock lock;
  __pyx_atomic_int acquisition_count[2];
  __pyx_atomic_int *acquisition_count_aligned_p;
  Py_buffer view;
  int flags;
  int dtype_is_object;
  __Pyx_TypeInfo *typeinfo;
};


/* "View.MemoryView":922
 * 
 * @cname('__pyx_memoryviewslice')
 * cdef class _memoryviewslice(memoryview):             # <<<<<<<<<<<<<<
 *     "Internal class for passing memoryview slices to Python"
 * 
 */
struct __pyx_memoryviewslice_obj {
  struct __pyx_memoryview_obj __pyx_base;
  __Pyx_memviewslice from_slice;
  PyObject *from_object;
  PyObject *(*to_object_func)(char *);
  int (*to_dtype_func)(char *, PyObject *);
};



/* "lurrn/sparsmat.pyx":934
 * cdef SparseVectorD emptyvec_D
 * 
 * cdef class CSRMatrixD:             # <<<<<<<<<<<<<<
 *     def __cinit__(self, vecs=None):
 *         self.mat=NULL
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixD {
  void (*set_matrix)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, struct CSRMatrix<double> *);
  double (*get_count)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, coordinate_t, coordinate_t, int __pyx_skip_dispatch);
  int (*get_maxcol)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*transform_mi)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*transform_mi_discount)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*transform_ll)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*transform_l1)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*apply_threshold)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, PyArrayObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*apply_scaling)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, PyArrayObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*fromVectors)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixD *__pyx_vtabptr_5lurrn_8sparsmat_CSRMatrixD;


/* "lurrn/sparsmat.pyx":26
 * cdef SparseVectorI emptyvec_I
 * 
 * cdef class CSRMatrixI:             # <<<<<<<<<<<<<<
 *     def __cinit__(self, vecs=None):
 *         self.mat=NULL
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixI {
  void (*set_matrix)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, struct CSRMatrix<int> *);
  int (*get_count)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, coordinate_t, coordinate_t, int __pyx_skip_dispatch);
  int (*get_maxcol)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*transform_mi)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*transform_mi_discount)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*transform_ll)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*transform_l1)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *(*apply_threshold)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, PyArrayObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*apply_scaling)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, PyArrayObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *(*fromVectors)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixI *__pyx_vtabptr_5lurrn_8sparsmat_CSRMatrixI;


/* "lurrn/sparsmat.pyx":2210
 *         return self.get_compact().remap(k,filt)
 * 
 * cdef class SparseVectorI:             # <<<<<<<<<<<<<<
 *     def __init__(self, pairs=None):
 *         cdef coordinate_t i
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorI {
  int (*from_dense)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, __Pyx_memviewslice, int __pyx_skip_dispatch);
  int (*dotSelf)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch);
  int (*_dotFull)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, const int *);
  int (*_dotFull_partial)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, const int *, int);
  int (*dotSparse)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch);
  void (*_axpy)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int *, int);
  int (*sqdist)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch);
  double (*jaccard)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch);
  double (*cosine)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch);
  double (*min_sum)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch);
  double (*jsd_unnorm)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch);
  double (*skew_unnorm)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, double, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *(*min_vals)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch);
  double (*norm_l1)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch);
  double (*norm_l2)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch);
  double (*norm_lp)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, double, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorI *__pyx_vtabptr_5lurrn_8sparsmat_SparseVectorI;


/* "lurrn/sparsmat.pyx":1444
 * cdef class IVecI1_iter
 * 
 * cdef class VecI1:             # <<<<<<<<<<<<<<
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI1 {
  int (*get_count)(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *, coordinate_t, int __pyx_skip_dispatch);
  void (*compactify)(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *);
  void (*ensure_compact)(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *);
  void (*c_add)(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *, coordinate_t, int);
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *(*to_sparse)(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *, int __pyx_skip_dispatch);
  int (*get_maxcol)(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI1_get_maxcol *__pyx_optional_args);
  PyArrayObject *(*get_type_counts)(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI1_get_type_counts *__pyx_optional_args);
  struct __pyx_obj_5lurrn_8sparsmat_VecI1 *(*remap)(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *, int, PyArrayObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI1 *__pyx_vtabptr_5lurrn_8sparsmat_VecI1;


/* "lurrn/sparsmat.pyx":1707
 * cdef class IVecI2_iter
 * 
 * cdef class VecI2:             # <<<<<<<<<<<<<<
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 {
  int (*get_count)(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *, coordinate_t, coordinate_t, int __pyx_skip_dispatch);
  void (*compactify)(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *);
  void (*ensure_compact)(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *);
  void (*c_add)(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *, coordinate_t, coordinate_t, int);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *(*to_csr)(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *, int __pyx_skip_dispatch);
  int (*get_maxcol)(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI2_get_maxcol *__pyx_optional_args);
  PyArrayObject *(*get_type_counts)(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI2_get_type_counts *__pyx_optional_args);
  struct __pyx_obj_5lurrn_8sparsmat_VecI2 *(*remap)(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *, int, PyArrayObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *__pyx_vtabptr_5lurrn_8sparsmat_VecI2;


/* "lurrn/sparsmat.pyx":1964
 * cdef class IVecI3_iter
 * 
 * cdef class VecI3:             # <<<<<<<<<<<<<<
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI3 {
  int (*get_count)(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *, coordinate_t, coordinate_t, coordinate_t, int __pyx_skip_dispatch);
  void (*compactify)(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *);
  void (*ensure_compact)(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *);
  void (*c_add)(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *, coordinate_t, coordinate_t, coordinate_t, int);
  int (*get_maxcol)(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI3_get_maxcol *__pyx_optional_args);
  PyArrayObject *(*get_type_counts)(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI3_get_type_counts *__pyx_optional_args);
  struct __pyx_obj_5lurrn_8sparsmat_VecI3 *(*remap)(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *, int, PyArrayObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI3 *__pyx_vtabptr_5lurrn_8sparsmat_VecI3;


/* "lurrn/sparsmat.pyx":2854
 * emptyvec_I=SparseVectorI([])
 * 
 * cdef class SparseVectorsI:             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *        self.vecs = []
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsI {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *(*to_vec)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *, int __pyx_skip_dispatch);
  PyObject *(*add)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsI_add *__pyx_optional_args);
  int (*_dotFull)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *, const int *);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsI *__pyx_vtabptr_5lurrn_8sparsmat_SparseVectorsI;


/* "lurrn/sparsmat.pyx":480
 * cdef SparseVectorF emptyvec_F
 * 
 * cdef class CSRMatrixF:             # <<<<<<<<<<<<<<
 *     def __cinit__(self, vecs=None):
 *         self.mat=NULL
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixF {
  void (*set_matrix)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, struct CSRMatrix<float> *);
  float (*get_count)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, coordinate_t, coordinate_t, int __pyx_skip_dispatch);
  int (*get_maxcol)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*transform_mi)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*transform_mi_discount)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*transform_ll)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*transform_l1)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *(*apply_threshold)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, PyArrayObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*apply_scaling)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, PyArrayObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *(*fromVectors)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixF *__pyx_vtabptr_5lurrn_8sparsmat_CSRMatrixF;


/* "lurrn/sparsmat.pyx":3694
 *         return self.get_compact().remap(k,filt)
 * 
 * cdef class SparseVectorF:             # <<<<<<<<<<<<<<
 *     def __init__(self, pairs=None):
 *         cdef coordinate_t i
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorF {
  int (*from_dense)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, __Pyx_memviewslice, int __pyx_skip_dispatch);
  float (*dotSelf)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch);
  float (*_dotFull)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, const float *);
  float (*_dotFull_partial)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, const float *, int);
  float (*dotSparse)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch);
  void (*_axpy)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, float *, float);
  float (*sqdist)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch);
  double (*jaccard)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch);
  double (*cosine)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch);
  double (*min_sum)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch);
  double (*jsd_unnorm)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch);
  double (*skew_unnorm)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, double, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *(*min_vals)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch);
  double (*norm_l1)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch);
  double (*norm_l2)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch);
  double (*norm_lp)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, double, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorF *__pyx_vtabptr_5lurrn_8sparsmat_SparseVectorF;


/* "lurrn/sparsmat.pyx":2928
 * cdef class IVecF1_iter
 * 
 * cdef class VecF1:             # <<<<<<<<<<<<<<
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF1 {
  float (*get_count)(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *, coordinate_t, int __pyx_skip_dispatch);
  void (*compactify)(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *);
  void (*ensure_compact)(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *);
  void (*c_add)(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *, coordinate_t, float);
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *(*to_sparse)(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *, int __pyx_skip_dispatch);
  int (*get_maxcol)(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF1_get_maxcol *__pyx_optional_args);
  PyArrayObject *(*get_type_counts)(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF1_get_type_counts *__pyx_optional_args);
  struct __pyx_obj_5lurrn_8sparsmat_VecF1 *(*remap)(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *, int, PyArrayObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF1 *__pyx_vtabptr_5lurrn_8sparsmat_VecF1;


/* "lurrn/sparsmat.pyx":3191
 * cdef class IVecF2_iter
 * 
 * cdef class VecF2:             # <<<<<<<<<<<<<<
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF2 {
  float (*get_count)(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *, coordinate_t, coordinate_t, int __pyx_skip_dispatch);
  void (*compactify)(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *);
  void (*ensure_compact)(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *);
  void (*c_add)(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *, coordinate_t, coordinate_t, float);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *(*to_csr)(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *, int __pyx_skip_dispatch);
  int (*get_maxcol)(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF2_get_maxcol *__pyx_optional_args);
  PyArrayObject *(*get_type_counts)(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF2_get_type_counts *__pyx_optional_args);
  struct __pyx_obj_5lurrn_8sparsmat_VecF2 *(*remap)(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *, int, PyArrayObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF2 *__pyx_vtabptr_5lurrn_8sparsmat_VecF2;


/* "lurrn/sparsmat.pyx":3448
 * cdef class IVecF3_iter
 * 
 * cdef class VecF3:             # <<<<<<<<<<<<<<
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF3 {
  float (*get_count)(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *, coordinate_t, coordinate_t, coordinate_t, int __pyx_skip_dispatch);
  void (*compactify)(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *);
  void (*ensure_compact)(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *);
  void (*c_add)(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *, coordinate_t, coordinate_t, coordinate_t, float);
  int (*get_maxcol)(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF3_get_maxcol *__pyx_optional_args);
  PyArrayObject *(*get_type_counts)(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF3_get_type_counts *__pyx_optional_args);
  struct __pyx_obj_5lurrn_8sparsmat_VecF3 *(*remap)(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *, int, PyArrayObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF3 *__pyx_vtabptr_5lurrn_8sparsmat_VecF3;


/* "lurrn/sparsmat.pyx":4338
 * emptyvec_F=SparseVectorF([])
 * 
 * cdef class SparseVectorsF:             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *        self.vecs = []
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsF {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *(*to_vec)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *, int __pyx_skip_dispatch);
  PyObject *(*add)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsF_add *__pyx_optional_args);
  float (*_dotFull)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *, const float *);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsF *__pyx_vtabptr_5lurrn_8sparsmat_SparseVectorsF;


/* "lurrn/sparsmat.pyx":5178
 *         return self.get_compact().remap(k,filt)
 * 
 * cdef class SparseVectorD:             # <<<<<<<<<<<<<<
 *     def __init__(self, pairs=None):
 *         cdef coordinate_t i
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorD {
  int (*from_dense)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, __Pyx_memviewslice, int __pyx_skip_dispatch);
  double (*dotSelf)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch);
  double (*_dotFull)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, const double *);
  double (*_dotFull_partial)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, const double *, int);
  double (*dotSparse)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch);
  void (*_axpy)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, double *, double);
  double (*sqdist)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch);
  double (*jaccard)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch);
  double (*cosine)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch);
  double (*min_sum)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch);
  double (*jsd_unnorm)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch);
  double (*skew_unnorm)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, double, int __pyx_skip_dispatch);
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *(*min_vals)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch);
  double (*norm_l1)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch);
  double (*norm_l2)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch);
  double (*norm_lp)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, double, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorD *__pyx_vtabptr_5lurrn_8sparsmat_SparseVectorD;


/* "lurrn/sparsmat.pyx":4412
 * cdef class IVecD1_iter
 * 
 * cdef class VecD1:             # <<<<<<<<<<<<<<
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD1 {
  double (*get_count)(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *, coordinate_t, int __pyx_skip_dispatch);
  void (*compactify)(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *);
  void (*ensure_compact)(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *);
  void (*c_add)(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *, coordinate_t, double);
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *(*to_sparse)(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *, int __pyx_skip_dispatch);
  int (*get_maxcol)(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD1_get_maxcol *__pyx_optional_args);
  PyArrayObject *(*get_type_counts)(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD1_get_type_counts *__pyx_optional_args);
  struct __pyx_obj_5lurrn_8sparsmat_VecD1 *(*remap)(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *, int, PyArrayObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD1 *__pyx_vtabptr_5lurrn_8sparsmat_VecD1;


/* "lurrn/sparsmat.pyx":4675
 * cdef class IVecD2_iter
 * 
 * cdef class VecD2:             # <<<<<<<<<<<<<<
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 {
  double (*get_count)(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *, coordinate_t, coordinate_t, int __pyx_skip_dispatch);
  void (*compactify)(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *);
  void (*ensure_compact)(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *);
  void (*c_add)(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *, coordinate_t, coordinate_t, double);
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*to_csr)(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *, int __pyx_skip_dispatch);
  int (*get_maxcol)(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD2_get_maxcol *__pyx_optional_args);
  PyArrayObject *(*get_type_counts)(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD2_get_type_counts *__pyx_optional_args);
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *(*remap)(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *, int, PyArrayObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *__pyx_vtabptr_5lurrn_8sparsmat_VecD2;


/* "lurrn/sparsmat.pyx":4932
 * cdef class IVecD3_iter
 * 
 * cdef class VecD3:             # <<<<<<<<<<<<<<
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD3 {
  double (*get_count)(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *, coordinate_t, coordinate_t, coordinate_t, int __pyx_skip_dispatch);
  void (*compactify)(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *);
  void (*ensure_compact)(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *);
  void (*c_add)(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *, coordinate_t, coordinate_t, coordinate_t, double);
  int (*get_maxcol)(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD3_get_maxcol *__pyx_optional_args);
  PyArrayObject *(*get_type_counts)(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD3_get_type_counts *__pyx_optional_args);
  struct __pyx_obj_5lurrn_8sparsmat_VecD3 *(*remap)(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *, int, PyArrayObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD3 *__pyx_vtabptr_5lurrn_8sparsmat_VecD3;


/* "lurrn/sparsmat.pyx":5822
 * emptyvec_D=SparseVectorD([])
 * 
 * cdef class SparseVectorsD:             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *        self.vecs = []
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsD {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *(*to_vec)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *, int __pyx_skip_dispatch);
  PyObject *(*add)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsD_add *__pyx_optional_args);
  double (*_dotFull)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *, const double *);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsD *__pyx_vtabptr_5lurrn_8sparsmat_SparseVectorsD;


/* "lurrn/sparsmat.pyx":5896
 * cdef class IVecV1_iter
 * 
 * cdef class VecV1:             # <<<<<<<<<<<<<<
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV1 {
  int (*get_count)(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *, coordinate_t, int __pyx_skip_dispatch);
  void (*compactify)(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *);
  void (*ensure_compact)(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *);
  void (*c_add)(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *, coordinate_t);
  int (*get_maxcol)(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV1_get_maxcol *__pyx_optional_args);
  PyArrayObject *(*get_type_counts)(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV1_get_type_counts *__pyx_optional_args);
  struct __pyx_obj_5lurrn_8sparsmat_VecV1 *(*remap)(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *, int, PyArrayObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV1 *__pyx_vtabptr_5lurrn_8sparsmat_VecV1;


/* "lurrn/sparsmat.pyx":6145
 * cdef class IVecV2_iter
 * 
 * cdef class VecV2:             # <<<<<<<<<<<<<<
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV2 {
  int (*get_count)(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *, coordinate_t, coordinate_t, int __pyx_skip_dispatch);
  void (*compactify)(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *);
  void (*ensure_compact)(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *);
  void (*c_add)(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *, coordinate_t, coordinate_t);
  int (*get_maxcol)(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV2_get_maxcol *__pyx_optional_args);
  PyArrayObject *(*get_type_counts)(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV2_get_type_counts *__pyx_optional_args);
  struct __pyx_obj_5lurrn_8sparsmat_VecV2 *(*remap)(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *, int, PyArrayObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV2 *__pyx_vtabptr_5lurrn_8sparsmat_VecV2;


/* "lurrn/sparsmat.pyx":6388
 * cdef class IVecV3_iter
 * 
 * cdef class VecV3:             # <<<<<<<<<<<<<<
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV3 {
  int (*get_count)(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *, coordinate_t, coordinate_t, coordinate_t, int __pyx_skip_dispatch);
  void (*compactify)(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *);
  void (*ensure_compact)(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *);
  void (*c_add)(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *, coordinate_t, coordinate_t, coordinate_t);
  int (*get_maxcol)(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV3_get_maxcol *__pyx_optional_args);
  PyArrayObject *(*get_type_counts)(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV3_get_type_counts *__pyx_optional_args);
  struct __pyx_obj_5lurrn_8sparsmat_VecV3 *(*remap)(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *, int, PyArrayObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV3 *__pyx_vtabptr_5lurrn_8sparsmat_VecV3;


/* "lurrn/sparsmat.pyx":1904
 *                 res.item)
 * 
 * cdef class LargeVecI2:             # <<<<<<<<<<<<<<
 *     cdef public object compact
 *     cdef public VecI2 loose
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_LargeVecI2 {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *(*to_csr)(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_LargeVecI2 *__pyx_vtabptr_5lurrn_8sparsmat_LargeVecI2;


/* "lurrn/sparsmat.pyx":3388
 *                 res.item)
 * 
 * cdef class LargeVecF2:             # <<<<<<<<<<<<<<
 *     cdef public object compact
 *     cdef public VecF2 loose
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_LargeVecF2 {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *(*to_csr)(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_LargeVecF2 *__pyx_vtabptr_5lurrn_8sparsmat_LargeVecF2;


/* "lurrn/sparsmat.pyx":4872
 *                 res.item)
 * 
 * cdef class LargeVecD2:             # <<<<<<<<<<<<<<
 *     cdef public object compact
 *     cdef public VecD2 loose
 */

struct __pyx_vtabstruct_5lurrn_8sparsmat_LargeVecD2 {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*to_csr)(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_LargeVecD2 *__pyx_vtabptr_5lurrn_8sparsmat_LargeVecD2;


/* "View.MemoryView":302
 * 
 * @cname('__pyx_memoryview')
 * cdef class memoryview(object):             # <<<<<<<<<<<<<<
 * 
 *     cdef object obj
 */

struct __pyx_vtabstruct_memoryview {
  char *(*get_item_pointer)(struct __pyx_memoryview_obj *, PyObject *);
  PyObject *(*is_slice)(struct __pyx_memoryview_obj *, PyObject *);
  PyObject *(*setitem_slice_assignment)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
  PyObject *(*setitem_slice_assign_scalar)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *);
  PyObject *(*setitem_indexed)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
  PyObject *(*convert_item_to_object)(struct __pyx_memoryview_obj *, char *);
  PyObject *(*assign_item_from_object)(struct __pyx_memoryview_obj *, char *, PyObject *);
};
static struct __pyx_vtabstruct_memoryview *__pyx_vtabptr_memoryview;


/* "View.MemoryView":922
 * 
 * @cname('__pyx_memoryviewslice')
 * cdef class _memoryviewslice(memoryview):             # <<<<<<<<<<<<<<
 *     "Internal class for passing memoryview slices to Python"
 * 
 */

struct __pyx_vtabstruct__memoryviewslice {
  struct __pyx_vtabstruct_memoryview __pyx_base;
};
static struct __pyx_vtabstruct__memoryviewslice *__pyx_vtabptr__memoryviewslice;
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
          if (acquire_gil) { \
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
              PyGILState_Release(__pyx_gilstate_save); \
          } else { \
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext() \
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {                            \
        PyObject *tmp = (PyObject *) r;                         \
        r = v; __Pyx_XDECREF(tmp);                              \
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {                             \
        PyObject *tmp = (PyObject *) r;                         \
        r = v; __Pyx_DECREF(tmp);                               \
    } while (0)
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

static PyObject *__Pyx_GetBuiltinName(PyObject *name);

static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
    const char* function_name);

static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);

static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact);

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb);

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);

static CYTHON_INLINE int  __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
    __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);

static void __Pyx_RaiseBufferFallbackError(void);

static void __Pyx_RaiseBufferIndexError(int axis);

#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0)
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif

static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename,
                                  int full_traceback);

#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif

#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) : \
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) : \
               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE int __Pyx_IterFinish(void);

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len)) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

static CYTHON_INLINE int __Pyx_div_int(int, int); /* proto */

#define UNARY_NEG_WOULD_OVERFLOW(x)            (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))

static CYTHON_INLINE long __Pyx_div_long(long, long); /* proto */

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);

#include <string.h>

static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);

static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);

#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
#else
#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
#endif

static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);

static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x);

#define __Pyx_PyObject_DelSlice(obj, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound) \
    __Pyx_PyObject_SetSlice(obj, (PyObject*)NULL, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound)
static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
        PyObject* obj, PyObject* value, Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
        int has_cstart, int has_cstop, int wraparound);

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb);
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb);

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);

static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);

#define __Pyx_BUF_MAX_NDIMS %(BUF_MAX_NDIMS)d
#define __Pyx_MEMVIEW_DIRECT   1
#define __Pyx_MEMVIEW_PTR      2
#define __Pyx_MEMVIEW_FULL     4
#define __Pyx_MEMVIEW_CONTIG   8
#define __Pyx_MEMVIEW_STRIDED  16
#define __Pyx_MEMVIEW_FOLLOW   32
#define __Pyx_IS_C_CONTIG 1
#define __Pyx_IS_F_CONTIG 2
static int __Pyx_init_memviewslice(
                struct __pyx_memoryview_obj *memview,
                int ndim,
                __Pyx_memviewslice *memviewslice,
                int memview_is_new_reference);
static CYTHON_INLINE int __pyx_add_acquisition_count_locked(
    __pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
static CYTHON_INLINE int __pyx_sub_acquisition_count_locked(
    __pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
#define __pyx_get_slice_count_pointer(memview) (memview->acquisition_count_aligned_p)
#define __pyx_get_slice_count(memview) (*__pyx_get_slice_count_pointer(memview))
#define __PYX_INC_MEMVIEW(slice, have_gil) __Pyx_INC_MEMVIEW(slice, have_gil, __LINE__)
#define __PYX_XDEC_MEMVIEW(slice, have_gil) __Pyx_XDEC_MEMVIEW(slice, have_gil, __LINE__)
static CYTHON_INLINE void __Pyx_INC_MEMVIEW(__Pyx_memviewslice *, int, int);
static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *, int, int);

#if PY_MAJOR_VERSION < 3
#define __Pyx_PyString_Join __Pyx_PyBytes_Join
#define __Pyx_PyBaseString_Join(s, v) (PyUnicode_CheckExact(s) ? PyUnicode_Join(s, v) : __Pyx_PyBytes_Join(s, v))
#else
#define __Pyx_PyString_Join PyUnicode_Join
#define __Pyx_PyBaseString_Join PyUnicode_Join
#endif
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION < 3
    #define __Pyx_PyBytes_Join _PyString_Join
    #else
    #define __Pyx_PyBytes_Join _PyBytes_Join
    #endif
#else
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values);
#endif

static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);

static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t); /* proto */

static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static PyObject *get_memview(PyObject *__pyx_v_self); /*proto*/
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);

static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
         const char* cstring, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));

static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);

static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static PyObject *__pyx_memoryview_transpose(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview__get__base(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_shape(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_strides(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_suboffsets(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_ndim(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_itemsize(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_nbytes(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_size(PyObject *__pyx_v_self); /*proto*/
static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject* none = _PyList_Extend((PyListObject*)L, v);
    if (unlikely(!none))
        return -1;
    Py_DECREF(none);
    return 0;
#else
    return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v);
#endif
}

static PyObject *__pyx_memoryviewslice__get__base(PyObject *__pyx_v_self); /*proto*/
static int __Pyx_SetVtable(PyObject *dict, void *vtable);

typedef struct {
    int code_line;
    PyCodeObject* code_object;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

typedef struct {
  Py_ssize_t shape, strides, suboffsets;
} __Pyx_Buf_DimInfo;
typedef struct {
  size_t refcount;
  Py_buffer pybuffer;
} __Pyx_Buffer;
typedef struct {
  __Pyx_Buffer *rcbuffer;
  char *data;
  __Pyx_Buf_DimInfo diminfo[8];
} __Pyx_LocalBuf_ND;

#if PY_MAJOR_VERSION < 3
    static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
    static void __Pyx_ReleaseBuffer(Py_buffer *view);
#else
    #define __Pyx_GetBuffer PyObject_GetBuffer
    #define __Pyx_ReleaseBuffer PyBuffer_Release
#endif


static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0};
static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1};

static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

static CYTHON_INLINE coordinate_t __Pyx_PyInt_As_coordinate_t(PyObject *);

static int __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b);

static int __Pyx_ValidateAndInit_memviewslice(
                int *axes_specs,
                int c_or_f_flag,
                int buf_flags,
                int ndim,
                __Pyx_TypeInfo *dtype,
                __Pyx_BufFmt_StackElem stack[],
                __Pyx_memviewslice *memviewslice,
                PyObject *original_obj);

static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_int(PyObject *);

static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_float(PyObject *);

static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_double(PyObject *);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_coordinate_t(coordinate_t value);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

static CYTHON_INLINE npy_int32 __Pyx_PyInt_As_npy_int32(PyObject *);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_npy_int32(npy_int32 value);

static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);

static PyObject *__pyx_memview_get_int(const char *itemp);
static int __pyx_memview_set_int(const char *itemp, PyObject *obj);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value);

static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value);

static PyObject *__pyx_memview_get_float(const char *itemp);
static int __pyx_memview_set_float(const char *itemp, PyObject *obj);

static PyObject *__pyx_memview_get_double(const char *itemp);
static int __pyx_memview_set_double(const char *itemp, PyObject *obj);

static int __Pyx_Print(PyObject*, PyObject *, int);
#if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3
static PyObject* __pyx_print = 0;
static PyObject* __pyx_print_kwargs = 0;
#endif

static int __Pyx_PrintOne(PyObject* stream, PyObject *o);

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    #define __Pyx_CREAL(z) ((z).real())
    #define __Pyx_CIMAG(z) ((z).imag())
  #else
    #define __Pyx_CREAL(z) (__real__(z))
    #define __Pyx_CIMAG(z) (__imag__(z))
  #endif
#else
    #define __Pyx_CREAL(z) ((z).real)
    #define __Pyx_CIMAG(z) ((z).imag)
#endif
#if (defined(_WIN32) || defined(__clang__)) && defined(__cplusplus) && CYTHON_CCOMPLEX
    #define __Pyx_SET_CREAL(z,x) ((z).real(x))
    #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
#else
    #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
    #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
#endif

static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);

#if CYTHON_CCOMPLEX
    #define __Pyx_c_eqf(a, b)   ((a)==(b))
    #define __Pyx_c_sumf(a, b)  ((a)+(b))
    #define __Pyx_c_difff(a, b) ((a)-(b))
    #define __Pyx_c_prodf(a, b) ((a)*(b))
    #define __Pyx_c_quotf(a, b) ((a)/(b))
    #define __Pyx_c_negf(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zerof(z) ((z)==(float)0)
    #define __Pyx_c_conjf(z)    (::std::conj(z))
    #if 1
        #define __Pyx_c_absf(z)     (::std::abs(z))
        #define __Pyx_c_powf(a, b)  (::std::pow(a, b))
    #endif
  #else
    #define __Pyx_c_is_zerof(z) ((z)==0)
    #define __Pyx_c_conjf(z)    (conjf(z))
    #if 1
        #define __Pyx_c_absf(z)     (cabsf(z))
        #define __Pyx_c_powf(a, b)  (cpowf(a, b))
    #endif
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex);
    static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex);
    #if 1
        static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex);
        static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex);
    #endif
#endif

static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);

#if CYTHON_CCOMPLEX
    #define __Pyx_c_eq(a, b)   ((a)==(b))
    #define __Pyx_c_sum(a, b)  ((a)+(b))
    #define __Pyx_c_diff(a, b) ((a)-(b))
    #define __Pyx_c_prod(a, b) ((a)*(b))
    #define __Pyx_c_quot(a, b) ((a)/(b))
    #define __Pyx_c_neg(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zero(z) ((z)==(double)0)
    #define __Pyx_c_conj(z)    (::std::conj(z))
    #if 1
        #define __Pyx_c_abs(z)     (::std::abs(z))
        #define __Pyx_c_pow(a, b)  (::std::pow(a, b))
    #endif
  #else
    #define __Pyx_c_is_zero(z) ((z)==0)
    #define __Pyx_c_conj(z)    (conj(z))
    #if 1
        #define __Pyx_c_abs(z)     (cabs(z))
        #define __Pyx_c_pow(a, b)  (cpow(a, b))
    #endif
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex);
    static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex);
    #if 1
        static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex);
        static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex);
    #endif
#endif

static int __pyx_memviewslice_is_contig(const __Pyx_memviewslice *mvs,
                                        char order, int ndim);

static int __pyx_slices_overlap(__Pyx_memviewslice *slice1,
                                __Pyx_memviewslice *slice2,
                                int ndim, size_t itemsize);

static __Pyx_memviewslice
__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
                                 const char *mode, int ndim,
                                 size_t sizeof_dtype, int contig_flag,
                                 int dtype_is_object);

static CYTHON_INLINE PyObject *__pyx_capsule_create(void *p, const char *sig);

static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *);

static int __Pyx_check_binary_version(void);

#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif

static PyObject *__Pyx_ImportModule(const char *name);

static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);

static void __pyx_f_5lurrn_8sparsmat_10CSRMatrixI_set_matrix(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, struct CSRMatrix<int> *__pyx_v_mat_new); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_fromVectors(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_vectors, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_10CSRMatrixI_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_transform_mi(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_transform_mi_discount(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_transform_ll(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_transform_l1(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_apply_threshold(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyArrayObject *__pyx_v_thr, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_apply_scaling(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyArrayObject *__pyx_v_thr, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_10CSRMatrixI_get_count(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, coordinate_t __pyx_v_k, coordinate_t __pyx_v_k2, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_10CSRMatrixF_set_matrix(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, struct CSRMatrix<float> *__pyx_v_mat_new); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_fromVectors(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_vectors, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_10CSRMatrixF_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_transform_mi(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_transform_mi_discount(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_transform_ll(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_transform_l1(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_apply_threshold(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyArrayObject *__pyx_v_thr, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_apply_scaling(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyArrayObject *__pyx_v_thr, int __pyx_skip_dispatch); /* proto*/
static float __pyx_f_5lurrn_8sparsmat_10CSRMatrixF_get_count(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, coordinate_t __pyx_v_k, coordinate_t __pyx_v_k2, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_10CSRMatrixD_set_matrix(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, struct CSRMatrix<double> *__pyx_v_mat_new); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_fromVectors(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_vectors, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_10CSRMatrixD_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_transform_mi(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_transform_mi_discount(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_transform_ll(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_transform_l1(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_apply_threshold(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyArrayObject *__pyx_v_thr, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_apply_scaling(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyArrayObject *__pyx_v_thr, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_10CSRMatrixD_get_count(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, coordinate_t __pyx_v_k, coordinate_t __pyx_v_k2, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecI1_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecI1_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecI1_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, coordinate_t __pyx_v_k0, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecI1_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, coordinate_t __pyx_v_k0, int __pyx_v_item); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_f_5lurrn_8sparsmat_5VecI1_to_sparse(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecI1_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI1_get_maxcol *__pyx_optional_args); /* proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecI1_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI1_get_type_counts *__pyx_optional_args); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_f_5lurrn_8sparsmat_5VecI1_remap(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecI2_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecI2_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecI2_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecI2_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, int __pyx_v_item); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_f_5lurrn_8sparsmat_5VecI2_to_csr(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecI2_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI2_get_maxcol *__pyx_optional_args); /* proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecI2_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI2_get_type_counts *__pyx_optional_args); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_f_5lurrn_8sparsmat_5VecI2_remap(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_f_5lurrn_8sparsmat_10LargeVecI2_to_csr(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecI3_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecI3_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecI3_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecI3_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, int __pyx_v_item); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecI3_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI3_get_maxcol *__pyx_optional_args); /* proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecI3_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI3_get_type_counts *__pyx_optional_args); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_f_5lurrn_8sparsmat_5VecI3_remap(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_13SparseVectorI_from_dense(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, __Pyx_memviewslice __pyx_v_dense, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_13SparseVectorI_dotSelf(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_13SparseVectorI__dotFull(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, const int * __pyx_v_full_ptr); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_13SparseVectorI__dotFull_partial(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, const int * __pyx_v_full_ptr, int __pyx_v_my_len); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorI_jaccard(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_13SparseVectorI_dotSparse(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorI_min_sum(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorI_cosine(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorI_jsd_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorI_skew_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other, double __pyx_v_alpha, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorI_norm_l1(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorI_norm_l2(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorI_norm_lp(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, double __pyx_v_p, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_13SparseVectorI__axpy(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, int *__pyx_v_x_ptr, int __pyx_v_a); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_13SparseVectorI_sqdist(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_f_5lurrn_8sparsmat_13SparseVectorI_min_vals(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_f_5lurrn_8sparsmat_14SparseVectorsI_to_vec(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_5lurrn_8sparsmat_14SparseVectorsI_add(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_vec, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsI_add *__pyx_optional_args); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_14SparseVectorsI__dotFull(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_self, const int * __pyx_v_full_ptr); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecF1_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecF1_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self); /* proto*/
static float __pyx_f_5lurrn_8sparsmat_5VecF1_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, coordinate_t __pyx_v_k0, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecF1_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, coordinate_t __pyx_v_k0, float __pyx_v_item); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_f_5lurrn_8sparsmat_5VecF1_to_sparse(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecF1_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF1_get_maxcol *__pyx_optional_args); /* proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecF1_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF1_get_type_counts *__pyx_optional_args); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_f_5lurrn_8sparsmat_5VecF1_remap(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecF2_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecF2_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self); /* proto*/
static float __pyx_f_5lurrn_8sparsmat_5VecF2_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecF2_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, float __pyx_v_item); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_f_5lurrn_8sparsmat_5VecF2_to_csr(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecF2_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF2_get_maxcol *__pyx_optional_args); /* proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecF2_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF2_get_type_counts *__pyx_optional_args); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_f_5lurrn_8sparsmat_5VecF2_remap(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_f_5lurrn_8sparsmat_10LargeVecF2_to_csr(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecF3_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecF3_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self); /* proto*/
static float __pyx_f_5lurrn_8sparsmat_5VecF3_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecF3_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, float __pyx_v_item); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecF3_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF3_get_maxcol *__pyx_optional_args); /* proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecF3_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF3_get_type_counts *__pyx_optional_args); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_f_5lurrn_8sparsmat_5VecF3_remap(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_13SparseVectorF_from_dense(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, __Pyx_memviewslice __pyx_v_dense, int __pyx_skip_dispatch); /* proto*/
static float __pyx_f_5lurrn_8sparsmat_13SparseVectorF_dotSelf(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static float __pyx_f_5lurrn_8sparsmat_13SparseVectorF__dotFull(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, const float * __pyx_v_full_ptr); /* proto*/
static float __pyx_f_5lurrn_8sparsmat_13SparseVectorF__dotFull_partial(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, const float * __pyx_v_full_ptr, int __pyx_v_my_len); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorF_jaccard(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static float __pyx_f_5lurrn_8sparsmat_13SparseVectorF_dotSparse(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorF_min_sum(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorF_cosine(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorF_jsd_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorF_skew_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other, double __pyx_v_alpha, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorF_norm_l1(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorF_norm_l2(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorF_norm_lp(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, double __pyx_v_p, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_13SparseVectorF__axpy(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, float *__pyx_v_x_ptr, float __pyx_v_a); /* proto*/
static float __pyx_f_5lurrn_8sparsmat_13SparseVectorF_sqdist(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_f_5lurrn_8sparsmat_13SparseVectorF_min_vals(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_f_5lurrn_8sparsmat_14SparseVectorsF_to_vec(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_5lurrn_8sparsmat_14SparseVectorsF_add(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_vec, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsF_add *__pyx_optional_args); /* proto*/
static float __pyx_f_5lurrn_8sparsmat_14SparseVectorsF__dotFull(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_self, const float * __pyx_v_full_ptr); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecD1_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecD1_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_5VecD1_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, coordinate_t __pyx_v_k0, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecD1_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, coordinate_t __pyx_v_k0, double __pyx_v_item); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_f_5lurrn_8sparsmat_5VecD1_to_sparse(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecD1_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD1_get_maxcol *__pyx_optional_args); /* proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecD1_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD1_get_type_counts *__pyx_optional_args); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_f_5lurrn_8sparsmat_5VecD1_remap(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecD2_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecD2_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_5VecD2_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecD2_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, double __pyx_v_item); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_5VecD2_to_csr(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecD2_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD2_get_maxcol *__pyx_optional_args); /* proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecD2_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD2_get_type_counts *__pyx_optional_args); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_f_5lurrn_8sparsmat_5VecD2_remap(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10LargeVecD2_to_csr(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecD3_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecD3_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_5VecD3_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecD3_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, double __pyx_v_item); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecD3_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD3_get_maxcol *__pyx_optional_args); /* proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecD3_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD3_get_type_counts *__pyx_optional_args); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_f_5lurrn_8sparsmat_5VecD3_remap(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_13SparseVectorD_from_dense(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, __Pyx_memviewslice __pyx_v_dense, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_dotSelf(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD__dotFull(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, const double * __pyx_v_full_ptr); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD__dotFull_partial(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, const double * __pyx_v_full_ptr, int __pyx_v_my_len); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_jaccard(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_dotSparse(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_min_sum(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_cosine(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_jsd_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_skew_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other, double __pyx_v_alpha, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_norm_l1(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_norm_l2(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_norm_lp(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, double __pyx_v_p, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_13SparseVectorD__axpy(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, double *__pyx_v_x_ptr, double __pyx_v_a); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_sqdist(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_f_5lurrn_8sparsmat_13SparseVectorD_min_vals(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_f_5lurrn_8sparsmat_14SparseVectorsD_to_vec(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_5lurrn_8sparsmat_14SparseVectorsD_add(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_vec, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsD_add *__pyx_optional_args); /* proto*/
static double __pyx_f_5lurrn_8sparsmat_14SparseVectorsD__dotFull(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_self, const double * __pyx_v_full_ptr); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecV1_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecV1_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecV1_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, coordinate_t __pyx_v_k0, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecV1_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, coordinate_t __pyx_v_k0); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecV1_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV1_get_maxcol *__pyx_optional_args); /* proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecV1_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV1_get_type_counts *__pyx_optional_args); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_f_5lurrn_8sparsmat_5VecV1_remap(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecV2_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecV2_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecV2_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecV2_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecV2_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV2_get_maxcol *__pyx_optional_args); /* proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecV2_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV2_get_type_counts *__pyx_optional_args); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_f_5lurrn_8sparsmat_5VecV2_remap(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecV3_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecV3_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecV3_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_5lurrn_8sparsmat_5VecV3_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2); /* proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecV3_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV3_get_maxcol *__pyx_optional_args); /* proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecV3_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV3_get_type_counts *__pyx_optional_args); /* proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_f_5lurrn_8sparsmat_5VecV3_remap(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch); /* proto*/
static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto*/
static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj); /* proto*/
static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src); /* proto*/
static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value); /* proto*/
static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto*/
static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/
static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/

/* Module declarations from 'cpython.buffer' */

/* Module declarations from 'cpython.ref' */

/* Module declarations from 'libc.string' */

/* Module declarations from 'libc.stdio' */

/* Module declarations from 'cpython.object' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.type' */
static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;

/* Module declarations from 'libc.stdlib' */

/* Module declarations from 'numpy' */

/* Module declarations from 'numpy' */
static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/

/* Module declarations from 'lurrn.sparsmat' */
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_CSRMatrixD = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_CSRMatrixI = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_SparseVectorI = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_VecI1 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_VecI2 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_VecI3 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_SparseVectorsI = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_CSRMatrixF = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_SparseVectorF = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_VecF1 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_VecF2 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_VecF3 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_SparseVectorsF = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_SparseVectorD = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_VecD1 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_VecD2 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_VecD3 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_SparseVectorsD = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_VecV1 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_VecV2 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_VecV3 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_CSRMatrixI_item_iter = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_CSRMatrixF_item_iter = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_CSRMatrixD_item_iter = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_IVecI1_iter = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_LargeVecI1 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_IVecI2_iter = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_LargeVecI2 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_IVecI3_iter = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_LargeVecI3 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_IVecF1_iter = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_LargeVecF1 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_IVecF2_iter = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_LargeVecF2 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_IVecF3_iter = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_LargeVecF3 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_IVecD1_iter = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_LargeVecD1 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_IVecD2_iter = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_LargeVecD2 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_IVecD3_iter = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_LargeVecD3 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_IVecV1_iter = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_LargeVecV1 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_IVecV2_iter = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_LargeVecV2 = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_IVecV3_iter = 0;
static PyTypeObject *__pyx_ptype_5lurrn_8sparsmat_LargeVecV3 = 0;
static PyTypeObject *__pyx_array_type = 0;
static PyTypeObject *__pyx_MemviewEnum_type = 0;
static PyTypeObject *__pyx_memoryview_type = 0;
static PyTypeObject *__pyx_memoryviewslice_type = 0;
static unsigned int __pyx_v_5lurrn_8sparsmat_BIG_ITEMS;
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_5lurrn_8sparsmat_emptyvec_I = 0;
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_5lurrn_8sparsmat_emptyvec_F = 0;
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_5lurrn_8sparsmat_emptyvec_D = 0;
static PyObject *generic = 0;
static PyObject *strided = 0;
static PyObject *indirect = 0;
static PyObject *contiguous = 0;
static PyObject *indirect_contiguous = 0;
static double __pyx_f_5lurrn_8sparsmat_logB(double, double, double); /*proto*/
static struct __pyx_array_obj *__pyx_array_new(PyObject *, Py_ssize_t, char *, char *, char *); /*proto*/
static void *__pyx_align_pointer(void *, size_t); /*proto*/
static PyObject *__pyx_memoryview_new(PyObject *, int, int, __Pyx_TypeInfo *); /*proto*/
static CYTHON_INLINE int __pyx_memoryview_check(PyObject *); /*proto*/
static PyObject *_unellipsify(PyObject *, int); /*proto*/
static PyObject *assert_direct_dimensions(Py_ssize_t *, int); /*proto*/
static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *, PyObject *); /*proto*/
static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int, int); /*proto*/
static char *__pyx_pybuffer_index(Py_buffer *, char *, Py_ssize_t, Py_ssize_t); /*proto*/
static int __pyx_memslice_transpose(__Pyx_memviewslice *); /*proto*/
static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice, int, PyObject *(*)(char *), int (*)(char *, PyObject *), int); /*proto*/
static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *); /*proto*/
static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
static Py_ssize_t abs_py_ssize_t(Py_ssize_t); /*proto*/
static char __pyx_get_best_slice_order(__Pyx_memviewslice *, int); /*proto*/
static void _copy_strided_to_strided(char *, Py_ssize_t *, char *, Py_ssize_t *, Py_ssize_t *, Py_ssize_t *, int, size_t); /*proto*/
static void copy_strided_to_strided(__Pyx_memviewslice *, __Pyx_memviewslice *, int, size_t); /*proto*/
static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *, int); /*proto*/
static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *, Py_ssize_t *, Py_ssize_t, int, char); /*proto*/
static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *, __Pyx_memviewslice *, char, int); /*proto*/
static int __pyx_memoryview_err_extents(int, Py_ssize_t, Py_ssize_t); /*proto*/
static int __pyx_memoryview_err_dim(PyObject *, char *, int); /*proto*/
static int __pyx_memoryview_err(PyObject *, char *); /*proto*/
static int __pyx_memoryview_copy_contents(__Pyx_memviewslice, __Pyx_memviewslice, int, int, int); /*proto*/
static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *, int, int); /*proto*/
static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *, int, int, int); /*proto*/
static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
static void __pyx_memoryview_refcount_objects_in_slice(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *, int, size_t, void *, int); /*proto*/
static void __pyx_memoryview__slice_assign_scalar(char *, Py_ssize_t *, Py_ssize_t *, int, size_t, void *); /*proto*/
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t = { "int32_t", NULL, sizeof(__pyx_t_5numpy_int32_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_5numpy_int32_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_5numpy_int32_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t = { "float32_t", NULL, sizeof(__pyx_t_5numpy_float32_t), { 0 }, 0, 'R', 0, 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t = { "float64_t", NULL, sizeof(__pyx_t_5numpy_float64_t), { 0 }, 0, 'R', 0, 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t = { "int8_t", NULL, sizeof(__pyx_t_5numpy_int8_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_5numpy_int8_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_5numpy_int8_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int_t = { "int_t", NULL, sizeof(__pyx_t_5numpy_int_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_5numpy_int_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_5numpy_int_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_int = { "int", NULL, sizeof(int), { 0 }, 0, IS_UNSIGNED(int) ? 'U' : 'I', IS_UNSIGNED(int), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_float = { "float", NULL, sizeof(float), { 0 }, 0, 'R', 0, 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_double = { "double", NULL, sizeof(double), { 0 }, 0, 'R', 0, 0 };
#define __Pyx_MODULE_NAME "lurrn.sparsmat"
int __pyx_module_is_main_lurrn__sparsmat = 0;

/* Implementation of 'lurrn.sparsmat' */
static PyObject *__pyx_builtin_IndexError;
static PyObject *__pyx_builtin_StopIteration;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_sum;
static PyObject *__pyx_builtin_file;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_MemoryError;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_Ellipsis;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_xrange;
static PyObject *__pyx_builtin_id;
static int __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI___cinit__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_vecs); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_2fromVectors(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_vectors); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_4__lshift__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_6__ilshift__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_8print_csr(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_10get_size(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self); /* proto */
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_12__len__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_14__getitem__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_16item_iter(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_18to_scipy(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_20get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_22transform_mi(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_24transform_mi_discount(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_26transform_ll(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_28transform_l1(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_30thresholds_norm(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_perc); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_32thresholds_quantile(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_perc); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_34thresholds_nonzero(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_perc); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_36get_quantiles(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_qs); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_38apply_threshold(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyArrayObject *__pyx_v_thr); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_40apply_scaling(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyArrayObject *__pyx_v_thr); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_42scale_columns(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_factors); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_44scale_rows(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_factors); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_46left_marginals(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_48right_marginals(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_50right_squared_marginals(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_52get_count(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, coordinate_t __pyx_v_k, coordinate_t __pyx_v_k2); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_54write_binary(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_56transpose(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_58__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static void __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_60__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_62__reduce__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_64__setstate__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_tmp); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_20CSRMatrixI_item_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter *__pyx_v_self, PyObject *__pyx_v_mat); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_20CSRMatrixI_item_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_20CSRMatrixI_item_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF___cinit__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_vecs); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_2fromVectors(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_vectors); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_4__lshift__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_6__ilshift__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_8print_csr(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_10get_size(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self); /* proto */
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_12__len__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_14__getitem__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_16item_iter(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_18to_scipy(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_20get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_22transform_mi(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_24transform_mi_discount(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_26transform_ll(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_28transform_l1(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_30thresholds_norm(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_perc); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_32thresholds_quantile(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_perc); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_34thresholds_nonzero(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_perc); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_36get_quantiles(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_qs); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_38apply_threshold(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyArrayObject *__pyx_v_thr); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_40apply_scaling(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyArrayObject *__pyx_v_thr); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_42scale_columns(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_factors); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_44scale_rows(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_factors); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_46left_marginals(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_48right_marginals(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_50right_squared_marginals(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_52get_count(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, coordinate_t __pyx_v_k, coordinate_t __pyx_v_k2); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_54write_binary(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_56transpose(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_58__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static void __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_60__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_62__reduce__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_64__setstate__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_tmp); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_20CSRMatrixF_item_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter *__pyx_v_self, PyObject *__pyx_v_mat); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_20CSRMatrixF_item_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_20CSRMatrixF_item_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD___cinit__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_vecs); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_2fromVectors(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_vectors); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_4__lshift__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_6__ilshift__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_8print_csr(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_10get_size(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self); /* proto */
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_12__len__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_14__getitem__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_16item_iter(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_18to_scipy(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_20get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_22transform_mi(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_24transform_mi_discount(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_26transform_ll(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_28transform_l1(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_30thresholds_norm(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_perc); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_32thresholds_quantile(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_perc); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_34thresholds_nonzero(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_perc); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_36get_quantiles(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_qs); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_38apply_threshold(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyArrayObject *__pyx_v_thr); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_40apply_scaling(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyArrayObject *__pyx_v_thr); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_42scale_columns(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_factors); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_44scale_rows(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_factors); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_46left_marginals(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_48right_marginals(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_50right_squared_marginals(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_52get_count(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, coordinate_t __pyx_v_k, coordinate_t __pyx_v_k2); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_54write_binary(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_56transpose(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_58__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static void __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_60__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_62__reduce__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_64__setstate__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_20CSRMatrixD_item_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter *__pyx_v_self, PyObject *__pyx_v_mat); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_20CSRMatrixD_item_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_20CSRMatrixD_item_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_csrFromBuffer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_2mmapCSR(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_f); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_5VecI1___init__(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecI1_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, coordinate_t __pyx_v_k0); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, coordinate_t __pyx_v_k0, PyObject *__pyx_v_item); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_16to_sparse(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_18tofile(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_20fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_22get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_24get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_26remap(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_28append(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, PyObject *__pyx_v_tup); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_30extend(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, PyObject *__pyx_v_tups); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_32__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_34__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_36__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_38__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self); /* proto */
static void __pyx_pf_5lurrn_8sparsmat_5VecI1_40__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_11IVecI1_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter *__pyx_v_self, PyObject *__pyx_v_vec); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecI1_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecI1_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI1___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI1_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI1_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self, coordinate_t __pyx_v_k0, PyObject *__pyx_v_item); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI1_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI1_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI1_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI1_12get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self, PyObject *__pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI1_14remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI1_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI1_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_5VecI2___init__(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecI2_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, PyObject *__pyx_v_item); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_16to_csr(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_18tofile(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_20fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_22get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_24get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_26remap(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_28append(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, PyObject *__pyx_v_tup); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_30extend(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, PyObject *__pyx_v_tups); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_32__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_34__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_36__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_38__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self); /* proto */
static void __pyx_pf_5lurrn_8sparsmat_5VecI2_40__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_11IVecI2_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter *__pyx_v_self, PyObject *__pyx_v_vec); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecI2_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecI2_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI2___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, PyObject *__pyx_v_item); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_12to_csr(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_14get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self, PyObject *__pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_16remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_5VecI3___init__(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecI3_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, PyObject *__pyx_v_item); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_16tofile(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_18fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_20get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_22get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_24remap(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_26append(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, PyObject *__pyx_v_tup); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_28extend(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, PyObject *__pyx_v_tups); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_30__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_32__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_34__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_36__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self); /* proto */
static void __pyx_pf_5lurrn_8sparsmat_5VecI3_38__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_11IVecI3_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter *__pyx_v_self, PyObject *__pyx_v_vec); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecI3_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecI3_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI3___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI3_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI3_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, PyObject *__pyx_v_item); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI3_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI3_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI3_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI3_12get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self, PyObject *__pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI3_14remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI3_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI3_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_13SparseVectorI___init__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, PyObject *__pyx_v_pairs); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_2from_dense(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, __Pyx_memviewslice __pyx_v_dense); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_4dotSelf(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_6jaccard(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_8dotSparse(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_10count_intersection(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_12min_sum(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_14cosine(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_16jsd_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_18skew_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other, double __pyx_v_alpha); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_20norm_l1(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_22norm_l2(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_24norm_lp(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, double __pyx_v_p); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_26dotFull(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, PyArrayObject *__pyx_v_full); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_28dotFull_check(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, PyArrayObject *__pyx_v_full); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_30dotMatrix(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, PyArrayObject *__pyx_v_full); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_32axpy(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, PyArrayObject *__pyx_v_x, int __pyx_v_a); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_34sqdist(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_36write_pairs(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, PyObject *__pyx_v_f, PyObject *__pyx_v_delim); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_38__imul__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, int __pyx_v_a); /* proto */
#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_40__idiv__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, int __pyx_v_a); /* proto */
#endif
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_42min_vals(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_44scale_array(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, PyArrayObject *__pyx_v_a); /* proto */
#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_46__div__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, int __pyx_v_a); /* proto */
#endif
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_48__len__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_50__add__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_52__sub__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_54__or__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_56__lshift__(PyObject *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_58__ilshift__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_60__getitem__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, int __pyx_v_i); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_62__repr__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_64__reduce_ex__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, PyObject *__pyx_v_protocol); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_66__setstate__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, PyObject *__pyx_v_state); /* proto */
static void __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_68__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_70to_scipy(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_14SparseVectorsI___init__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_2to_vec(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_4add(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_vec, int __pyx_v_weight); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_6__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_factor); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_8__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_others); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_10__sub__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_others); /* proto */
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_12__len__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_14__getitem__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_self, PyObject *__pyx_v_k); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_5VecF1___init__(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecF1_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, coordinate_t __pyx_v_k0); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, coordinate_t __pyx_v_k0, PyObject *__pyx_v_item); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_16to_sparse(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_18tofile(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_20fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_22get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_24get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_26remap(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_28append(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, PyObject *__pyx_v_tup); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_30extend(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, PyObject *__pyx_v_tups); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_32__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_34__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_36__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_38__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self); /* proto */
static void __pyx_pf_5lurrn_8sparsmat_5VecF1_40__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_11IVecF1_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter *__pyx_v_self, PyObject *__pyx_v_vec); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecF1_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecF1_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF1___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF1_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF1_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self, coordinate_t __pyx_v_k0, PyObject *__pyx_v_item); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF1_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF1_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF1_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF1_12get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self, PyObject *__pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF1_14remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF1_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF1_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_5VecF2___init__(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecF2_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, PyObject *__pyx_v_item); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_16to_csr(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_18tofile(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_20fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_22get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_24get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_26remap(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_28append(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, PyObject *__pyx_v_tup); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_30extend(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, PyObject *__pyx_v_tups); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_32__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_34__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_36__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_38__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self); /* proto */
static void __pyx_pf_5lurrn_8sparsmat_5VecF2_40__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_11IVecF2_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter *__pyx_v_self, PyObject *__pyx_v_vec); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecF2_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecF2_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF2___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, PyObject *__pyx_v_item); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_12to_csr(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_14get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self, PyObject *__pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_16remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_5VecF3___init__(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecF3_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, PyObject *__pyx_v_item); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_16tofile(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_18fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_20get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_22get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_24remap(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_26append(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, PyObject *__pyx_v_tup); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_28extend(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, PyObject *__pyx_v_tups); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_30__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_32__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_34__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_36__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self); /* proto */
static void __pyx_pf_5lurrn_8sparsmat_5VecF3_38__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_11IVecF3_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter *__pyx_v_self, PyObject *__pyx_v_vec); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecF3_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecF3_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF3___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF3_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF3_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, PyObject *__pyx_v_item); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF3_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF3_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF3_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF3_12get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self, PyObject *__pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF3_14remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF3_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF3_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_13SparseVectorF___init__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, PyObject *__pyx_v_pairs); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_2from_dense(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, __Pyx_memviewslice __pyx_v_dense); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_4dotSelf(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_6jaccard(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_8dotSparse(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_10count_intersection(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_12min_sum(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_14cosine(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_16jsd_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_18skew_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other, double __pyx_v_alpha); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_20norm_l1(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_22norm_l2(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_24norm_lp(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, double __pyx_v_p); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_26dotFull(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, PyArrayObject *__pyx_v_full); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_28dotFull_check(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, PyArrayObject *__pyx_v_full); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_30dotMatrix(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, PyArrayObject *__pyx_v_full); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_32axpy(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, PyArrayObject *__pyx_v_x, float __pyx_v_a); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_34sqdist(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_36write_pairs(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, PyObject *__pyx_v_f, PyObject *__pyx_v_delim); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_38__imul__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, float __pyx_v_a); /* proto */
#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_40__idiv__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, float __pyx_v_a); /* proto */
#endif
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_42min_vals(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_44scale_array(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, PyArrayObject *__pyx_v_a); /* proto */
#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_46__div__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, float __pyx_v_a); /* proto */
#endif
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_48__len__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_50__add__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_52__sub__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_54__or__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_56__lshift__(PyObject *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_58__ilshift__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_60__getitem__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, int __pyx_v_i); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_62__repr__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_64__reduce_ex__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, PyObject *__pyx_v_protocol); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_66__setstate__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, PyObject *__pyx_v_state); /* proto */
static void __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_68__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_70to_scipy(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_14SparseVectorsF___init__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_2to_vec(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_4add(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_vec, float __pyx_v_weight); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_6__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_factor); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_8__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_others); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_10__sub__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_others); /* proto */
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_12__len__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_14__getitem__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_self, PyObject *__pyx_v_k); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_5VecD1___init__(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecD1_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, coordinate_t __pyx_v_k0); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, coordinate_t __pyx_v_k0, PyObject *__pyx_v_item); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_16to_sparse(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_18tofile(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_20fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_22get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_24get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_26remap(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_28append(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, PyObject *__pyx_v_tup); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_30extend(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, PyObject *__pyx_v_tups); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_32__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_34__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_36__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_38__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self); /* proto */
static void __pyx_pf_5lurrn_8sparsmat_5VecD1_40__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_11IVecD1_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter *__pyx_v_self, PyObject *__pyx_v_vec); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecD1_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecD1_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD1___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD1_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD1_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self, coordinate_t __pyx_v_k0, PyObject *__pyx_v_item); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD1_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD1_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD1_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD1_12get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self, PyObject *__pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD1_14remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD1_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD1_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_5VecD2___init__(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecD2_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, PyObject *__pyx_v_item); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_16to_csr(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_18tofile(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_20fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_22get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_24get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_26remap(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_28append(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, PyObject *__pyx_v_tup); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_30extend(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, PyObject *__pyx_v_tups); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_32__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_34__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_36__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_38__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self); /* proto */
static void __pyx_pf_5lurrn_8sparsmat_5VecD2_40__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_11IVecD2_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter *__pyx_v_self, PyObject *__pyx_v_vec); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecD2_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecD2_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD2___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, PyObject *__pyx_v_item); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_12to_csr(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_14get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self, PyObject *__pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_16remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_5VecD3___init__(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecD3_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, PyObject *__pyx_v_item); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_16tofile(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_18fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_20get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_22get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_24remap(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_26append(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, PyObject *__pyx_v_tup); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_28extend(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, PyObject *__pyx_v_tups); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_30__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_32__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_34__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_36__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self); /* proto */
static void __pyx_pf_5lurrn_8sparsmat_5VecD3_38__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_11IVecD3_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter *__pyx_v_self, PyObject *__pyx_v_vec); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecD3_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecD3_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD3___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD3_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD3_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, PyObject *__pyx_v_item); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD3_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD3_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD3_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD3_12get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self, PyObject *__pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD3_14remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD3_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD3_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_13SparseVectorD___init__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, PyObject *__pyx_v_pairs); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_2from_dense(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, __Pyx_memviewslice __pyx_v_dense); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_4dotSelf(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_6jaccard(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_8dotSparse(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_10count_intersection(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_12min_sum(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_14cosine(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_16jsd_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_18skew_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other, double __pyx_v_alpha); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_20norm_l1(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_22norm_l2(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_24norm_lp(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, double __pyx_v_p); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_26dotFull(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, PyArrayObject *__pyx_v_full); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_28dotFull_check(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, PyArrayObject *__pyx_v_full); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_30dotMatrix(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, PyArrayObject *__pyx_v_full); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_32axpy(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, PyArrayObject *__pyx_v_x, double __pyx_v_a); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_34sqdist(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_36write_pairs(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, PyObject *__pyx_v_f, PyObject *__pyx_v_delim); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_38__imul__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, double __pyx_v_a); /* proto */
#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_40__idiv__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, double __pyx_v_a); /* proto */
#endif
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_42min_vals(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_44scale_array(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, PyArrayObject *__pyx_v_a); /* proto */
#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_46__div__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, double __pyx_v_a); /* proto */
#endif
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_48__len__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_50__add__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_52__sub__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_54__or__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_56__lshift__(PyObject *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_58__ilshift__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_60__getitem__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, int __pyx_v_i); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_62__repr__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_64__reduce_ex__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, PyObject *__pyx_v_protocol); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_66__setstate__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, PyObject *__pyx_v_state); /* proto */
static void __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_68__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_70to_scipy(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_14SparseVectorsD___init__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_2to_vec(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_4add(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_vec, double __pyx_v_weight); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_6__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_factor); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_8__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_others); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_10__sub__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_others); /* proto */
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_12__len__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_14__getitem__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_self, PyObject *__pyx_v_k); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_5VecV1___init__(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecV1_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, coordinate_t __pyx_v_k0); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, coordinate_t __pyx_v_k0); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_16to_array(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_18tofile(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_20fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_22get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_24get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_26remap(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_28append(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, PyObject *__pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_30extend(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, PyObject *__pyx_v_tups); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_32__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_34__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_36__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_38__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self); /* proto */
static void __pyx_pf_5lurrn_8sparsmat_5VecV1_40__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_11IVecV1_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter *__pyx_v_self, PyObject *__pyx_v_vec); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecV1_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecV1_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV1___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV1_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV1_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self, coordinate_t __pyx_v_k0); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV1_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV1_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV1_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV1_12get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self, PyObject *__pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV1_14remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV1_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV1_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_5VecV2___init__(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecV2_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_16tofile(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_18fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_20get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_22get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_24remap(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_26append(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, PyObject *__pyx_v_tup); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_28extend(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, PyObject *__pyx_v_tups); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_30__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_32__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_34__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_36__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self); /* proto */
static void __pyx_pf_5lurrn_8sparsmat_5VecV2_38__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_11IVecV2_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter *__pyx_v_self, PyObject *__pyx_v_vec); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecV2_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecV2_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV2___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV2_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV2_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV2_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV2_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV2_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV2_12get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self, PyObject *__pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV2_14remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV2_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV2_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_5VecV3___init__(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecV3_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_16tofile(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_18fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_20get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_22get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_24remap(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_26append(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, PyObject *__pyx_v_tup); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_28extend(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, PyObject *__pyx_v_tups); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_30__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_32__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_34__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_36__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self); /* proto */
static void __pyx_pf_5lurrn_8sparsmat_5VecV3_38__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_11IVecV3_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter *__pyx_v_self, PyObject *__pyx_v_vec); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecV3_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecV3_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV3___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV3_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV3_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV3_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV3_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self, PyObject *__pyx_v_compactify); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV3_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV3_12get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self, PyObject *__pyx_v_k); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV3_14remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV3_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV3_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5lurrn_8sparsmat_4run_test(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */
static int __pyx_array_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer); /* proto */
static int __pyx_array_getbuffer_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
static void __pyx_array_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self); /* proto */
static PyObject *get_memview_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_array_MemoryView_5array_6__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr); /* proto */
static PyObject *__pyx_array_MemoryView_5array_8__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item); /* proto */
static int __pyx_array_MemoryView_5array_10__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /* proto */
static int __pyx_MemviewEnum_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
static PyObject *__pyx_MemviewEnum_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */
static int __pyx_memoryview_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object); /* proto */
static void __pyx_memoryview_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto */
static int __pyx_memoryview_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto */
static int __pyx_memoryview_getbuffer_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
static PyObject *__pyx_memoryview_transpose_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview__get__base_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview_get_shape_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview_get_strides_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview_get_suboffsets_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview_get_ndim_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview_get_itemsize_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview_get_nbytes_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview_get_size_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static Py_ssize_t __pyx_memoryview_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static void __pyx_memoryviewslice_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryviewslice__get__base_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_CSRMatrixD(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_CSRMatrixI(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_SparseVectorI(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecI1(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecI2(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecI3(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_SparseVectorsI(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_CSRMatrixF(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_SparseVectorF(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecF1(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecF2(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecF3(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_SparseVectorsF(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_SparseVectorD(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecD1(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecD2(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecD3(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_SparseVectorsD(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecV1(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecV2(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecV3(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_CSRMatrixI_item_iter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_CSRMatrixF_item_iter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_CSRMatrixD_item_iter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecI1_iter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecI1(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecI2_iter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecI2(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecI3_iter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecI3(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecF1_iter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecF1(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecF2_iter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecF2(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecF3_iter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecF3(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecD1_iter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecD1(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecD2_iter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecD2(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecD3_iter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecD3(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecV1_iter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecV1(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecV2_iter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecV2(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecV3_iter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecV3(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static char __pyx_k_B[] = "B";
static char __pyx_k_H[] = "H";
static char __pyx_k_I[] = "I";
static char __pyx_k_L[] = "L";
static char __pyx_k_O[] = "O";
static char __pyx_k_Q[] = "Q";
static char __pyx_k_a[] = "a";
static char __pyx_k_b[] = "b";
static char __pyx_k_c[] = "c";
static char __pyx_k_d[] = "d";
static char __pyx_k_f[] = "f";
static char __pyx_k_g[] = "g";
static char __pyx_k_h[] = "h";
static char __pyx_k_i[] = "i";
static char __pyx_k_k[] = "k";
static char __pyx_k_l[] = "l";
static char __pyx_k_q[] = "q";
static char __pyx_k_w[] = "w";
static char __pyx_k_x[] = "x";
static char __pyx_k_D1[] = "D1";
static char __pyx_k_D2[] = "D2";
static char __pyx_k_D3[] = "D3";
static char __pyx_k_F1[] = "F1";
static char __pyx_k_F2[] = "F2";
static char __pyx_k_F3[] = "F3";
static char __pyx_k_I1[] = "I1";
static char __pyx_k_I2[] = "I2";
static char __pyx_k_I3[] = "I3";
static char __pyx_k_V1[] = "V1";
static char __pyx_k_V2[] = "V2";
static char __pyx_k_V3[] = "V3";
static char __pyx_k_Zd[] = "Zd";
static char __pyx_k_Zf[] = "Zf";
static char __pyx_k_Zg[] = "Zg";
static char __pyx_k_at[] = "at";
static char __pyx_k_id[] = "id";
static char __pyx_k_k0[] = "k0";
static char __pyx_k_k1[] = "k1";
static char __pyx_k_k2[] = "k2";
static char __pyx_k_sv[] = "sv";
static char __pyx_k_xs[] = "xs";
static char __pyx_k__24[] = ":";
static char __pyx_k__25[] = ",";
static char __pyx_k__94[] = " ";
static char __pyx_k_add[] = "add";
static char __pyx_k_buf[] = "buf";
static char __pyx_k_d_s[] = "(%d,%s)";
static char __pyx_k_end[] = "end";
static char __pyx_k_mat[] = "mat";
static char __pyx_k_obj[] = "obj";
static char __pyx_k_sum[] = "sum";
static char __pyx_k_sys[] = "sys";
static char __pyx_k_tmp[] = "tmp";
static char __pyx_k_vec[] = "vec";
static char __pyx_k_D1_d[] = "D1 %d\n";
static char __pyx_k_D2_d[] = "D2 %d\n";
static char __pyx_k_D3_d[] = "D3 %d\n";
static char __pyx_k_F1_d[] = "F1 %d\n";
static char __pyx_k_F2_d[] = "F2 %d\n";
static char __pyx_k_F3_d[] = "F3 %d\n";
static char __pyx_k_I1_d[] = "I1 %d\n";
static char __pyx_k_I2_d[] = "I2 %d\n";
static char __pyx_k_I3_d[] = "I3 %d\n";
static char __pyx_k_V1_d[] = "V1 %d\n";
static char __pyx_k_V2_d[] = "V2 %d\n";
static char __pyx_k_V3_d[] = "V3 %d\n";
static char __pyx_k_base[] = "base";
static char __pyx_k_file[] = "file";
static char __pyx_k_filt[] = "filt";
static char __pyx_k_flen[] = "flen";
static char __pyx_k_item[] = "item";
static char __pyx_k_join[] = "join";
static char __pyx_k_main[] = "__main__";
static char __pyx_k_mat2[] = "mat2";
static char __pyx_k_mat3[] = "mat3";
static char __pyx_k_mat4[] = "mat4";
static char __pyx_k_mat5[] = "mat5";
static char __pyx_k_mat6[] = "mat6";
static char __pyx_k_matD[] = "matD";
static char __pyx_k_matF[] = "matF";
static char __pyx_k_matI[] = "matI";
static char __pyx_k_mmap[] = "mmap";
static char __pyx_k_mode[] = "mode";
static char __pyx_k_name[] = "name";
static char __pyx_k_ndim[] = "ndim";
static char __pyx_k_pack[] = "pack";
static char __pyx_k_read[] = "read";
static char __pyx_k_seek[] = "seek";
static char __pyx_k_size[] = "size";
static char __pyx_k_sort[] = "sort";
static char __pyx_k_sqrt[] = "sqrt";
static char __pyx_k_step[] = "step";
static char __pyx_k_stop[] = "stop";
static char __pyx_k_tell[] = "tell";
static char __pyx_k_test[] = "__test__";
static char __pyx_k_vecs[] = "vecs";
static char __pyx_k_alpha[] = "alpha";
static char __pyx_k_class[] = "__class__";
static char __pyx_k_clear[] = "clear";
static char __pyx_k_d_s_s[] = " %d%s%s";
static char __pyx_k_delim[] = "delim";
static char __pyx_k_empty[] = "empty";
static char __pyx_k_error[] = "error";
static char __pyx_k_flags[] = "flags";
static char __pyx_k_int32[] = "int32";
static char __pyx_k_numpy[] = "numpy";
static char __pyx_k_other[] = "other";
static char __pyx_k_pairs[] = "pairs";
static char __pyx_k_print[] = "print";
static char __pyx_k_range[] = "range";
static char __pyx_k_remap[] = "remap";
static char __pyx_k_shape[] = "shape";
static char __pyx_k_split[] = "split";
static char __pyx_k_start[] = "start";
static char __pyx_k_strip[] = "strip";
static char __pyx_k_tcode[] = "tcode";
static char __pyx_k_write[] = "write";
static char __pyx_k_zeros[] = "zeros";
static char __pyx_k_access[] = "access";
static char __pyx_k_append[] = "append";
static char __pyx_k_astype[] = "astype";
static char __pyx_k_buffer[] = "buffer";
static char __pyx_k_c_matD[] = "c_matD";
static char __pyx_k_c_matF[] = "c_matF";
static char __pyx_k_c_matI[] = "c_matI";
static char __pyx_k_cosine[] = "cosine";
static char __pyx_k_counts[] = "counts";
static char __pyx_k_cumsum[] = "cumsum";
static char __pyx_k_extend[] = "extend";
static char __pyx_k_fileno[] = "fileno";
static char __pyx_k_format[] = "format";
static char __pyx_k_import[] = "__import__";
static char __pyx_k_my_len[] = "my_len";
static char __pyx_k_name_2[] = "__name__";
static char __pyx_k_result[] = "result";
static char __pyx_k_sqdist[] = "sqdist";
static char __pyx_k_struct[] = "struct";
static char __pyx_k_to_csr[] = "to_csr";
static char __pyx_k_to_vec[] = "to_vec";
static char __pyx_k_unpack[] = "unpack";
static char __pyx_k_weight[] = "weight";
static char __pyx_k_xrange[] = "xrange";
static char __pyx_k_VecD1_s[] = "VecD1(%s)";
static char __pyx_k_VecD2_s[] = "VecD2(%s)";
static char __pyx_k_VecD3_s[] = "VecD3(%s)";
static char __pyx_k_VecF1_s[] = "VecF1(%s)";
static char __pyx_k_VecF2_s[] = "VecF2(%s)";
static char __pyx_k_VecF3_s[] = "VecF3(%s)";
static char __pyx_k_VecI1_s[] = "VecI1(%s)";
static char __pyx_k_VecI2_s[] = "VecI2(%s)";
static char __pyx_k_VecI3_s[] = "VecI3(%s)";
static char __pyx_k_VecV1_s[] = "VecV1(%s)";
static char __pyx_k_VecV2_s[] = "VecV2(%s)";
static char __pyx_k_VecV3_s[] = "VecV3(%s)";
static char __pyx_k_dotSelf[] = "dotSelf";
static char __pyx_k_float32[] = "float32";
static char __pyx_k_float64[] = "float64";
static char __pyx_k_fortran[] = "fortran";
static char __pyx_k_idx_ptr[] = "idx_ptr";
static char __pyx_k_indices[] = "indices";
static char __pyx_k_jaccard[] = "jaccard";
static char __pyx_k_memview[] = "memview";
static char __pyx_k_min_sum[] = "min_sum";
static char __pyx_k_mmapCSR[] = "mmapCSR";
static char __pyx_k_norm_l1[] = "norm_l1";
static char __pyx_k_norm_l2[] = "norm_l2";
static char __pyx_k_norm_lp[] = "norm_lp";
static char __pyx_k_weights[] = "weights";
static char __pyx_k_Ellipsis[] = "Ellipsis";
static char __pyx_k_get_size[] = "get_size";
static char __pyx_k_itemsize[] = "itemsize";
static char __pyx_k_min_vals[] = "min_vals";
static char __pyx_k_readline[] = "readline";
static char __pyx_k_run_test[] = "run_test";
static char __pyx_k_tmp_mat3[] = "/tmp/mat3";
static char __pyx_k_vals_ptr[] = "vals_ptr";
static char __pyx_k_TypeError[] = "TypeError";
static char __pyx_k_add_count[] = "add_count";
static char __pyx_k_dotSparse[] = "dotSparse";
static char __pyx_k_enumerate[] = "enumerate";
static char __pyx_k_get_count[] = "get_count";
static char __pyx_k_item_iter[] = "item_iter";
static char __pyx_k_mat_0_1_d[] = "mat[0,1]==%d";
static char __pyx_k_print_csr[] = "print_csr";
static char __pyx_k_to_sparse[] = "to_sparse";
static char __pyx_k_transpose[] = "transpose";
static char __pyx_k_IndexError[] = "IndexError";
static char __pyx_k_ValueError[] = "ValueError";
static char __pyx_k_buffer_len[] = "buffer_len";
static char __pyx_k_compactify[] = "compactify";
static char __pyx_k_from_dense[] = "from_dense";
static char __pyx_k_get_maxcol[] = "get_maxcol";
static char __pyx_k_jsd_unnorm[] = "jsd_unnorm";
static char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static char __pyx_k_ACCESS_READ[] = "ACCESS_READ";
static char __pyx_k_MemoryError[] = "MemoryError";
static char __pyx_k_fromVectors[] = "fromVectors";
static char __pyx_k_get_compact[] = "get_compact";
static char __pyx_k_skew_unnorm[] = "skew_unnorm";
static char __pyx_k_wrong_tcode[] = "wrong tcode ";
static char __pyx_k_RuntimeError[] = "RuntimeError";
static char __pyx_k_transform_l1[] = "transform_l1";
static char __pyx_k_transform_ll[] = "transform_ll";
static char __pyx_k_transform_mi[] = "transform_mi";
static char __pyx_k_write_binary[] = "write_binary";
static char __pyx_k_StopIteration[] = "StopIteration";
static char __pyx_k_apply_scaling[] = "apply_scaling";
static char __pyx_k_csrFromBuffer[] = "csrFromBuffer";
static char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer";
static char __pyx_k_ensure_compact[] = "ensure_compact";
static char __pyx_k_left_marginals[] = "left_marginals";
static char __pyx_k_lurrn_sparsmat[] = "lurrn.sparsmat";
static char __pyx_k_SparseVectorD_s[] = "SparseVectorD([%s])";
static char __pyx_k_SparseVectorF_s[] = "SparseVectorF([%s])";
static char __pyx_k_SparseVectorI_s[] = "SparseVectorI([%s])";
static char __pyx_k_allocate_buffer[] = "allocate_buffer";
static char __pyx_k_apply_threshold[] = "apply_threshold";
static char __pyx_k_dtype_is_object[] = "dtype_is_object";
static char __pyx_k_get_type_counts[] = "get_type_counts";
static char __pyx_k_right_marginals[] = "right_marginals";
static char __pyx_k_strided_and_direct[] = "<strided and direct>";
static char __pyx_k_strided_and_indirect[] = "<strided and indirect>";
static char __pyx_k_contiguous_and_direct[] = "<contiguous and direct>";
static char __pyx_k_transform_mi_discount[] = "transform_mi_discount";
static char __pyx_k_MemoryView_of_r_object[] = "<MemoryView of %r object>";
static char __pyx_k_MemoryView_of_r_at_0x_x[] = "<MemoryView of %r at 0x%x>";
static char __pyx_k_contiguous_and_indirect[] = "<contiguous and indirect>";
static char __pyx_k_right_squared_marginals[] = "right_squared_marginals";
static char __pyx_k_Cannot_index_with_type_s[] = "Cannot index with type '%s'";
static char __pyx_k_getbuffer_obj_view_flags[] = "getbuffer(obj, view, flags)";
static char __pyx_k_Dimension_d_is_not_direct[] = "Dimension %d is not direct";
static char __pyx_k_Invalid_shape_in_axis_d_d[] = "Invalid shape in axis %d: %d.";
static char __pyx_k_Index_out_of_bounds_axis_d[] = "Index out of bounds (axis %d)";
static char __pyx_k_Step_may_not_be_zero_axis_d[] = "Step may not be zero (axis %d)";
static char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array";
static char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous";
static char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data.";
static char __pyx_k_strided_and_direct_or_indirect[] = "<strided and direct or indirect>";
static char __pyx_k_home_yannick_proj_lurrn_pyx_src[] = "/home/yannick/proj/lurrn/pyx_src/lurrn/sparsmat.pyx";
static char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)";
static char __pyx_k_All_dimensions_preceding_dimensi[] = "All dimensions preceding dimension %d must be indexed and not sliced";
static char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides";
static char __pyx_k_Can_only_create_a_buffer_that_is[] = "Can only create a buffer that is contiguous in memory.";
static char __pyx_k_Cannot_transpose_memoryview_with[] = "Cannot transpose memoryview with indirect dimensions";
static char __pyx_k_Empty_shape_tuple_for_cython_arr[] = "Empty shape tuple for cython.array";
static char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd";
static char __pyx_k_Indirect_dimensions_not_supporte[] = "Indirect dimensions not supported";
static char __pyx_k_Invalid_mode_expected_c_or_fortr[] = "Invalid mode, expected 'c' or 'fortran', got %s";
static char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported";
static char __pyx_k_Out_of_bounds_on_buffer_access_a[] = "Out of bounds on buffer access (axis %d)";
static char __pyx_k_Unable_to_convert_item_to_object[] = "Unable to convert item to object";
static char __pyx_k_got_differing_extents_in_dimensi[] = "got differing extents in dimension %d (got %d and %d)";
static char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous";
static char __pyx_k_unable_to_allocate_shape_and_str[] = "unable to allocate shape and strides.";
static char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short.";
static PyObject *__pyx_n_s_ACCESS_READ;
static PyObject *__pyx_kp_s_Buffer_view_does_not_expose_stri;
static PyObject *__pyx_kp_s_Can_only_create_a_buffer_that_is;
static PyObject *__pyx_kp_s_Cannot_index_with_type_s;
static PyObject *__pyx_n_s_D1;
static PyObject *__pyx_kp_s_D1_d;
static PyObject *__pyx_n_s_D2;
static PyObject *__pyx_kp_s_D2_d;
static PyObject *__pyx_n_s_D3;
static PyObject *__pyx_kp_s_D3_d;
static PyObject *__pyx_n_s_Ellipsis;
static PyObject *__pyx_kp_s_Empty_shape_tuple_for_cython_arr;
static PyObject *__pyx_n_s_F1;
static PyObject *__pyx_kp_s_F1_d;
static PyObject *__pyx_n_s_F2;
static PyObject *__pyx_kp_s_F2_d;
static PyObject *__pyx_n_s_F3;
static PyObject *__pyx_kp_s_F3_d;
static PyObject *__pyx_kp_u_Format_string_allocated_too_shor;
static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2;
static PyObject *__pyx_n_s_I1;
static PyObject *__pyx_kp_s_I1_d;
static PyObject *__pyx_n_s_I2;
static PyObject *__pyx_kp_s_I2_d;
static PyObject *__pyx_n_s_I3;
static PyObject *__pyx_kp_s_I3_d;
static PyObject *__pyx_n_s_IndexError;
static PyObject *__pyx_kp_s_Indirect_dimensions_not_supporte;
static PyObject *__pyx_kp_s_Invalid_mode_expected_c_or_fortr;
static PyObject *__pyx_kp_s_Invalid_shape_in_axis_d_d;
static PyObject *__pyx_n_s_MemoryError;
static PyObject *__pyx_kp_s_MemoryView_of_r_at_0x_x;
static PyObject *__pyx_kp_s_MemoryView_of_r_object;
static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor;
static PyObject *__pyx_n_b_O;
static PyObject *__pyx_kp_s_Out_of_bounds_on_buffer_access_a;
static PyObject *__pyx_n_s_RuntimeError;
static PyObject *__pyx_kp_s_SparseVectorD_s;
static PyObject *__pyx_kp_s_SparseVectorF_s;
static PyObject *__pyx_kp_s_SparseVectorI_s;
static PyObject *__pyx_n_s_StopIteration;
static PyObject *__pyx_n_s_TypeError;
static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object;
static PyObject *__pyx_n_s_V1;
static PyObject *__pyx_kp_s_V1_d;
static PyObject *__pyx_n_s_V2;
static PyObject *__pyx_kp_s_V2_d;
static PyObject *__pyx_n_s_V3;
static PyObject *__pyx_kp_s_V3_d;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_kp_s_VecD1_s;
static PyObject *__pyx_kp_s_VecD2_s;
static PyObject *__pyx_kp_s_VecD3_s;
static PyObject *__pyx_kp_s_VecF1_s;
static PyObject *__pyx_kp_s_VecF2_s;
static PyObject *__pyx_kp_s_VecF3_s;
static PyObject *__pyx_kp_s_VecI1_s;
static PyObject *__pyx_kp_s_VecI2_s;
static PyObject *__pyx_kp_s_VecI3_s;
static PyObject *__pyx_kp_s_VecV1_s;
static PyObject *__pyx_kp_s_VecV2_s;
static PyObject *__pyx_kp_s_VecV3_s;
static PyObject *__pyx_kp_s__24;
static PyObject *__pyx_kp_s__25;
static PyObject *__pyx_kp_s__94;
static PyObject *__pyx_n_s_a;
static PyObject *__pyx_n_s_access;
static PyObject *__pyx_n_s_add;
static PyObject *__pyx_n_s_add_count;
static PyObject *__pyx_n_s_allocate_buffer;
static PyObject *__pyx_n_s_alpha;
static PyObject *__pyx_n_s_append;
static PyObject *__pyx_n_s_apply_scaling;
static PyObject *__pyx_n_s_apply_threshold;
static PyObject *__pyx_n_s_astype;
static PyObject *__pyx_n_s_at;
static PyObject *__pyx_n_s_b;
static PyObject *__pyx_n_s_base;
static PyObject *__pyx_n_s_buf;
static PyObject *__pyx_n_s_buffer;
static PyObject *__pyx_n_s_buffer_len;
static PyObject *__pyx_n_s_c;
static PyObject *__pyx_n_u_c;
static PyObject *__pyx_n_s_c_matD;
static PyObject *__pyx_n_s_c_matF;
static PyObject *__pyx_n_s_c_matI;
static PyObject *__pyx_n_s_class;
static PyObject *__pyx_n_s_clear;
static PyObject *__pyx_n_s_compactify;
static PyObject *__pyx_kp_s_contiguous_and_direct;
static PyObject *__pyx_kp_s_contiguous_and_indirect;
static PyObject *__pyx_n_s_cosine;
static PyObject *__pyx_n_s_counts;
static PyObject *__pyx_n_s_csrFromBuffer;
static PyObject *__pyx_n_s_cumsum;
static PyObject *__pyx_kp_s_d_s;
static PyObject *__pyx_kp_s_d_s_s;
static PyObject *__pyx_n_s_delim;
static PyObject *__pyx_n_s_dotSelf;
static PyObject *__pyx_n_s_dotSparse;
static PyObject *__pyx_n_s_dtype_is_object;
static PyObject *__pyx_n_s_empty;
static PyObject *__pyx_n_s_end;
static PyObject *__pyx_n_s_ensure_compact;
static PyObject *__pyx_n_s_enumerate;
static PyObject *__pyx_n_s_error;
static PyObject *__pyx_n_s_extend;
static PyObject *__pyx_n_s_f;
static PyObject *__pyx_n_s_file;
static PyObject *__pyx_n_s_fileno;
static PyObject *__pyx_n_s_filt;
static PyObject *__pyx_n_s_flags;
static PyObject *__pyx_n_s_flen;
static PyObject *__pyx_n_s_float32;
static PyObject *__pyx_n_s_float64;
static PyObject *__pyx_n_s_format;
static PyObject *__pyx_n_s_fortran;
static PyObject *__pyx_n_u_fortran;
static PyObject *__pyx_n_s_fromVectors;
static PyObject *__pyx_n_s_from_dense;
static PyObject *__pyx_n_s_get_compact;
static PyObject *__pyx_n_s_get_count;
static PyObject *__pyx_n_s_get_maxcol;
static PyObject *__pyx_n_s_get_size;
static PyObject *__pyx_n_s_get_type_counts;
static PyObject *__pyx_kp_s_got_differing_extents_in_dimensi;
static PyObject *__pyx_kp_s_home_yannick_proj_lurrn_pyx_src;
static PyObject *__pyx_n_s_id;
static PyObject *__pyx_n_s_idx_ptr;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_indices;
static PyObject *__pyx_n_s_int32;
static PyObject *__pyx_n_s_item;
static PyObject *__pyx_n_s_item_iter;
static PyObject *__pyx_n_s_itemsize;
static PyObject *__pyx_kp_s_itemsize_0_for_cython_array;
static PyObject *__pyx_n_s_jaccard;
static PyObject *__pyx_n_s_join;
static PyObject *__pyx_n_s_jsd_unnorm;
static PyObject *__pyx_n_s_k;
static PyObject *__pyx_n_s_k0;
static PyObject *__pyx_n_s_k1;
static PyObject *__pyx_n_s_k2;
static PyObject *__pyx_n_s_left_marginals;
static PyObject *__pyx_n_s_lurrn_sparsmat;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_mat;
static PyObject *__pyx_n_s_mat2;
static PyObject *__pyx_n_s_mat3;
static PyObject *__pyx_n_s_mat4;
static PyObject *__pyx_n_s_mat5;
static PyObject *__pyx_n_s_mat6;
static PyObject *__pyx_n_s_matD;
static PyObject *__pyx_n_s_matF;
static PyObject *__pyx_n_s_matI;
static PyObject *__pyx_kp_s_mat_0_1_d;
static PyObject *__pyx_n_s_memview;
static PyObject *__pyx_n_s_min_sum;
static PyObject *__pyx_n_s_min_vals;
static PyObject *__pyx_n_s_mmap;
static PyObject *__pyx_n_s_mmapCSR;
static PyObject *__pyx_n_s_mode;
static PyObject *__pyx_n_s_my_len;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_s_name_2;
static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous;
static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou;
static PyObject *__pyx_n_s_ndim;
static PyObject *__pyx_n_s_norm_l1;
static PyObject *__pyx_n_s_norm_l2;
static PyObject *__pyx_n_s_norm_lp;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_n_s_obj;
static PyObject *__pyx_n_s_other;
static PyObject *__pyx_n_s_pack;
static PyObject *__pyx_n_s_pairs;
static PyObject *__pyx_n_s_print;
static PyObject *__pyx_n_s_print_csr;
static PyObject *__pyx_n_s_pyx_getbuffer;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_read;
static PyObject *__pyx_n_s_readline;
static PyObject *__pyx_n_s_remap;
static PyObject *__pyx_n_s_result;
static PyObject *__pyx_n_s_right_marginals;
static PyObject *__pyx_n_s_right_squared_marginals;
static PyObject *__pyx_n_s_run_test;
static PyObject *__pyx_n_s_seek;
static PyObject *__pyx_n_s_shape;
static PyObject *__pyx_n_s_size;
static PyObject *__pyx_n_s_skew_unnorm;
static PyObject *__pyx_n_s_sort;
static PyObject *__pyx_n_s_split;
static PyObject *__pyx_n_s_sqdist;
static PyObject *__pyx_n_s_sqrt;
static PyObject *__pyx_n_s_start;
static PyObject *__pyx_n_s_step;
static PyObject *__pyx_n_s_stop;
static PyObject *__pyx_kp_s_strided_and_direct;
static PyObject *__pyx_kp_s_strided_and_direct_or_indirect;
static PyObject *__pyx_kp_s_strided_and_indirect;
static PyObject *__pyx_n_s_strip;
static PyObject *__pyx_n_s_struct;
static PyObject *__pyx_n_s_sum;
static PyObject *__pyx_n_s_sv;
static PyObject *__pyx_n_s_sys;
static PyObject *__pyx_n_s_tcode;
static PyObject *__pyx_n_s_tell;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_tmp;
static PyObject *__pyx_kp_s_tmp_mat3;
static PyObject *__pyx_n_s_to_csr;
static PyObject *__pyx_n_s_to_sparse;
static PyObject *__pyx_n_s_to_vec;
static PyObject *__pyx_n_s_transform_l1;
static PyObject *__pyx_n_s_transform_ll;
static PyObject *__pyx_n_s_transform_mi;
static PyObject *__pyx_n_s_transform_mi_discount;
static PyObject *__pyx_n_s_transpose;
static PyObject *__pyx_kp_s_unable_to_allocate_array_data;
static PyObject *__pyx_kp_s_unable_to_allocate_shape_and_str;
static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd;
static PyObject *__pyx_n_s_unpack;
static PyObject *__pyx_n_s_vals_ptr;
static PyObject *__pyx_n_s_vec;
static PyObject *__pyx_n_s_vecs;
static PyObject *__pyx_n_s_w;
static PyObject *__pyx_n_s_weight;
static PyObject *__pyx_n_s_weights;
static PyObject *__pyx_n_s_write;
static PyObject *__pyx_n_s_write_binary;
static PyObject *__pyx_kp_s_wrong_tcode;
static PyObject *__pyx_n_s_x;
static PyObject *__pyx_n_s_xrange;
static PyObject *__pyx_n_s_xs;
static PyObject *__pyx_n_s_zeros;
static PyObject *__pyx_float_0_5;
static PyObject *__pyx_float_0_6;
static PyObject *__pyx_float_1_0;
static PyObject *__pyx_float_2_0;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_256;
static PyObject *__pyx_int_100000;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_int_neg_2;
static PyObject *__pyx_tuple_;
static PyObject *__pyx_slice__5;
static PyObject *__pyx_slice__7;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__3;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__8;
static PyObject *__pyx_tuple__9;
static PyObject *__pyx_slice__12;
static PyObject *__pyx_slice__14;
static PyObject *__pyx_slice__19;
static PyObject *__pyx_slice__21;
static PyObject *__pyx_slice__30;
static PyObject *__pyx_slice__32;
static PyObject *__pyx_slice__37;
static PyObject *__pyx_slice__39;
static PyObject *__pyx_slice__44;
static PyObject *__pyx_slice__46;
static PyObject *__pyx_slice__53;
static PyObject *__pyx_slice__55;
static PyObject *__pyx_slice__60;
static PyObject *__pyx_slice__62;
static PyObject *__pyx_slice__67;
static PyObject *__pyx_slice__69;
static PyObject *__pyx_slice__75;
static PyObject *__pyx_slice__77;
static PyObject *__pyx_slice__82;
static PyObject *__pyx_slice__84;
static PyObject *__pyx_slice__89;
static PyObject *__pyx_slice__91;
static PyObject *__pyx_tuple__10;
static PyObject *__pyx_tuple__11;
static PyObject *__pyx_tuple__13;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__22;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__27;
static PyObject *__pyx_tuple__28;
static PyObject *__pyx_tuple__29;
static PyObject *__pyx_tuple__31;
static PyObject *__pyx_tuple__33;
static PyObject *__pyx_tuple__34;
static PyObject *__pyx_tuple__35;
static PyObject *__pyx_tuple__36;
static PyObject *__pyx_tuple__38;
static PyObject *__pyx_tuple__40;
static PyObject *__pyx_tuple__41;
static PyObject *__pyx_tuple__42;
static PyObject *__pyx_tuple__43;
static PyObject *__pyx_tuple__45;
static PyObject *__pyx_tuple__47;
static PyObject *__pyx_tuple__48;
static PyObject *__pyx_tuple__49;
static PyObject *__pyx_tuple__50;
static PyObject *__pyx_tuple__51;
static PyObject *__pyx_tuple__52;
static PyObject *__pyx_tuple__54;
static PyObject *__pyx_tuple__56;
static PyObject *__pyx_tuple__57;
static PyObject *__pyx_tuple__58;
static PyObject *__pyx_tuple__59;
static PyObject *__pyx_tuple__61;
static PyObject *__pyx_tuple__63;
static PyObject *__pyx_tuple__64;
static PyObject *__pyx_tuple__65;
static PyObject *__pyx_tuple__66;
static PyObject *__pyx_tuple__68;
static PyObject *__pyx_tuple__70;
static PyObject *__pyx_tuple__71;
static PyObject *__pyx_tuple__72;
static PyObject *__pyx_tuple__73;
static PyObject *__pyx_tuple__74;
static PyObject *__pyx_tuple__76;
static PyObject *__pyx_tuple__78;
static PyObject *__pyx_tuple__79;
static PyObject *__pyx_tuple__80;
static PyObject *__pyx_tuple__81;
static PyObject *__pyx_tuple__83;
static PyObject *__pyx_tuple__85;
static PyObject *__pyx_tuple__86;
static PyObject *__pyx_tuple__87;
static PyObject *__pyx_tuple__88;
static PyObject *__pyx_tuple__90;
static PyObject *__pyx_tuple__92;
static PyObject *__pyx_tuple__93;
static PyObject *__pyx_tuple__95;
static PyObject *__pyx_tuple__96;
static PyObject *__pyx_tuple__97;
static PyObject *__pyx_tuple__98;
static PyObject *__pyx_tuple__99;
static PyObject *__pyx_slice__110;
static PyObject *__pyx_slice__111;
static PyObject *__pyx_slice__112;
static PyObject *__pyx_tuple__100;
static PyObject *__pyx_tuple__101;
static PyObject *__pyx_tuple__102;
static PyObject *__pyx_tuple__103;
static PyObject *__pyx_tuple__104;
static PyObject *__pyx_tuple__105;
static PyObject *__pyx_tuple__106;
static PyObject *__pyx_tuple__107;
static PyObject *__pyx_tuple__108;
static PyObject *__pyx_tuple__109;
static PyObject *__pyx_tuple__113;
static PyObject *__pyx_tuple__114;
static PyObject *__pyx_tuple__116;
static PyObject *__pyx_tuple__118;
static PyObject *__pyx_tuple__120;
static PyObject *__pyx_tuple__121;
static PyObject *__pyx_tuple__122;
static PyObject *__pyx_tuple__123;
static PyObject *__pyx_tuple__124;
static PyObject *__pyx_codeobj__115;
static PyObject *__pyx_codeobj__117;
static PyObject *__pyx_codeobj__119;

/* "lurrn/sparsmat.pyx":10
 * DEF CHUNK_SIZE = 256
 * 
 * cdef double logB(double n, double p, double k):             # <<<<<<<<<<<<<<
 *     cdef double lp, lq
 *     if p==0.0 or p==1.0:
 */

static double __pyx_f_5lurrn_8sparsmat_logB(double __pyx_v_n, double __pyx_v_p, double __pyx_v_k) {
  double __pyx_v_lp;
  double __pyx_v_lq;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("logB", 0);

  /* "lurrn/sparsmat.pyx":12
 * cdef double logB(double n, double p, double k):
 *     cdef double lp, lq
 *     if p==0.0 or p==1.0:             # <<<<<<<<<<<<<<
 *         return 0.0
 *     else:
 */
  __pyx_t_2 = ((__pyx_v_p == 0.0) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_p == 1.0) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":13
 *     cdef double lp, lq
 *     if p==0.0 or p==1.0:
 *         return 0.0             # <<<<<<<<<<<<<<
 *     else:
 *         lp=log(p)
 */
    __pyx_r = 0.0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":15
 *         return 0.0
 *     else:
 *         lp=log(p)             # <<<<<<<<<<<<<<
 *         lq=log1p(-p)
 *     return k*lp+(n-k)*lq
 */
    __pyx_v_lp = log(__pyx_v_p);

    /* "lurrn/sparsmat.pyx":16
 *     else:
 *         lp=log(p)
 *         lq=log1p(-p)             # <<<<<<<<<<<<<<
 *     return k*lp+(n-k)*lq
 * 
 */
    __pyx_v_lq = log1p((-__pyx_v_p));
  }

  /* "lurrn/sparsmat.pyx":17
 *         lp=log(p)
 *         lq=log1p(-p)
 *     return k*lp+(n-k)*lq             # <<<<<<<<<<<<<<
 * 
 * ## I -> int, int32
 */
  __pyx_r = ((__pyx_v_k * __pyx_v_lp) + ((__pyx_v_n - __pyx_v_k) * __pyx_v_lq));
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":10
 * DEF CHUNK_SIZE = 256
 * 
 * cdef double logB(double n, double p, double k):             # <<<<<<<<<<<<<<
 *     cdef double lp, lq
 *     if p==0.0 or p==1.0:
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":27
 * 
 * cdef class CSRMatrixI:
 *     def __cinit__(self, vecs=None):             # <<<<<<<<<<<<<<
 *         self.mat=NULL
 *         self.cache_maxcol=-1
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_vecs = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_vecs,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vecs);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_vecs = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI___cinit__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self), __pyx_v_vecs);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI___cinit__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_vecs) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "lurrn/sparsmat.pyx":28
 * cdef class CSRMatrixI:
 *     def __cinit__(self, vecs=None):
 *         self.mat=NULL             # <<<<<<<<<<<<<<
 *         self.cache_maxcol=-1
 *         if vecs is not None:
 */
  __pyx_v_self->mat = NULL;

  /* "lurrn/sparsmat.pyx":29
 *     def __cinit__(self, vecs=None):
 *         self.mat=NULL
 *         self.cache_maxcol=-1             # <<<<<<<<<<<<<<
 *         if vecs is not None:
 *             self.fromVectors(vecs)
 */
  __pyx_v_self->cache_maxcol = -1;

  /* "lurrn/sparsmat.pyx":30
 *         self.mat=NULL
 *         self.cache_maxcol=-1
 *         if vecs is not None:             # <<<<<<<<<<<<<<
 *             self.fromVectors(vecs)
 *     cdef void set_matrix(self,c_CSRMatrixI *mat_new):
 */
  __pyx_t_1 = (__pyx_v_vecs != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lurrn/sparsmat.pyx":31
 *         self.cache_maxcol=-1
 *         if vecs is not None:
 *             self.fromVectors(vecs)             # <<<<<<<<<<<<<<
 *     cdef void set_matrix(self,c_CSRMatrixI *mat_new):
 *         self.mat=mat_new
 */
    __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self->__pyx_vtab)->fromVectors(__pyx_v_self, __pyx_v_vecs, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":27
 * 
 * cdef class CSRMatrixI:
 *     def __cinit__(self, vecs=None):             # <<<<<<<<<<<<<<
 *         self.mat=NULL
 *         self.cache_maxcol=-1
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":32
 *         if vecs is not None:
 *             self.fromVectors(vecs)
 *     cdef void set_matrix(self,c_CSRMatrixI *mat_new):             # <<<<<<<<<<<<<<
 *         self.mat=mat_new
 *         self.cache_maxcol=-1
 */

static void __pyx_f_5lurrn_8sparsmat_10CSRMatrixI_set_matrix(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, struct CSRMatrix<int> *__pyx_v_mat_new) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_matrix", 0);

  /* "lurrn/sparsmat.pyx":33
 *             self.fromVectors(vecs)
 *     cdef void set_matrix(self,c_CSRMatrixI *mat_new):
 *         self.mat=mat_new             # <<<<<<<<<<<<<<
 *         self.cache_maxcol=-1
 *     cpdef CSRMatrixI fromVectors(self, vectors):
 */
  __pyx_v_self->mat = __pyx_v_mat_new;

  /* "lurrn/sparsmat.pyx":34
 *     cdef void set_matrix(self,c_CSRMatrixI *mat_new):
 *         self.mat=mat_new
 *         self.cache_maxcol=-1             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixI fromVectors(self, vectors):
 *         cdef int spaceNeeded=0
 */
  __pyx_v_self->cache_maxcol = -1;

  /* "lurrn/sparsmat.pyx":32
 *         if vecs is not None:
 *             self.fromVectors(vecs)
 *     cdef void set_matrix(self,c_CSRMatrixI *mat_new):             # <<<<<<<<<<<<<<
 *         self.mat=mat_new
 *         self.cache_maxcol=-1
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":35
 *         self.mat=mat_new
 *         self.cache_maxcol=-1
 *     cpdef CSRMatrixI fromVectors(self, vectors):             # <<<<<<<<<<<<<<
 *         cdef int spaceNeeded=0
 *         cdef int i=0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_3fromVectors(PyObject *__pyx_v_self, PyObject *__pyx_v_vectors); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_fromVectors(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_vectors, int __pyx_skip_dispatch) {
  int __pyx_v_spaceNeeded;
  int __pyx_v_i;
  int __pyx_v_j;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_vec = 0;
  struct CSRMatrix<int> *__pyx_v_c_result;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  unsigned int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromVectors", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_fromVectors); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_3fromVectors)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_vectors); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(__pyx_v_vectors);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_vectors);
        __Pyx_GIVEREF(__pyx_v_vectors);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":36
 *         self.cache_maxcol=-1
 *     cpdef CSRMatrixI fromVectors(self, vectors):
 *         cdef int spaceNeeded=0             # <<<<<<<<<<<<<<
 *         cdef int i=0
 *         cdef int j=0
 */
  __pyx_v_spaceNeeded = 0;

  /* "lurrn/sparsmat.pyx":37
 *     cpdef CSRMatrixI fromVectors(self, vectors):
 *         cdef int spaceNeeded=0
 *         cdef int i=0             # <<<<<<<<<<<<<<
 *         cdef int j=0
 *         cdef SparseVectorI vec
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":38
 *         cdef int spaceNeeded=0
 *         cdef int i=0
 *         cdef int j=0             # <<<<<<<<<<<<<<
 *         cdef SparseVectorI vec
 *         cdef c_CSRMatrixI *c_result
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":42
 *         cdef c_CSRMatrixI *c_result
 *         cdef CSRMatrixI result
 *         for vec in vectors:             # <<<<<<<<<<<<<<
 *             spaceNeeded+=vec.my_len
 *             i+=1
 */
  if (likely(PyList_CheckExact(__pyx_v_vectors)) || PyTuple_CheckExact(__pyx_v_vectors)) {
    __pyx_t_1 = __pyx_v_vectors; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_vectors); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_SparseVectorI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":43
 *         cdef CSRMatrixI result
 *         for vec in vectors:
 *             spaceNeeded+=vec.my_len             # <<<<<<<<<<<<<<
 *             i+=1
 *         c_result=new_csrI(i,spaceNeeded)
 */
    __pyx_v_spaceNeeded = (__pyx_v_spaceNeeded + __pyx_v_vec->my_len);

    /* "lurrn/sparsmat.pyx":44
 *         for vec in vectors:
 *             spaceNeeded+=vec.my_len
 *             i+=1             # <<<<<<<<<<<<<<
 *         c_result=new_csrI(i,spaceNeeded)
 *         i=0
 */
    __pyx_v_i = (__pyx_v_i + 1);

    /* "lurrn/sparsmat.pyx":42
 *         cdef c_CSRMatrixI *c_result
 *         cdef CSRMatrixI result
 *         for vec in vectors:             # <<<<<<<<<<<<<<
 *             spaceNeeded+=vec.my_len
 *             i+=1
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":45
 *             spaceNeeded+=vec.my_len
 *             i+=1
 *         c_result=new_csrI(i,spaceNeeded)             # <<<<<<<<<<<<<<
 *         i=0
 *         spaceNeeded=0
 */
  __pyx_v_c_result = new_csr<int>(__pyx_v_i, __pyx_v_spaceNeeded);

  /* "lurrn/sparsmat.pyx":46
 *             i+=1
 *         c_result=new_csrI(i,spaceNeeded)
 *         i=0             # <<<<<<<<<<<<<<
 *         spaceNeeded=0
 *         for vec in vectors:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":47
 *         c_result=new_csrI(i,spaceNeeded)
 *         i=0
 *         spaceNeeded=0             # <<<<<<<<<<<<<<
 *         for vec in vectors:
 *             c_result.offsets[i]=spaceNeeded
 */
  __pyx_v_spaceNeeded = 0;

  /* "lurrn/sparsmat.pyx":48
 *         i=0
 *         spaceNeeded=0
 *         for vec in vectors:             # <<<<<<<<<<<<<<
 *             c_result.offsets[i]=spaceNeeded
 *             for j from 0<=j<vec.my_len:
 */
  if (likely(PyList_CheckExact(__pyx_v_vectors)) || PyTuple_CheckExact(__pyx_v_vectors)) {
    __pyx_t_1 = __pyx_v_vectors; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_vectors); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_SparseVectorI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":49
 *         spaceNeeded=0
 *         for vec in vectors:
 *             c_result.offsets[i]=spaceNeeded             # <<<<<<<<<<<<<<
 *             for j from 0<=j<vec.my_len:
 *                  c_result.rightColumns[spaceNeeded]=vec.idx_ptr[j]
 */
    (__pyx_v_c_result->offsets[__pyx_v_i]) = __pyx_v_spaceNeeded;

    /* "lurrn/sparsmat.pyx":50
 *         for vec in vectors:
 *             c_result.offsets[i]=spaceNeeded
 *             for j from 0<=j<vec.my_len:             # <<<<<<<<<<<<<<
 *                  c_result.rightColumns[spaceNeeded]=vec.idx_ptr[j]
 *                  c_result.values[spaceNeeded]=vec.vals_ptr[j]
 */
    __pyx_t_8 = __pyx_v_vec->my_len;
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_8; __pyx_v_j++) {

      /* "lurrn/sparsmat.pyx":51
 *             c_result.offsets[i]=spaceNeeded
 *             for j from 0<=j<vec.my_len:
 *                  c_result.rightColumns[spaceNeeded]=vec.idx_ptr[j]             # <<<<<<<<<<<<<<
 *                  c_result.values[spaceNeeded]=vec.vals_ptr[j]
 *                  spaceNeeded+=1
 */
      (__pyx_v_c_result->rightColumns[__pyx_v_spaceNeeded]) = (__pyx_v_vec->idx_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":52
 *             for j from 0<=j<vec.my_len:
 *                  c_result.rightColumns[spaceNeeded]=vec.idx_ptr[j]
 *                  c_result.values[spaceNeeded]=vec.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                  spaceNeeded+=1
 *             i+=1
 */
      (__pyx_v_c_result->values[__pyx_v_spaceNeeded]) = (__pyx_v_vec->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":53
 *                  c_result.rightColumns[spaceNeeded]=vec.idx_ptr[j]
 *                  c_result.values[spaceNeeded]=vec.vals_ptr[j]
 *                  spaceNeeded+=1             # <<<<<<<<<<<<<<
 *             i+=1
 *         c_result.offsets[i]=spaceNeeded
 */
      __pyx_v_spaceNeeded = (__pyx_v_spaceNeeded + 1);
    }

    /* "lurrn/sparsmat.pyx":54
 *                  c_result.values[spaceNeeded]=vec.vals_ptr[j]
 *                  spaceNeeded+=1
 *             i+=1             # <<<<<<<<<<<<<<
 *         c_result.offsets[i]=spaceNeeded
 *         self.set_matrix(c_result)
 */
    __pyx_v_i = (__pyx_v_i + 1);

    /* "lurrn/sparsmat.pyx":48
 *         i=0
 *         spaceNeeded=0
 *         for vec in vectors:             # <<<<<<<<<<<<<<
 *             c_result.offsets[i]=spaceNeeded
 *             for j from 0<=j<vec.my_len:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":55
 *                  spaceNeeded+=1
 *             i+=1
 *         c_result.offsets[i]=spaceNeeded             # <<<<<<<<<<<<<<
 *         self.set_matrix(c_result)
 *         return self
 */
  (__pyx_v_c_result->offsets[__pyx_v_i]) = __pyx_v_spaceNeeded;

  /* "lurrn/sparsmat.pyx":56
 *             i+=1
 *         c_result.offsets[i]=spaceNeeded
 *         self.set_matrix(c_result)             # <<<<<<<<<<<<<<
 *         return self
 *     def __lshift__(CSRMatrixI self,int k):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self->__pyx_vtab)->set_matrix(__pyx_v_self, __pyx_v_c_result);

  /* "lurrn/sparsmat.pyx":57
 *         c_result.offsets[i]=spaceNeeded
 *         self.set_matrix(c_result)
 *         return self             # <<<<<<<<<<<<<<
 *     def __lshift__(CSRMatrixI self,int k):
 *         cdef CSRMatrixI result
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":35
 *         self.mat=mat_new
 *         self.cache_maxcol=-1
 *     cpdef CSRMatrixI fromVectors(self, vectors):             # <<<<<<<<<<<<<<
 *         cdef int spaceNeeded=0
 *         cdef int i=0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.fromVectors", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_vec);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_3fromVectors(PyObject *__pyx_v_self, PyObject *__pyx_v_vectors); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_3fromVectors(PyObject *__pyx_v_self, PyObject *__pyx_v_vectors) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fromVectors (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_2fromVectors(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self), ((PyObject *)__pyx_v_vectors));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_2fromVectors(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_vectors) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromVectors", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_fromVectors(__pyx_v_self, __pyx_v_vectors, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.fromVectors", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":58
 *         self.set_matrix(c_result)
 *         return self
 *     def __lshift__(CSRMatrixI self,int k):             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixI result
 *         cdef c_CSRMatrixI *c_mat
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_5__lshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_5__lshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__lshift__ (wrapper)", 0);
  assert(__pyx_arg_k); {
    __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.__lshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_CSRMatrixI, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_4__lshift__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self), ((int)__pyx_v_k));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_4__lshift__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, int __pyx_v_k) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_result = 0;
  struct CSRMatrix<int> *__pyx_v_c_mat;
  struct CSRMatrix<int> *__pyx_v_c_result;
  int __pyx_v_i;
  int __pyx_v_nnz;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct CSRMatrix<int> *__pyx_t_1;
  coordinate_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__lshift__", 0);

  /* "lurrn/sparsmat.pyx":63
 *         cdef c_CSRMatrixI *c_result
 *         cdef int i, nnz
 *         c_mat=self.mat             # <<<<<<<<<<<<<<
 *         nnz=c_mat.offsets[c_mat.num_rows]
 *         c_result=new_csrI(c_mat.num_rows, nnz)
 */
  __pyx_t_1 = __pyx_v_self->mat;
  __pyx_v_c_mat = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":64
 *         cdef int i, nnz
 *         c_mat=self.mat
 *         nnz=c_mat.offsets[c_mat.num_rows]             # <<<<<<<<<<<<<<
 *         c_result=new_csrI(c_mat.num_rows, nnz)
 *         for i from 0<=i<=c_mat.num_rows:
 */
  __pyx_v_nnz = (__pyx_v_c_mat->offsets[__pyx_v_c_mat->num_rows]);

  /* "lurrn/sparsmat.pyx":65
 *         c_mat=self.mat
 *         nnz=c_mat.offsets[c_mat.num_rows]
 *         c_result=new_csrI(c_mat.num_rows, nnz)             # <<<<<<<<<<<<<<
 *         for i from 0<=i<=c_mat.num_rows:
 *             c_result.offsets[i]=c_mat.offsets[i]
 */
  __pyx_v_c_result = new_csr<int>(__pyx_v_c_mat->num_rows, __pyx_v_nnz);

  /* "lurrn/sparsmat.pyx":66
 *         nnz=c_mat.offsets[c_mat.num_rows]
 *         c_result=new_csrI(c_mat.num_rows, nnz)
 *         for i from 0<=i<=c_mat.num_rows:             # <<<<<<<<<<<<<<
 *             c_result.offsets[i]=c_mat.offsets[i]
 *         for i from 0<=i<nnz:
 */
  __pyx_t_2 = __pyx_v_c_mat->num_rows;
  for (__pyx_v_i = 0; __pyx_v_i <= __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":67
 *         c_result=new_csrI(c_mat.num_rows, nnz)
 *         for i from 0<=i<=c_mat.num_rows:
 *             c_result.offsets[i]=c_mat.offsets[i]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<nnz:
 *             c_result.rightColumns[i]=c_mat.rightColumns[i]+k
 */
    (__pyx_v_c_result->offsets[__pyx_v_i]) = (__pyx_v_c_mat->offsets[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":68
 *         for i from 0<=i<=c_mat.num_rows:
 *             c_result.offsets[i]=c_mat.offsets[i]
 *         for i from 0<=i<nnz:             # <<<<<<<<<<<<<<
 *             c_result.rightColumns[i]=c_mat.rightColumns[i]+k
 *         for i from 0<=i<nnz:
 */
  __pyx_t_3 = __pyx_v_nnz;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":69
 *             c_result.offsets[i]=c_mat.offsets[i]
 *         for i from 0<=i<nnz:
 *             c_result.rightColumns[i]=c_mat.rightColumns[i]+k             # <<<<<<<<<<<<<<
 *         for i from 0<=i<nnz:
 *             c_result.values[i]=c_mat.values[i]
 */
    (__pyx_v_c_result->rightColumns[__pyx_v_i]) = ((__pyx_v_c_mat->rightColumns[__pyx_v_i]) + __pyx_v_k);
  }

  /* "lurrn/sparsmat.pyx":70
 *         for i from 0<=i<nnz:
 *             c_result.rightColumns[i]=c_mat.rightColumns[i]+k
 *         for i from 0<=i<nnz:             # <<<<<<<<<<<<<<
 *             c_result.values[i]=c_mat.values[i]
 *         result=CSRMatrixI()
 */
  __pyx_t_3 = __pyx_v_nnz;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":71
 *             c_result.rightColumns[i]=c_mat.rightColumns[i]+k
 *         for i from 0<=i<nnz:
 *             c_result.values[i]=c_mat.values[i]             # <<<<<<<<<<<<<<
 *         result=CSRMatrixI()
 *         result.set_matrix(c_result)
 */
    (__pyx_v_c_result->values[__pyx_v_i]) = (__pyx_v_c_mat->values[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":72
 *         for i from 0<=i<nnz:
 *             c_result.values[i]=c_mat.values[i]
 *         result=CSRMatrixI()             # <<<<<<<<<<<<<<
 *         result.set_matrix(c_result)
 *         return result
 */
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixI)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "lurrn/sparsmat.pyx":73
 *             c_result.values[i]=c_mat.values[i]
 *         result=CSRMatrixI()
 *         result.set_matrix(c_result)             # <<<<<<<<<<<<<<
 *         return result
 *     def __ilshift__(CSRMatrixI self, int k):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_result->__pyx_vtab)->set_matrix(__pyx_v_result, __pyx_v_c_result);

  /* "lurrn/sparsmat.pyx":74
 *         result=CSRMatrixI()
 *         result.set_matrix(c_result)
 *         return result             # <<<<<<<<<<<<<<
 *     def __ilshift__(CSRMatrixI self, int k):
 *         cdef c_CSRMatrixI *c_mat
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":58
 *         self.set_matrix(c_result)
 *         return self
 *     def __lshift__(CSRMatrixI self,int k):             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixI result
 *         cdef c_CSRMatrixI *c_mat
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.__lshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":75
 *         result.set_matrix(c_result)
 *         return result
 *     def __ilshift__(CSRMatrixI self, int k):             # <<<<<<<<<<<<<<
 *         cdef c_CSRMatrixI *c_mat
 *         cdef int i, nnz
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_7__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_7__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ilshift__ (wrapper)", 0);
  assert(__pyx_arg_k); {
    __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.__ilshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_6__ilshift__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self), ((int)__pyx_v_k));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_6__ilshift__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, int __pyx_v_k) {
  struct CSRMatrix<int> *__pyx_v_c_mat;
  int __pyx_v_i;
  int __pyx_v_nnz;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct CSRMatrix<int> *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("__ilshift__", 0);

  /* "lurrn/sparsmat.pyx":78
 *         cdef c_CSRMatrixI *c_mat
 *         cdef int i, nnz
 *         c_mat=self.mat             # <<<<<<<<<<<<<<
 *         nnz=c_mat.offsets[c_mat.num_rows]
 *         for i from 0<=i<nnz:
 */
  __pyx_t_1 = __pyx_v_self->mat;
  __pyx_v_c_mat = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":79
 *         cdef int i, nnz
 *         c_mat=self.mat
 *         nnz=c_mat.offsets[c_mat.num_rows]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<nnz:
 *             c_mat.rightColumns[i]+=k
 */
  __pyx_v_nnz = (__pyx_v_c_mat->offsets[__pyx_v_c_mat->num_rows]);

  /* "lurrn/sparsmat.pyx":80
 *         c_mat=self.mat
 *         nnz=c_mat.offsets[c_mat.num_rows]
 *         for i from 0<=i<nnz:             # <<<<<<<<<<<<<<
 *             c_mat.rightColumns[i]+=k
 *         return self
 */
  __pyx_t_2 = __pyx_v_nnz;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":81
 *         nnz=c_mat.offsets[c_mat.num_rows]
 *         for i from 0<=i<nnz:
 *             c_mat.rightColumns[i]+=k             # <<<<<<<<<<<<<<
 *         return self
 *     def print_csr(self):
 */
    __pyx_t_3 = __pyx_v_i;
    (__pyx_v_c_mat->rightColumns[__pyx_t_3]) = ((__pyx_v_c_mat->rightColumns[__pyx_t_3]) + __pyx_v_k);
  }

  /* "lurrn/sparsmat.pyx":82
 *         for i from 0<=i<nnz:
 *             c_mat.rightColumns[i]+=k
 *         return self             # <<<<<<<<<<<<<<
 *     def print_csr(self):
 *         print_csrI(self.mat)
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":75
 *         result.set_matrix(c_result)
 *         return result
 *     def __ilshift__(CSRMatrixI self, int k):             # <<<<<<<<<<<<<<
 *         cdef c_CSRMatrixI *c_mat
 *         cdef int i, nnz
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":83
 *             c_mat.rightColumns[i]+=k
 *         return self
 *     def print_csr(self):             # <<<<<<<<<<<<<<
 *         print_csrI(self.mat)
 *     def get_size(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_9print_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_9print_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("print_csr (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_8print_csr(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_8print_csr(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("print_csr", 0);

  /* "lurrn/sparsmat.pyx":84
 *         return self
 *     def print_csr(self):
 *         print_csrI(self.mat)             # <<<<<<<<<<<<<<
 *     def get_size(self):
 *         return self.mat.offsets[self.mat.num_rows]
 */
  print_csr<int>(__pyx_v_self->mat);

  /* "lurrn/sparsmat.pyx":83
 *             c_mat.rightColumns[i]+=k
 *         return self
 *     def print_csr(self):             # <<<<<<<<<<<<<<
 *         print_csrI(self.mat)
 *     def get_size(self):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":85
 *     def print_csr(self):
 *         print_csrI(self.mat)
 *     def get_size(self):             # <<<<<<<<<<<<<<
 *         return self.mat.offsets[self.mat.num_rows]
 *     def __len__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_11get_size(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_11get_size(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_10get_size(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_10get_size(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":86
 *         print_csrI(self.mat)
 *     def get_size(self):
 *         return self.mat.offsets[self.mat.num_rows]             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return self.mat.num_rows
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":85
 *     def print_csr(self):
 *         print_csrI(self.mat)
 *     def get_size(self):             # <<<<<<<<<<<<<<
 *         return self.mat.offsets[self.mat.num_rows]
 *     def __len__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":87
 *     def get_size(self):
 *         return self.mat.offsets[self.mat.num_rows]
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.mat.num_rows
 *     def __getitem__(self,k):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_13__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_13__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_12__len__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_12__len__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":88
 *         return self.mat.offsets[self.mat.num_rows]
 *     def __len__(self):
 *         return self.mat.num_rows             # <<<<<<<<<<<<<<
 *     def __getitem__(self,k):
 *         cdef int off1, off2
 */
  __pyx_r = __pyx_v_self->mat->num_rows;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":87
 *     def get_size(self):
 *         return self.mat.offsets[self.mat.num_rows]
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.mat.num_rows
 *     def __getitem__(self,k):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":89
 *     def __len__(self):
 *         return self.mat.num_rows
 *     def __getitem__(self,k):             # <<<<<<<<<<<<<<
 *         cdef int off1, off2
 *         cdef SparseVectorI res
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_15__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_k); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_15__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_14__getitem__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self), ((PyObject *)__pyx_v_k));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_14__getitem__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_k) {
  int __pyx_v_off1;
  int __pyx_v_off2;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_res = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "lurrn/sparsmat.pyx":92
 *         cdef int off1, off2
 *         cdef SparseVectorI res
 *         if not (k>=0 and k<self.mat.num_rows):             # <<<<<<<<<<<<<<
 *             raise IndexError
 *         off1=self.mat.offsets[k]
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_k, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = __Pyx_PyInt_From_coordinate_t(__pyx_v_self->mat->num_rows); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  __pyx_t_3 = ((!__pyx_t_1) != 0);
  if (__pyx_t_3) {

    /* "lurrn/sparsmat.pyx":93
 *         cdef SparseVectorI res
 *         if not (k>=0 and k<self.mat.num_rows):
 *             raise IndexError             # <<<<<<<<<<<<<<
 *         off1=self.mat.offsets[k]
 *         off2=self.mat.offsets[k+1]
 */
    __Pyx_Raise(__pyx_builtin_IndexError, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lurrn/sparsmat.pyx":94
 *         if not (k>=0 and k<self.mat.num_rows):
 *             raise IndexError
 *         off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *         off2=self.mat.offsets[k+1]
 *         if off1==off2:
 */
  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_k); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_t_5]);

  /* "lurrn/sparsmat.pyx":95
 *             raise IndexError
 *         off1=self.mat.offsets[k]
 *         off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *         if off1==off2:
 *             return emptyvec_I
 */
  __pyx_t_4 = PyNumber_Add(__pyx_v_k, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_off2 = (__pyx_v_self->mat->offsets[__pyx_t_5]);

  /* "lurrn/sparsmat.pyx":96
 *         off1=self.mat.offsets[k]
 *         off2=self.mat.offsets[k+1]
 *         if off1==off2:             # <<<<<<<<<<<<<<
 *             return emptyvec_I
 *         res=SparseVectorI()
 */
  __pyx_t_3 = ((__pyx_v_off1 == __pyx_v_off2) != 0);
  if (__pyx_t_3) {

    /* "lurrn/sparsmat.pyx":97
 *         off2=self.mat.offsets[k+1]
 *         if off1==off2:
 *             return emptyvec_I             # <<<<<<<<<<<<<<
 *         res=SparseVectorI()
 *         res.buf=self
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_5lurrn_8sparsmat_emptyvec_I));
    __pyx_r = ((PyObject *)__pyx_v_5lurrn_8sparsmat_emptyvec_I);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":98
 *         if off1==off2:
 *             return emptyvec_I
 *         res=SparseVectorI()             # <<<<<<<<<<<<<<
 *         res.buf=self
 *         res.my_len=off2-off1
 */
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorI)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_res = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "lurrn/sparsmat.pyx":99
 *             return emptyvec_I
 *         res=SparseVectorI()
 *         res.buf=self             # <<<<<<<<<<<<<<
 *         res.my_len=off2-off1
 *         res.vals_ptr=&self.mat.values[off1]
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __Pyx_GOTREF(__pyx_v_res->buf);
  __Pyx_DECREF(__pyx_v_res->buf);
  __pyx_v_res->buf = ((PyObject *)__pyx_v_self);

  /* "lurrn/sparsmat.pyx":100
 *         res=SparseVectorI()
 *         res.buf=self
 *         res.my_len=off2-off1             # <<<<<<<<<<<<<<
 *         res.vals_ptr=&self.mat.values[off1]
 *         res.idx_ptr=&self.mat.rightColumns[off1]
 */
  __pyx_v_res->my_len = (__pyx_v_off2 - __pyx_v_off1);

  /* "lurrn/sparsmat.pyx":101
 *         res.buf=self
 *         res.my_len=off2-off1
 *         res.vals_ptr=&self.mat.values[off1]             # <<<<<<<<<<<<<<
 *         res.idx_ptr=&self.mat.rightColumns[off1]
 *         return res
 */
  __pyx_v_res->vals_ptr = (&(__pyx_v_self->mat->values[__pyx_v_off1]));

  /* "lurrn/sparsmat.pyx":102
 *         res.my_len=off2-off1
 *         res.vals_ptr=&self.mat.values[off1]
 *         res.idx_ptr=&self.mat.rightColumns[off1]             # <<<<<<<<<<<<<<
 *         return res
 *     def item_iter(self):
 */
  __pyx_v_res->idx_ptr = (&(__pyx_v_self->mat->rightColumns[__pyx_v_off1]));

  /* "lurrn/sparsmat.pyx":103
 *         res.vals_ptr=&self.mat.values[off1]
 *         res.idx_ptr=&self.mat.rightColumns[off1]
 *         return res             # <<<<<<<<<<<<<<
 *     def item_iter(self):
 *         if self.mat.num_rows>0:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_res));
  __pyx_r = ((PyObject *)__pyx_v_res);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":89
 *     def __len__(self):
 *         return self.mat.num_rows
 *     def __getitem__(self,k):             # <<<<<<<<<<<<<<
 *         cdef int off1, off2
 *         cdef SparseVectorI res
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_res);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":104
 *         res.idx_ptr=&self.mat.rightColumns[off1]
 *         return res
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         if self.mat.num_rows>0:
 *             return CSRMatrixI_item_iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_17item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_17item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("item_iter (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_16item_iter(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_16item_iter(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("item_iter", 0);

  /* "lurrn/sparsmat.pyx":105
 *         return res
 *     def item_iter(self):
 *         if self.mat.num_rows>0:             # <<<<<<<<<<<<<<
 *             return CSRMatrixI_item_iter(self)
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_self->mat->num_rows > 0) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":106
 *     def item_iter(self):
 *         if self.mat.num_rows>0:
 *             return CSRMatrixI_item_iter(self)             # <<<<<<<<<<<<<<
 *         else:
 *             return ()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixI_item_iter)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":108
 *             return CSRMatrixI_item_iter(self)
 *         else:
 *             return ()             # <<<<<<<<<<<<<<
 *     def to_scipy(self):
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] data
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_r = __pyx_empty_tuple;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":104
 *         res.idx_ptr=&self.mat.rightColumns[off1]
 *         return res
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         if self.mat.num_rows>0:
 *             return CSRMatrixI_item_iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.item_iter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":109
 *         else:
 *             return ()
 *     def to_scipy(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] data
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indices
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_19to_scipy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_19to_scipy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_scipy (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_18to_scipy(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_18to_scipy(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self) {
  PyArrayObject *__pyx_v_data = 0;
  PyArrayObject *__pyx_v_indices = 0;
  PyArrayObject *__pyx_v_indptr = 0;
  int __pyx_v_num_rows;
  int __pyx_v_max_offset;
  int __pyx_v_i;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_data;
  __Pyx_Buffer __pyx_pybuffer_data;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indices;
  __Pyx_Buffer __pyx_pybuffer_indices;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indptr;
  __Pyx_Buffer __pyx_pybuffer_indptr;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  coordinate_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyArrayObject *__pyx_t_14 = NULL;
  PyArrayObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_t_19;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_scipy", 0);
  __pyx_pybuffer_data.pybuffer.buf = NULL;
  __pyx_pybuffer_data.refcount = 0;
  __pyx_pybuffernd_data.data = NULL;
  __pyx_pybuffernd_data.rcbuffer = &__pyx_pybuffer_data;
  __pyx_pybuffer_indices.pybuffer.buf = NULL;
  __pyx_pybuffer_indices.refcount = 0;
  __pyx_pybuffernd_indices.data = NULL;
  __pyx_pybuffernd_indices.rcbuffer = &__pyx_pybuffer_indices;
  __pyx_pybuffer_indptr.pybuffer.buf = NULL;
  __pyx_pybuffer_indptr.refcount = 0;
  __pyx_pybuffernd_indptr.data = NULL;
  __pyx_pybuffernd_indptr.rcbuffer = &__pyx_pybuffer_indptr;

  /* "lurrn/sparsmat.pyx":113
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indices
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indptr
 *         cdef int num_rows=self.mat.num_rows             # <<<<<<<<<<<<<<
 *         cdef int max_offset=self.mat.offsets[num_rows]
 *         cdef int i,j
 */
  __pyx_t_1 = __pyx_v_self->mat->num_rows;
  __pyx_v_num_rows = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":114
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indptr
 *         cdef int num_rows=self.mat.num_rows
 *         cdef int max_offset=self.mat.offsets[num_rows]             # <<<<<<<<<<<<<<
 *         cdef int i,j
 *         indptr=numpy.zeros(num_rows+1, numpy.int32)
 */
  __pyx_v_max_offset = (__pyx_v_self->mat->offsets[__pyx_v_num_rows]);

  /* "lurrn/sparsmat.pyx":116
 *         cdef int max_offset=self.mat.offsets[num_rows]
 *         cdef int i,j
 *         indptr=numpy.zeros(num_rows+1, numpy.int32)             # <<<<<<<<<<<<<<
 *         indices=numpy.zeros(max_offset, numpy.int32)
 *         data=numpy.zeros(max_offset, numpy.int32)
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_long((__pyx_v_num_rows + 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_int32); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_7 = 1;
    }
  }
  __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (__pyx_t_5) {
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_3 = 0;
  __pyx_t_6 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer, (PyObject*)__pyx_v_indptr, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
    }
    __pyx_pybuffernd_indptr.diminfo[0].strides = __pyx_pybuffernd_indptr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indptr.diminfo[0].shape = __pyx_pybuffernd_indptr.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_9 = 0;
  __pyx_v_indptr = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":117
 *         cdef int i,j
 *         indptr=numpy.zeros(num_rows+1, numpy.int32)
 *         indices=numpy.zeros(max_offset, numpy.int32)             # <<<<<<<<<<<<<<
 *         data=numpy.zeros(max_offset, numpy.int32)
 *         for i from 0<=i<=num_rows:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_max_offset); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int32); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
      __pyx_t_7 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_6) {
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_7, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_7, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_4 = 0;
  __pyx_t_3 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indices.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indices.rcbuffer->pybuffer, (PyObject*)__pyx_v_indices, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
      }
    }
    __pyx_pybuffernd_indices.diminfo[0].strides = __pyx_pybuffernd_indices.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indices.diminfo[0].shape = __pyx_pybuffernd_indices.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_14 = 0;
  __pyx_v_indices = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":118
 *         indptr=numpy.zeros(num_rows+1, numpy.int32)
 *         indices=numpy.zeros(max_offset, numpy.int32)
 *         data=numpy.zeros(max_offset, numpy.int32)             # <<<<<<<<<<<<<<
 *         for i from 0<=i<=num_rows:
 *             indptr[i]=self.mat.offsets[i]
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_max_offset); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_int32); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_7 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_3) {
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_8 = 0;
  __pyx_t_4 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_15 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data.rcbuffer->pybuffer, (PyObject*)__pyx_v_data, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
    }
    __pyx_pybuffernd_data.diminfo[0].strides = __pyx_pybuffernd_data.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_data.diminfo[0].shape = __pyx_pybuffernd_data.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_15 = 0;
  __pyx_v_data = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":119
 *         indices=numpy.zeros(max_offset, numpy.int32)
 *         data=numpy.zeros(max_offset, numpy.int32)
 *         for i from 0<=i<=num_rows:             # <<<<<<<<<<<<<<
 *             indptr[i]=self.mat.offsets[i]
 *         for i from 0<=i<max_offset:
 */
  __pyx_t_10 = __pyx_v_num_rows;
  for (__pyx_v_i = 0; __pyx_v_i <= __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":120
 *         data=numpy.zeros(max_offset, numpy.int32)
 *         for i from 0<=i<=num_rows:
 *             indptr[i]=self.mat.offsets[i]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<max_offset:
 *             indices[i]=self.mat.rightColumns[i]
 */
    __pyx_t_16 = __pyx_v_i;
    __pyx_t_17 = -1;
    if (__pyx_t_16 < 0) {
      __pyx_t_16 += __pyx_pybuffernd_indptr.diminfo[0].shape;
      if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 0;
    } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_indptr.diminfo[0].shape)) __pyx_t_17 = 0;
    if (unlikely(__pyx_t_17 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_17);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_indptr.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_indptr.diminfo[0].strides) = (__pyx_v_self->mat->offsets[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":121
 *         for i from 0<=i<=num_rows:
 *             indptr[i]=self.mat.offsets[i]
 *         for i from 0<=i<max_offset:             # <<<<<<<<<<<<<<
 *             indices[i]=self.mat.rightColumns[i]
 *         for i from 0<=i<max_offset:
 */
  __pyx_t_10 = __pyx_v_max_offset;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":122
 *             indptr[i]=self.mat.offsets[i]
 *         for i from 0<=i<max_offset:
 *             indices[i]=self.mat.rightColumns[i]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<max_offset:
 *             data[i]=self.mat.values[i]
 */
    __pyx_t_17 = __pyx_v_i;
    __pyx_t_18 = -1;
    if (__pyx_t_17 < 0) {
      __pyx_t_17 += __pyx_pybuffernd_indices.diminfo[0].shape;
      if (unlikely(__pyx_t_17 < 0)) __pyx_t_18 = 0;
    } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_indices.diminfo[0].shape)) __pyx_t_18 = 0;
    if (unlikely(__pyx_t_18 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_18);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_indices.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_indices.diminfo[0].strides) = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":123
 *         for i from 0<=i<max_offset:
 *             indices[i]=self.mat.rightColumns[i]
 *         for i from 0<=i<max_offset:             # <<<<<<<<<<<<<<
 *             data[i]=self.mat.values[i]
 *         return (data,indices,indptr)
 */
  __pyx_t_10 = __pyx_v_max_offset;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":124
 *             indices[i]=self.mat.rightColumns[i]
 *         for i from 0<=i<max_offset:
 *             data[i]=self.mat.values[i]             # <<<<<<<<<<<<<<
 *         return (data,indices,indptr)
 *     cpdef int get_maxcol(self):
 */
    __pyx_t_18 = __pyx_v_i;
    __pyx_t_19 = -1;
    if (__pyx_t_18 < 0) {
      __pyx_t_18 += __pyx_pybuffernd_data.diminfo[0].shape;
      if (unlikely(__pyx_t_18 < 0)) __pyx_t_19 = 0;
    } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_data.diminfo[0].shape)) __pyx_t_19 = 0;
    if (unlikely(__pyx_t_19 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_19);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_data.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_data.diminfo[0].strides) = (__pyx_v_self->mat->values[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":125
 *         for i from 0<=i<max_offset:
 *             data[i]=self.mat.values[i]
 *         return (data,indices,indptr)             # <<<<<<<<<<<<<<
 *     cpdef int get_maxcol(self):
 *         cdef int result=0
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_data));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_data));
  __Pyx_INCREF(((PyObject *)__pyx_v_indices));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_indices));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_indices));
  __Pyx_INCREF(((PyObject *)__pyx_v_indptr));
  PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_indptr));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_indptr));
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":109
 *         else:
 *             return ()
 *     def to_scipy(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] data
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indices
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.to_scipy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_data);
  __Pyx_XDECREF((PyObject *)__pyx_v_indices);
  __Pyx_XDECREF((PyObject *)__pyx_v_indptr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":126
 *             data[i]=self.mat.values[i]
 *         return (data,indices,indptr)
 *     cpdef int get_maxcol(self):             # <<<<<<<<<<<<<<
 *         cdef int result=0
 *         cdef int col_max
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_21get_maxcol(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_10CSRMatrixI_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, int __pyx_skip_dispatch) {
  int __pyx_v_result;
  int __pyx_v_col_max;
  coordinate_t __pyx_v_i;
  int __pyx_v_off1;
  int __pyx_v_off2;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  coordinate_t __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_maxcol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_21get_maxcol)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_5;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":127
 *         return (data,indices,indptr)
 *     cpdef int get_maxcol(self):
 *         cdef int result=0             # <<<<<<<<<<<<<<
 *         cdef int col_max
 *         cdef coordinate_t i
 */
  __pyx_v_result = 0;

  /* "lurrn/sparsmat.pyx":131
 *         cdef coordinate_t i
 *         cdef int off1, off2
 *         if self.cache_maxcol>=0:             # <<<<<<<<<<<<<<
 *             return self.cache_maxcol
 *         for i from 0<=i<self.mat.num_rows:
 */
  __pyx_t_6 = ((__pyx_v_self->cache_maxcol >= 0) != 0);
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":132
 *         cdef int off1, off2
 *         if self.cache_maxcol>=0:
 *             return self.cache_maxcol             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.mat.num_rows:
 *            off1=self.mat.offsets[i]
 */
    __pyx_r = __pyx_v_self->cache_maxcol;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":133
 *         if self.cache_maxcol>=0:
 *             return self.cache_maxcol
 *         for i from 0<=i<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *            off1=self.mat.offsets[i]
 *            off2=self.mat.offsets[i+1]
 */
  __pyx_t_7 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":134
 *             return self.cache_maxcol
 *         for i from 0<=i<self.mat.num_rows:
 *            off1=self.mat.offsets[i]             # <<<<<<<<<<<<<<
 *            off2=self.mat.offsets[i+1]
 *            if off2>off1:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":135
 *         for i from 0<=i<self.mat.num_rows:
 *            off1=self.mat.offsets[i]
 *            off2=self.mat.offsets[i+1]             # <<<<<<<<<<<<<<
 *            if off2>off1:
 *               col_max=self.mat.rightColumns[off2-1]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_i + 1)]);

    /* "lurrn/sparsmat.pyx":136
 *            off1=self.mat.offsets[i]
 *            off2=self.mat.offsets[i+1]
 *            if off2>off1:             # <<<<<<<<<<<<<<
 *               col_max=self.mat.rightColumns[off2-1]
 *               if result<col_max:
 */
    __pyx_t_6 = ((__pyx_v_off2 > __pyx_v_off1) != 0);
    if (__pyx_t_6) {

      /* "lurrn/sparsmat.pyx":137
 *            off2=self.mat.offsets[i+1]
 *            if off2>off1:
 *               col_max=self.mat.rightColumns[off2-1]             # <<<<<<<<<<<<<<
 *               if result<col_max:
 *                  result=col_max
 */
      __pyx_v_col_max = (__pyx_v_self->mat->rightColumns[(__pyx_v_off2 - 1)]);

      /* "lurrn/sparsmat.pyx":138
 *            if off2>off1:
 *               col_max=self.mat.rightColumns[off2-1]
 *               if result<col_max:             # <<<<<<<<<<<<<<
 *                  result=col_max
 *         self.cache_maxcol=result
 */
      __pyx_t_6 = ((__pyx_v_result < __pyx_v_col_max) != 0);
      if (__pyx_t_6) {

        /* "lurrn/sparsmat.pyx":139
 *               col_max=self.mat.rightColumns[off2-1]
 *               if result<col_max:
 *                  result=col_max             # <<<<<<<<<<<<<<
 *         self.cache_maxcol=result
 *         return result
 */
        __pyx_v_result = __pyx_v_col_max;
        goto __pyx_L7;
      }
      __pyx_L7:;
      goto __pyx_L6;
    }
    __pyx_L6:;
  }

  /* "lurrn/sparsmat.pyx":140
 *               if result<col_max:
 *                  result=col_max
 *         self.cache_maxcol=result             # <<<<<<<<<<<<<<
 *         return result
 *     cpdef CSRMatrixD transform_mi(self):
 */
  __pyx_v_self->cache_maxcol = __pyx_v_result;

  /* "lurrn/sparsmat.pyx":141
 *                  result=col_max
 *         self.cache_maxcol=result
 *         return result             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixD transform_mi(self):
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":126
 *             data[i]=self.mat.values[i]
 *         return (data,indices,indptr)
 *     cpdef int get_maxcol(self):             # <<<<<<<<<<<<<<
 *         cdef int result=0
 *         cdef int col_max
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_WriteUnraisable("lurrn.sparsmat.CSRMatrixI.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_21get_maxcol(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_21get_maxcol(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_maxcol (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_20get_maxcol(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_20get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_get_maxcol(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":142
 *         self.cache_maxcol=result
 *         return result
 *     cpdef CSRMatrixD transform_mi(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_r
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_23transform_mi(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_transform_mi(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_marginals_l = 0;
  PyArrayObject *__pyx_v_marginals_r = 0;
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp = 0;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_i;
  int __pyx_v_off1;
  int __pyx_v_off2;
  double __pyx_v_v;
  double __pyx_v_log_v;
  double __pyx_v_log_N;
  double __pyx_v_log1;
  double __pyx_v_log2;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_l;
  __Pyx_Buffer __pyx_pybuffer_marginals_l;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_r;
  __Pyx_Buffer __pyx_pybuffer_marginals_r;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyArrayObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyArrayObject *__pyx_t_11 = NULL;
  double __pyx_t_12;
  coordinate_t __pyx_t_13;
  coordinate_t __pyx_t_14;
  coordinate_t __pyx_t_15;
  int __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  Py_ssize_t __pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_mi", 0);
  __pyx_pybuffer_marginals_l.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_l.refcount = 0;
  __pyx_pybuffernd_marginals_l.data = NULL;
  __pyx_pybuffernd_marginals_l.rcbuffer = &__pyx_pybuffer_marginals_l;
  __pyx_pybuffer_marginals_r.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_r.refcount = 0;
  __pyx_pybuffernd_marginals_r.data = NULL;
  __pyx_pybuffernd_marginals_r.rcbuffer = &__pyx_pybuffer_marginals_r;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transform_mi); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_23transform_mi)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":145
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_r
 *         cdef VecD2 tmp=VecD2()             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, i
 *         cdef int off1, off2
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":149
 *         cdef int off1, off2
 *         cdef double v, log_v, log_N, log1, log2
 *         if self.mat.num_rows<100000:             # <<<<<<<<<<<<<<
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 */
  __pyx_t_5 = ((__pyx_v_self->mat->num_rows < 100000) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":150
 *         cdef double v, log_v, log_N, log1, log2
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         else:
 *             tmp.vec.reserve(100000)
 */
    __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":152
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 *             tmp.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()
 */
    __pyx_v_tmp->vec.reserve(100000);
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":153
 *         else:
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()             # <<<<<<<<<<<<<<
 *         marginals_r=self.right_marginals()
 *         log_N=log(marginals_l.sum())
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_left_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_l, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_marginals_l.diminfo[0].strides = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_l.diminfo[0].shape = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = 0;
  __pyx_v_marginals_l = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":154
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()             # <<<<<<<<<<<<<<
 *         log_N=log(marginals_l.sum())
 *         for k from 0<=k<self.mat.num_rows:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_right_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_r, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
      }
    }
    __pyx_pybuffernd_marginals_r.diminfo[0].strides = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_r.diminfo[0].shape = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_11 = 0;
  __pyx_v_marginals_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":155
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()
 *         log_N=log(marginals_l.sum())             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.num_rows:
 *             log1=log(marginals_l[k])-log_N
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_marginals_l), __pyx_n_s_sum); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_log_N = log(__pyx_t_12);

  /* "lurrn/sparsmat.pyx":156
 *         marginals_r=self.right_marginals()
 *         log_N=log(marginals_l.sum())
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             log1=log(marginals_l[k])-log_N
 *             off1=self.mat.offsets[k]
 */
  __pyx_t_13 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_13; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":157
 *         log_N=log(marginals_l.sum())
 *         for k from 0<=k<self.mat.num_rows:
 *             log1=log(marginals_l[k])-log_N             # <<<<<<<<<<<<<<
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 */
    __pyx_t_14 = __pyx_v_k;
    __pyx_t_7 = -1;
    if (unlikely(__pyx_t_14 >= (size_t)__pyx_pybuffernd_marginals_l.diminfo[0].shape)) __pyx_t_7 = 0;
    if (unlikely(__pyx_t_7 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_7);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_log1 = (log((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_marginals_l.diminfo[0].strides))) - __pyx_v_log_N);

    /* "lurrn/sparsmat.pyx":158
 *         for k from 0<=k<self.mat.num_rows:
 *             log1=log(marginals_l[k])-log_N
 *             off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":159
 *             log1=log(marginals_l[k])-log_N
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":160
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                v=self.mat.values[i]
 *                if v>0:
 */
    __pyx_t_7 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":161
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]             # <<<<<<<<<<<<<<
 *                if v>0:
 *                    log2=log(marginals_r[self.mat.rightColumns[i]])
 */
      __pyx_v_v = (__pyx_v_self->mat->values[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":162
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 *                if v>0:             # <<<<<<<<<<<<<<
 *                    log2=log(marginals_r[self.mat.rightColumns[i]])
 *                    log_v=log(v)-log2-log1
 */
      __pyx_t_5 = ((__pyx_v_v > 0.0) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":163
 *                v=self.mat.values[i]
 *                if v>0:
 *                    log2=log(marginals_r[self.mat.rightColumns[i]])             # <<<<<<<<<<<<<<
 *                    log_v=log(v)-log2-log1
 *                    if log_v>0:
 */
        __pyx_t_15 = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);
        __pyx_t_16 = -1;
        if (unlikely(__pyx_t_15 >= (size_t)__pyx_pybuffernd_marginals_r.diminfo[0].shape)) __pyx_t_16 = 0;
        if (unlikely(__pyx_t_16 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_16);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_log2 = log((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_marginals_r.diminfo[0].strides)));

        /* "lurrn/sparsmat.pyx":164
 *                if v>0:
 *                    log2=log(marginals_r[self.mat.rightColumns[i]])
 *                    log_v=log(v)-log2-log1             # <<<<<<<<<<<<<<
 *                    if log_v>0:
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 */
        __pyx_v_log_v = ((log(__pyx_v_v) - __pyx_v_log2) - __pyx_v_log1);

        /* "lurrn/sparsmat.pyx":165
 *                    log2=log(marginals_r[self.mat.rightColumns[i]])
 *                    log_v=log(v)-log2-log1
 *                    if log_v>0:             # <<<<<<<<<<<<<<
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()
 */
        __pyx_t_5 = ((__pyx_v_log_v > 0.0) != 0);
        if (__pyx_t_5) {

          /* "lurrn/sparsmat.pyx":166
 *                    log_v=log(v)-log2-log1
 *                    if log_v>0:
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)             # <<<<<<<<<<<<<<
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_mi_discount(self):
 */
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->mat->rightColumns[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_17 = PyFloat_FromDouble(__pyx_v_log_v); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_18 = NULL;
          __pyx_t_19 = 0;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_18)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_18);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
              __pyx_t_19 = 1;
            }
          }
          __pyx_t_20 = PyTuple_New(3+__pyx_t_19); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_20);
          if (__pyx_t_18) {
            PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); __pyx_t_18 = NULL;
          }
          PyTuple_SET_ITEM(__pyx_t_20, 0+__pyx_t_19, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_20, 1+__pyx_t_19, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_20, 2+__pyx_t_19, __pyx_t_17);
          __Pyx_GIVEREF(__pyx_t_17);
          __pyx_t_3 = 0;
          __pyx_t_4 = 0;
          __pyx_t_17 = 0;
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_20, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          goto __pyx_L9;
        }
        __pyx_L9:;
        goto __pyx_L8;
      }
      __pyx_L8:;
    }
  }

  /* "lurrn/sparsmat.pyx":167
 *                    if log_v>0:
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixD transform_mi_discount(self):
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp->__pyx_vtab)->to_csr(__pyx_v_tmp, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":142
 *         self.cache_maxcol=result
 *         return result
 *     cpdef CSRMatrixD transform_mi(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_r
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_20);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.transform_mi", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_l);
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_r);
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_23transform_mi(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_23transform_mi(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("transform_mi (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_22transform_mi(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_22transform_mi(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_mi", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_transform_mi(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.transform_mi", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":168
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_mi_discount(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_r
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_25transform_mi_discount(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_transform_mi_discount(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_marginals_l = 0;
  PyArrayObject *__pyx_v_marginals_r = 0;
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp = 0;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_i;
  int __pyx_v_off1;
  int __pyx_v_off2;
  double __pyx_v_marg_l;
  double __pyx_v_marg_r;
  double __pyx_v_log_corr1;
  double __pyx_v_log_corr2;
  double __pyx_v_v;
  double __pyx_v_log_v;
  double __pyx_v_log_N;
  double __pyx_v_log1;
  double __pyx_v_log2;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_l;
  __Pyx_Buffer __pyx_pybuffer_marginals_l;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_r;
  __Pyx_Buffer __pyx_pybuffer_marginals_r;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyArrayObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyArrayObject *__pyx_t_11 = NULL;
  double __pyx_t_12;
  coordinate_t __pyx_t_13;
  coordinate_t __pyx_t_14;
  coordinate_t __pyx_t_15;
  int __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  Py_ssize_t __pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_mi_discount", 0);
  __pyx_pybuffer_marginals_l.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_l.refcount = 0;
  __pyx_pybuffernd_marginals_l.data = NULL;
  __pyx_pybuffernd_marginals_l.rcbuffer = &__pyx_pybuffer_marginals_l;
  __pyx_pybuffer_marginals_r.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_r.refcount = 0;
  __pyx_pybuffernd_marginals_r.data = NULL;
  __pyx_pybuffernd_marginals_r.rcbuffer = &__pyx_pybuffer_marginals_r;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transform_mi_discount); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_25transform_mi_discount)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":171
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_r
 *         cdef VecD2 tmp=VecD2()             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, i
 *         cdef int off1, off2
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":176
 *         cdef double marg_l, marg_r, log_corr1, log_corr2
 *         cdef double v, log_v, log_N, log1, log2
 *         if self.mat.num_rows<100000:             # <<<<<<<<<<<<<<
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 */
  __pyx_t_5 = ((__pyx_v_self->mat->num_rows < 100000) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":177
 *         cdef double v, log_v, log_N, log1, log2
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         else:
 *             tmp.vec.reserve(100000)
 */
    __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":179
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 *             tmp.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()
 */
    __pyx_v_tmp->vec.reserve(100000);
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":180
 *         else:
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()             # <<<<<<<<<<<<<<
 *         marginals_r=self.right_marginals()
 *         log_N=log(marginals_l.sum())
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_left_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_l, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_marginals_l.diminfo[0].strides = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_l.diminfo[0].shape = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = 0;
  __pyx_v_marginals_l = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":181
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()             # <<<<<<<<<<<<<<
 *         log_N=log(marginals_l.sum())
 *         for k from 0<=k<self.mat.num_rows:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_right_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_r, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
      }
    }
    __pyx_pybuffernd_marginals_r.diminfo[0].strides = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_r.diminfo[0].shape = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_11 = 0;
  __pyx_v_marginals_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":182
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()
 *         log_N=log(marginals_l.sum())             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.num_rows:
 *             marg_l=marginals_l[k]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_marginals_l), __pyx_n_s_sum); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_log_N = log(__pyx_t_12);

  /* "lurrn/sparsmat.pyx":183
 *         marginals_r=self.right_marginals()
 *         log_N=log(marginals_l.sum())
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             marg_l=marginals_l[k]
 *             log1=log(marg_l)-log_N
 */
  __pyx_t_13 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_13; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":184
 *         log_N=log(marginals_l.sum())
 *         for k from 0<=k<self.mat.num_rows:
 *             marg_l=marginals_l[k]             # <<<<<<<<<<<<<<
 *             log1=log(marg_l)-log_N
 *             off1=self.mat.offsets[k]
 */
    __pyx_t_14 = __pyx_v_k;
    __pyx_t_7 = -1;
    if (unlikely(__pyx_t_14 >= (size_t)__pyx_pybuffernd_marginals_l.diminfo[0].shape)) __pyx_t_7 = 0;
    if (unlikely(__pyx_t_7 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_7);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_marg_l = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_marginals_l.diminfo[0].strides));

    /* "lurrn/sparsmat.pyx":185
 *         for k from 0<=k<self.mat.num_rows:
 *             marg_l=marginals_l[k]
 *             log1=log(marg_l)-log_N             # <<<<<<<<<<<<<<
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 */
    __pyx_v_log1 = (log(__pyx_v_marg_l) - __pyx_v_log_N);

    /* "lurrn/sparsmat.pyx":186
 *             marg_l=marginals_l[k]
 *             log1=log(marg_l)-log_N
 *             off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":187
 *             log1=log(marg_l)-log_N
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":188
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                v=self.mat.values[i]
 *                if v>0:
 */
    __pyx_t_7 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":189
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]             # <<<<<<<<<<<<<<
 *                if v>0:
 *                    marg_r=marginals_r[self.mat.rightColumns[i]]
 */
      __pyx_v_v = (__pyx_v_self->mat->values[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":190
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 *                if v>0:             # <<<<<<<<<<<<<<
 *                    marg_r=marginals_r[self.mat.rightColumns[i]]
 *                    log2=log(marg_r)
 */
      __pyx_t_5 = ((__pyx_v_v > 0.0) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":191
 *                v=self.mat.values[i]
 *                if v>0:
 *                    marg_r=marginals_r[self.mat.rightColumns[i]]             # <<<<<<<<<<<<<<
 *                    log2=log(marg_r)
 *                    log_corr1=log1p(-1.0/(v+1.0))
 */
        __pyx_t_15 = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);
        __pyx_t_16 = -1;
        if (unlikely(__pyx_t_15 >= (size_t)__pyx_pybuffernd_marginals_r.diminfo[0].shape)) __pyx_t_16 = 0;
        if (unlikely(__pyx_t_16 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_16);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_marg_r = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_marginals_r.diminfo[0].strides));

        /* "lurrn/sparsmat.pyx":192
 *                if v>0:
 *                    marg_r=marginals_r[self.mat.rightColumns[i]]
 *                    log2=log(marg_r)             # <<<<<<<<<<<<<<
 *                    log_corr1=log1p(-1.0/(v+1.0))
 *                    if marg_l<marg_r:
 */
        __pyx_v_log2 = log(__pyx_v_marg_r);

        /* "lurrn/sparsmat.pyx":193
 *                    marg_r=marginals_r[self.mat.rightColumns[i]]
 *                    log2=log(marg_r)
 *                    log_corr1=log1p(-1.0/(v+1.0))             # <<<<<<<<<<<<<<
 *                    if marg_l<marg_r:
 *                        log_corr2=log1p(-1.0/(marg_l+1.0))
 */
        __pyx_t_12 = (__pyx_v_v + 1.0);
        if (unlikely(__pyx_t_12 == 0)) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
          #endif
          PyErr_SetString(PyExc_ZeroDivisionError, "float division");
          #ifdef WITH_THREAD
          PyGILState_Release(__pyx_gilstate_save);
          #endif
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_log_corr1 = log1p((-1.0 / __pyx_t_12));

        /* "lurrn/sparsmat.pyx":194
 *                    log2=log(marg_r)
 *                    log_corr1=log1p(-1.0/(v+1.0))
 *                    if marg_l<marg_r:             # <<<<<<<<<<<<<<
 *                        log_corr2=log1p(-1.0/(marg_l+1.0))
 *                    else:
 */
        __pyx_t_5 = ((__pyx_v_marg_l < __pyx_v_marg_r) != 0);
        if (__pyx_t_5) {

          /* "lurrn/sparsmat.pyx":195
 *                    log_corr1=log1p(-1.0/(v+1.0))
 *                    if marg_l<marg_r:
 *                        log_corr2=log1p(-1.0/(marg_l+1.0))             # <<<<<<<<<<<<<<
 *                    else:
 *                        log_corr2=log1p(-1.0/(marg_r+1.0))
 */
          __pyx_t_12 = (__pyx_v_marg_l + 1.0);
          if (unlikely(__pyx_t_12 == 0)) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
            #endif
            PyErr_SetString(PyExc_ZeroDivisionError, "float division");
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_log_corr2 = log1p((-1.0 / __pyx_t_12));
          goto __pyx_L9;
        }
        /*else*/ {

          /* "lurrn/sparsmat.pyx":197
 *                        log_corr2=log1p(-1.0/(marg_l+1.0))
 *                    else:
 *                        log_corr2=log1p(-1.0/(marg_r+1.0))             # <<<<<<<<<<<<<<
 *                    log_v=log(v)-log2-log1+log_corr1+log_corr2
 *                    if log_v>0:
 */
          __pyx_t_12 = (__pyx_v_marg_r + 1.0);
          if (unlikely(__pyx_t_12 == 0)) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
            #endif
            PyErr_SetString(PyExc_ZeroDivisionError, "float division");
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_log_corr2 = log1p((-1.0 / __pyx_t_12));
        }
        __pyx_L9:;

        /* "lurrn/sparsmat.pyx":198
 *                    else:
 *                        log_corr2=log1p(-1.0/(marg_r+1.0))
 *                    log_v=log(v)-log2-log1+log_corr1+log_corr2             # <<<<<<<<<<<<<<
 *                    if log_v>0:
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 */
        __pyx_v_log_v = ((((log(__pyx_v_v) - __pyx_v_log2) - __pyx_v_log1) + __pyx_v_log_corr1) + __pyx_v_log_corr2);

        /* "lurrn/sparsmat.pyx":199
 *                        log_corr2=log1p(-1.0/(marg_r+1.0))
 *                    log_v=log(v)-log2-log1+log_corr1+log_corr2
 *                    if log_v>0:             # <<<<<<<<<<<<<<
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()
 */
        __pyx_t_5 = ((__pyx_v_log_v > 0.0) != 0);
        if (__pyx_t_5) {

          /* "lurrn/sparsmat.pyx":200
 *                    log_v=log(v)-log2-log1+log_corr1+log_corr2
 *                    if log_v>0:
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)             # <<<<<<<<<<<<<<
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_ll(self):
 */
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->mat->rightColumns[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_17 = PyFloat_FromDouble(__pyx_v_log_v); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_18 = NULL;
          __pyx_t_19 = 0;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_18)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_18);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
              __pyx_t_19 = 1;
            }
          }
          __pyx_t_20 = PyTuple_New(3+__pyx_t_19); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_20);
          if (__pyx_t_18) {
            PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); __pyx_t_18 = NULL;
          }
          PyTuple_SET_ITEM(__pyx_t_20, 0+__pyx_t_19, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_20, 1+__pyx_t_19, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_20, 2+__pyx_t_19, __pyx_t_17);
          __Pyx_GIVEREF(__pyx_t_17);
          __pyx_t_3 = 0;
          __pyx_t_4 = 0;
          __pyx_t_17 = 0;
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_20, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          goto __pyx_L10;
        }
        __pyx_L10:;
        goto __pyx_L8;
      }
      __pyx_L8:;
    }
  }

  /* "lurrn/sparsmat.pyx":201
 *                    if log_v>0:
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixD transform_ll(self):
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp->__pyx_vtab)->to_csr(__pyx_v_tmp, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":168
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_mi_discount(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_r
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_20);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.transform_mi_discount", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_l);
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_r);
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_25transform_mi_discount(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_25transform_mi_discount(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("transform_mi_discount (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_24transform_mi_discount(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_24transform_mi_discount(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_mi_discount", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_transform_mi_discount(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.transform_mi_discount", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":202
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_ll(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_r
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_27transform_ll(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_transform_ll(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_marginals_l = 0;
  PyArrayObject *__pyx_v_marginals_r = 0;
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp = 0;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_i;
  int __pyx_v_off1;
  int __pyx_v_off2;
  double __pyx_v_c;
  double __pyx_v_c1;
  double __pyx_v_c2;
  double __pyx_v_p;
  double __pyx_v_p1;
  double __pyx_v_pn1;
  double __pyx_v_ll;
  PyObject *__pyx_v_c12 = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_l;
  __Pyx_Buffer __pyx_pybuffer_marginals_l;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_r;
  __Pyx_Buffer __pyx_pybuffer_marginals_r;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyArrayObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyArrayObject *__pyx_t_11 = NULL;
  double __pyx_t_12;
  coordinate_t __pyx_t_13;
  coordinate_t __pyx_t_14;
  coordinate_t __pyx_t_15;
  int __pyx_t_16;
  double __pyx_t_17;
  double __pyx_t_18;
  double __pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  Py_ssize_t __pyx_t_22;
  PyObject *__pyx_t_23 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_ll", 0);
  __pyx_pybuffer_marginals_l.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_l.refcount = 0;
  __pyx_pybuffernd_marginals_l.data = NULL;
  __pyx_pybuffernd_marginals_l.rcbuffer = &__pyx_pybuffer_marginals_l;
  __pyx_pybuffer_marginals_r.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_r.refcount = 0;
  __pyx_pybuffernd_marginals_r.data = NULL;
  __pyx_pybuffernd_marginals_r.rcbuffer = &__pyx_pybuffer_marginals_r;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transform_ll); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_27transform_ll)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":205
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_r
 *         cdef VecD2 tmp=VecD2()             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, i
 *         cdef int off1, off2
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":210
 *         cdef double marg_l, marg_r, c, c1, c2
 *         cdef double p, p1, pn1, ll
 *         if self.mat.num_rows<100000:             # <<<<<<<<<<<<<<
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 */
  __pyx_t_5 = ((__pyx_v_self->mat->num_rows < 100000) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":211
 *         cdef double p, p1, pn1, ll
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         else:
 *             tmp.vec.reserve(100000)
 */
    __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":213
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 *             tmp.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()
 */
    __pyx_v_tmp->vec.reserve(100000);
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":214
 *         else:
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()             # <<<<<<<<<<<<<<
 *         marginals_r=self.right_marginals()
 *         c=marginals_l.sum()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_left_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_l, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_marginals_l.diminfo[0].strides = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_l.diminfo[0].shape = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = 0;
  __pyx_v_marginals_l = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":215
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()             # <<<<<<<<<<<<<<
 *         c=marginals_l.sum()
 *         for k from 0<=k<self.mat.num_rows:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_right_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_r, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
      }
    }
    __pyx_pybuffernd_marginals_r.diminfo[0].strides = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_r.diminfo[0].shape = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_11 = 0;
  __pyx_v_marginals_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":216
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()
 *         c=marginals_l.sum()             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.num_rows:
 *             c1=marginals_l[k]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_marginals_l), __pyx_n_s_sum); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_c = __pyx_t_12;

  /* "lurrn/sparsmat.pyx":217
 *         marginals_r=self.right_marginals()
 *         c=marginals_l.sum()
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             c1=marginals_l[k]
 *             off1=self.mat.offsets[k]
 */
  __pyx_t_13 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_13; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":218
 *         c=marginals_l.sum()
 *         for k from 0<=k<self.mat.num_rows:
 *             c1=marginals_l[k]             # <<<<<<<<<<<<<<
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 */
    __pyx_t_14 = __pyx_v_k;
    __pyx_t_7 = -1;
    if (unlikely(__pyx_t_14 >= (size_t)__pyx_pybuffernd_marginals_l.diminfo[0].shape)) __pyx_t_7 = 0;
    if (unlikely(__pyx_t_7 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_7);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_c1 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_marginals_l.diminfo[0].strides));

    /* "lurrn/sparsmat.pyx":219
 *         for k from 0<=k<self.mat.num_rows:
 *             c1=marginals_l[k]
 *             off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":220
 *             c1=marginals_l[k]
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                c12=self.mat.values[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":221
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                c12=self.mat.values[i]
 *                if c12>0:
 */
    __pyx_t_7 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":222
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                c12=self.mat.values[i]             # <<<<<<<<<<<<<<
 *                if c12>0:
 *                    c2=marginals_r[self.mat.rightColumns[i]]
 */
      __pyx_t_1 = __Pyx_PyInt_From_int((__pyx_v_self->mat->values[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_c12, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "lurrn/sparsmat.pyx":223
 *             for i from off1<=i<off2:
 *                c12=self.mat.values[i]
 *                if c12>0:             # <<<<<<<<<<<<<<
 *                    c2=marginals_r[self.mat.rightColumns[i]]
 *                    p=c2/c
 */
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_c12, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":224
 *                c12=self.mat.values[i]
 *                if c12>0:
 *                    c2=marginals_r[self.mat.rightColumns[i]]             # <<<<<<<<<<<<<<
 *                    p=c2/c
 *                    p1=c12/c1
 */
        __pyx_t_15 = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);
        __pyx_t_16 = -1;
        if (unlikely(__pyx_t_15 >= (size_t)__pyx_pybuffernd_marginals_r.diminfo[0].shape)) __pyx_t_16 = 0;
        if (unlikely(__pyx_t_16 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_16);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_c2 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_marginals_r.diminfo[0].strides));

        /* "lurrn/sparsmat.pyx":225
 *                if c12>0:
 *                    c2=marginals_r[self.mat.rightColumns[i]]
 *                    p=c2/c             # <<<<<<<<<<<<<<
 *                    p1=c12/c1
 *                    if p1>p:
 */
        if (unlikely(__pyx_v_c == 0)) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
          #endif
          PyErr_SetString(PyExc_ZeroDivisionError, "float division");
          #ifdef WITH_THREAD
          PyGILState_Release(__pyx_gilstate_save);
          #endif
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_p = (__pyx_v_c2 / __pyx_v_c);

        /* "lurrn/sparsmat.pyx":226
 *                    c2=marginals_r[self.mat.rightColumns[i]]
 *                    p=c2/c
 *                    p1=c12/c1             # <<<<<<<<<<<<<<
 *                    if p1>p:
 *                        pn1=(c2-c12)/(c-c1)
 */
        __pyx_t_1 = PyFloat_FromDouble(__pyx_v_c1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_v_c12, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_v_p1 = __pyx_t_12;

        /* "lurrn/sparsmat.pyx":227
 *                    p=c2/c
 *                    p1=c12/c1
 *                    if p1>p:             # <<<<<<<<<<<<<<
 *                        pn1=(c2-c12)/(c-c1)
 *                        ll=(-logB(c1,p,c12)-logB(c-c1,p,c2-c12)
 */
        __pyx_t_5 = ((__pyx_v_p1 > __pyx_v_p) != 0);
        if (__pyx_t_5) {

          /* "lurrn/sparsmat.pyx":228
 *                    p1=c12/c1
 *                    if p1>p:
 *                        pn1=(c2-c12)/(c-c1)             # <<<<<<<<<<<<<<
 *                        ll=(-logB(c1,p,c12)-logB(c-c1,p,c2-c12)
 *                            +logB(c1,p1,c12)+logB(c-c1,pn1,c2-c12))
 */
          __pyx_t_2 = PyFloat_FromDouble(__pyx_v_c2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_1 = PyNumber_Subtract(__pyx_t_2, __pyx_v_c12); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = PyFloat_FromDouble((__pyx_v_c - __pyx_v_c1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_v_pn1 = __pyx_t_12;

          /* "lurrn/sparsmat.pyx":229
 *                    if p1>p:
 *                        pn1=(c2-c12)/(c-c1)
 *                        ll=(-logB(c1,p,c12)-logB(c-c1,p,c2-c12)             # <<<<<<<<<<<<<<
 *                            +logB(c1,p1,c12)+logB(c-c1,pn1,c2-c12))
 *                        tmp.add_count(k,self.mat.rightColumns[i],ll)
 */
          __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_v_c12); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_3 = PyFloat_FromDouble(__pyx_v_c2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_2 = PyNumber_Subtract(__pyx_t_3, __pyx_v_c12); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_17 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_17 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "lurrn/sparsmat.pyx":230
 *                        pn1=(c2-c12)/(c-c1)
 *                        ll=(-logB(c1,p,c12)-logB(c-c1,p,c2-c12)
 *                            +logB(c1,p1,c12)+logB(c-c1,pn1,c2-c12))             # <<<<<<<<<<<<<<
 *                        tmp.add_count(k,self.mat.rightColumns[i],ll)
 *         return tmp.to_csr()
 */
          __pyx_t_18 = __pyx_PyFloat_AsDouble(__pyx_v_c12); if (unlikely((__pyx_t_18 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_2 = PyFloat_FromDouble(__pyx_v_c2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = PyNumber_Subtract(__pyx_t_2, __pyx_v_c12); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_19 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_19 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_v_ll = ((((-__pyx_f_5lurrn_8sparsmat_logB(__pyx_v_c1, __pyx_v_p, __pyx_t_12)) - __pyx_f_5lurrn_8sparsmat_logB((__pyx_v_c - __pyx_v_c1), __pyx_v_p, __pyx_t_17)) + __pyx_f_5lurrn_8sparsmat_logB(__pyx_v_c1, __pyx_v_p1, __pyx_t_18)) + __pyx_f_5lurrn_8sparsmat_logB((__pyx_v_c - __pyx_v_c1), __pyx_v_pn1, __pyx_t_19));

          /* "lurrn/sparsmat.pyx":231
 *                        ll=(-logB(c1,p,c12)-logB(c-c1,p,c2-c12)
 *                            +logB(c1,p1,c12)+logB(c-c1,pn1,c2-c12))
 *                        tmp.add_count(k,self.mat.rightColumns[i],ll)             # <<<<<<<<<<<<<<
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_l1(self):
 */
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_1 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_4 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->mat->rightColumns[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_20 = PyFloat_FromDouble(__pyx_v_ll); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_20);
          __pyx_t_21 = NULL;
          __pyx_t_22 = 0;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_21)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_21);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
              __pyx_t_22 = 1;
            }
          }
          __pyx_t_23 = PyTuple_New(3+__pyx_t_22); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_23);
          if (__pyx_t_21) {
            PyTuple_SET_ITEM(__pyx_t_23, 0, __pyx_t_21); __Pyx_GIVEREF(__pyx_t_21); __pyx_t_21 = NULL;
          }
          PyTuple_SET_ITEM(__pyx_t_23, 0+__pyx_t_22, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_23, 1+__pyx_t_22, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_23, 2+__pyx_t_22, __pyx_t_20);
          __Pyx_GIVEREF(__pyx_t_20);
          __pyx_t_1 = 0;
          __pyx_t_4 = 0;
          __pyx_t_20 = 0;
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_23, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          goto __pyx_L9;
        }
        __pyx_L9:;
        goto __pyx_L8;
      }
      __pyx_L8:;
    }
  }

  /* "lurrn/sparsmat.pyx":232
 *                            +logB(c1,p1,c12)+logB(c-c1,pn1,c2-c12))
 *                        tmp.add_count(k,self.mat.rightColumns[i],ll)
 *         return tmp.to_csr()             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixD transform_l1(self):
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp->__pyx_vtab)->to_csr(__pyx_v_tmp, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":202
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_ll(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_r
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_23);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.transform_ll", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_l);
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_r);
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XDECREF(__pyx_v_c12);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_27transform_ll(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_27transform_ll(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("transform_ll (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_26transform_ll(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_26transform_ll(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_ll", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_transform_ll(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.transform_ll", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":233
 *                        tmp.add_count(k,self.mat.rightColumns[i],ll)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_l1(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 *         cdef VecD2 tmp=VecD2()
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_29transform_l1(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_transform_l1(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_marginals_l = 0;
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp = 0;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_i;
  int __pyx_v_off1;
  int __pyx_v_off2;
  double __pyx_v_v;
  double __pyx_v_marg_l;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_l;
  __Pyx_Buffer __pyx_pybuffer_marginals_l;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyArrayObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  coordinate_t __pyx_t_11;
  coordinate_t __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  Py_ssize_t __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_l1", 0);
  __pyx_pybuffer_marginals_l.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_l.refcount = 0;
  __pyx_pybuffernd_marginals_l.data = NULL;
  __pyx_pybuffernd_marginals_l.rcbuffer = &__pyx_pybuffer_marginals_l;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transform_l1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_29transform_l1)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":235
 *     cpdef CSRMatrixD transform_l1(self):
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 *         cdef VecD2 tmp=VecD2()             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, i
 *         cdef int off1, off2
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":239
 *         cdef int off1, off2
 *         cdef double v, marg_l
 *         if self.mat.num_rows<100000:             # <<<<<<<<<<<<<<
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 */
  __pyx_t_5 = ((__pyx_v_self->mat->num_rows < 100000) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":240
 *         cdef double v, marg_l
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         else:
 *             tmp.vec.reserve(100000)
 */
    __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":242
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 *             tmp.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *         marginals_l=self.left_marginals()
 *         for k from 0<=k<self.mat.num_rows:
 */
    __pyx_v_tmp->vec.reserve(100000);
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":243
 *         else:
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.num_rows:
 *             marg_l=marginals_l[k]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_left_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_l, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_marginals_l.diminfo[0].strides = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_l.diminfo[0].shape = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = 0;
  __pyx_v_marginals_l = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":244
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             marg_l=marginals_l[k]
 *             off1=self.mat.offsets[k]
 */
  __pyx_t_11 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_11; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":245
 *         marginals_l=self.left_marginals()
 *         for k from 0<=k<self.mat.num_rows:
 *             marg_l=marginals_l[k]             # <<<<<<<<<<<<<<
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 */
    __pyx_t_12 = __pyx_v_k;
    __pyx_t_7 = -1;
    if (unlikely(__pyx_t_12 >= (size_t)__pyx_pybuffernd_marginals_l.diminfo[0].shape)) __pyx_t_7 = 0;
    if (unlikely(__pyx_t_7 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_7);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_marg_l = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_marginals_l.diminfo[0].strides));

    /* "lurrn/sparsmat.pyx":246
 *         for k from 0<=k<self.mat.num_rows:
 *             marg_l=marginals_l[k]
 *             off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":247
 *             marg_l=marginals_l[k]
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":248
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                v=self.mat.values[i]
 *                if v>0:
 */
    __pyx_t_7 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":249
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]             # <<<<<<<<<<<<<<
 *                if v>0:
 *                    tmp.add_count(k,self.mat.rightColumns[i],v/marg_l)
 */
      __pyx_v_v = (__pyx_v_self->mat->values[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":250
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 *                if v>0:             # <<<<<<<<<<<<<<
 *                    tmp.add_count(k,self.mat.rightColumns[i],v/marg_l)
 *         return tmp.to_csr()
 */
      __pyx_t_5 = ((__pyx_v_v > 0.0) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":251
 *                v=self.mat.values[i]
 *                if v>0:
 *                    tmp.add_count(k,self.mat.rightColumns[i],v/marg_l)             # <<<<<<<<<<<<<<
 *         return tmp.to_csr()
 *     def thresholds_norm(self, perc):
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->mat->rightColumns[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        if (unlikely(__pyx_v_marg_l == 0)) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
          #endif
          PyErr_SetString(PyExc_ZeroDivisionError, "float division");
          #ifdef WITH_THREAD
          PyGILState_Release(__pyx_gilstate_save);
          #endif
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_13 = PyFloat_FromDouble((__pyx_v_v / __pyx_v_marg_l)); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_14 = NULL;
        __pyx_t_15 = 0;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_14)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_14);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
            __pyx_t_15 = 1;
          }
        }
        __pyx_t_16 = PyTuple_New(3+__pyx_t_15); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_16);
        if (__pyx_t_14) {
          PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); __pyx_t_14 = NULL;
        }
        PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_15, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_15, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_16, 2+__pyx_t_15, __pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_13);
        __pyx_t_3 = 0;
        __pyx_t_4 = 0;
        __pyx_t_13 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_16, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L8;
      }
      __pyx_L8:;
    }
  }

  /* "lurrn/sparsmat.pyx":252
 *                if v>0:
 *                    tmp.add_count(k,self.mat.rightColumns[i],v/marg_l)
 *         return tmp.to_csr()             # <<<<<<<<<<<<<<
 *     def thresholds_norm(self, perc):
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] means
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp->__pyx_vtab)->to_csr(__pyx_v_tmp, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":233
 *                        tmp.add_count(k,self.mat.rightColumns[i],ll)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_l1(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 *         cdef VecD2 tmp=VecD2()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_16);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.transform_l1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_l);
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_29transform_l1(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_29transform_l1(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("transform_l1 (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_28transform_l1(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_28transform_l1(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_l1", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_transform_l1(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.transform_l1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":253
 *                    tmp.add_count(k,self.mat.rightColumns[i],v/marg_l)
 *         return tmp.to_csr()
 *     def thresholds_norm(self, perc):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] means
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] squared_means
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_31thresholds_norm(PyObject *__pyx_v_self, PyObject *__pyx_v_perc); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_31thresholds_norm(PyObject *__pyx_v_self, PyObject *__pyx_v_perc) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("thresholds_norm (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_30thresholds_norm(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self), ((PyObject *)__pyx_v_perc));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_30thresholds_norm(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_perc) {
  PyArrayObject *__pyx_v_means = 0;
  PyArrayObject *__pyx_v_squared_means = 0;
  PyArrayObject *__pyx_v_stddev = 0;
  double __pyx_v_zscore;
  int __pyx_v_count_targets;
  int __pyx_v_count_all;
  double __pyx_v_corr_factor;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_means;
  __Pyx_Buffer __pyx_pybuffer_means;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_squared_means;
  __Pyx_Buffer __pyx_pybuffer_squared_means;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_stddev;
  __Pyx_Buffer __pyx_pybuffer_stddev;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  double __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyArrayObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyArrayObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyArrayObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("thresholds_norm", 0);
  __pyx_pybuffer_means.pybuffer.buf = NULL;
  __pyx_pybuffer_means.refcount = 0;
  __pyx_pybuffernd_means.data = NULL;
  __pyx_pybuffernd_means.rcbuffer = &__pyx_pybuffer_means;
  __pyx_pybuffer_squared_means.pybuffer.buf = NULL;
  __pyx_pybuffer_squared_means.refcount = 0;
  __pyx_pybuffernd_squared_means.data = NULL;
  __pyx_pybuffernd_squared_means.rcbuffer = &__pyx_pybuffer_squared_means;
  __pyx_pybuffer_stddev.pybuffer.buf = NULL;
  __pyx_pybuffer_stddev.refcount = 0;
  __pyx_pybuffernd_stddev.data = NULL;
  __pyx_pybuffernd_stddev.rcbuffer = &__pyx_pybuffer_stddev;

  /* "lurrn/sparsmat.pyx":257
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] squared_means
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] stddev
 *         cdef double zscore=inverse_erf(2.0*perc-1.0)             # <<<<<<<<<<<<<<
 *         cdef int count_targets
 *         cdef int count_all=self.get_maxcol()+1
 */
  __pyx_t_1 = PyNumber_Multiply(__pyx_float_2_0, __pyx_v_perc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_float_1_0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_3 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_zscore = inverse_erf(__pyx_t_3);

  /* "lurrn/sparsmat.pyx":259
 *         cdef double zscore=inverse_erf(2.0*perc-1.0)
 *         cdef int count_targets
 *         cdef int count_all=self.get_maxcol()+1             # <<<<<<<<<<<<<<
 *         cdef double corr_factor = count_all / (count_all - 1.0)
 *         count_targets=len(self)
 */
  __pyx_v_count_all = (((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0) + 1);

  /* "lurrn/sparsmat.pyx":260
 *         cdef int count_targets
 *         cdef int count_all=self.get_maxcol()+1
 *         cdef double corr_factor = count_all / (count_all - 1.0)             # <<<<<<<<<<<<<<
 *         count_targets=len(self)
 *         means=self.right_marginals()
 */
  __pyx_t_3 = (__pyx_v_count_all - 1.0);
  if (unlikely(__pyx_t_3 == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_corr_factor = (__pyx_v_count_all / __pyx_t_3);

  /* "lurrn/sparsmat.pyx":261
 *         cdef int count_all=self.get_maxcol()+1
 *         cdef double corr_factor = count_all / (count_all - 1.0)
 *         count_targets=len(self)             # <<<<<<<<<<<<<<
 *         means=self.right_marginals()
 *         means /= count_targets
 */
  __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_count_targets = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":262
 *         cdef double corr_factor = count_all / (count_all - 1.0)
 *         count_targets=len(self)
 *         means=self.right_marginals()             # <<<<<<<<<<<<<<
 *         means /= count_targets
 *         squared_means = self.right_squared_marginals()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_right_marginals); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_means.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_means.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_means.rcbuffer->pybuffer, (PyObject*)__pyx_v_means, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_means.diminfo[0].strides = __pyx_pybuffernd_means.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_means.diminfo[0].shape = __pyx_pybuffernd_means.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = 0;
  __pyx_v_means = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":263
 *         count_targets=len(self)
 *         means=self.right_marginals()
 *         means /= count_targets             # <<<<<<<<<<<<<<
 *         squared_means = self.right_squared_marginals()
 *         squared_means /= count_targets
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_count_targets); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyNumber_InPlaceDivide(((PyObject *)__pyx_v_means), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_means.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_means.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_means.rcbuffer->pybuffer, (PyObject*)__pyx_v_means, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
      }
    }
    __pyx_pybuffernd_means.diminfo[0].strides = __pyx_pybuffernd_means.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_means.diminfo[0].shape = __pyx_pybuffernd_means.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = 0;
  __Pyx_DECREF_SET(__pyx_v_means, ((PyArrayObject *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":264
 *         means=self.right_marginals()
 *         means /= count_targets
 *         squared_means = self.right_squared_marginals()             # <<<<<<<<<<<<<<
 *         squared_means /= count_targets
 *         stddev=numpy.sqrt(corr_factor * (squared_means - means*means))
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_right_squared_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer, (PyObject*)__pyx_v_squared_means, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_squared_means.diminfo[0].strides = __pyx_pybuffernd_squared_means.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_squared_means.diminfo[0].shape = __pyx_pybuffernd_squared_means.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_11 = 0;
  __pyx_v_squared_means = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":265
 *         means /= count_targets
 *         squared_means = self.right_squared_marginals()
 *         squared_means /= count_targets             # <<<<<<<<<<<<<<
 *         stddev=numpy.sqrt(corr_factor * (squared_means - means*means))
 *         return means + zscore * stddev
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_count_targets); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyNumber_InPlaceDivide(((PyObject *)__pyx_v_squared_means), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer, (PyObject*)__pyx_v_squared_means, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
      }
    }
    __pyx_pybuffernd_squared_means.diminfo[0].strides = __pyx_pybuffernd_squared_means.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_squared_means.diminfo[0].shape = __pyx_pybuffernd_squared_means.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_11 = 0;
  __Pyx_DECREF_SET(__pyx_v_squared_means, ((PyArrayObject *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":266
 *         squared_means = self.right_squared_marginals()
 *         squared_means /= count_targets
 *         stddev=numpy.sqrt(corr_factor * (squared_means - means*means))             # <<<<<<<<<<<<<<
 *         return means + zscore * stddev
 *     def thresholds_quantile(self, perc):
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_corr_factor); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_12 = PyNumber_Multiply(((PyObject *)__pyx_v_means), ((PyObject *)__pyx_v_means)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = PyNumber_Subtract(((PyObject *)__pyx_v_squared_means), __pyx_t_12); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = PyNumber_Multiply(__pyx_t_1, __pyx_t_13); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_13) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_12); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_13); __Pyx_GIVEREF(__pyx_t_13); __pyx_t_13 = NULL;
    PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_stddev.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_stddev.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_stddev.rcbuffer->pybuffer, (PyObject*)__pyx_v_stddev, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_stddev.diminfo[0].strides = __pyx_pybuffernd_stddev.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_stddev.diminfo[0].shape = __pyx_pybuffernd_stddev.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_14 = 0;
  __pyx_v_stddev = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":267
 *         squared_means /= count_targets
 *         stddev=numpy.sqrt(corr_factor * (squared_means - means*means))
 *         return means + zscore * stddev             # <<<<<<<<<<<<<<
 *     def thresholds_quantile(self, perc):
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] results
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_zscore); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = PyNumber_Multiply(__pyx_t_2, ((PyObject *)__pyx_v_stddev)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_v_means), __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":253
 *                    tmp.add_count(k,self.mat.rightColumns[i],v/marg_l)
 *         return tmp.to_csr()
 *     def thresholds_norm(self, perc):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] means
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] squared_means
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_means.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_stddev.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.thresholds_norm", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_means.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_stddev.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_means);
  __Pyx_XDECREF((PyObject *)__pyx_v_squared_means);
  __Pyx_XDECREF((PyObject *)__pyx_v_stddev);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":268
 *         stddev=numpy.sqrt(corr_factor * (squared_means - means*means))
 *         return means + zscore * stddev
 *     def thresholds_quantile(self, perc):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] results
 *         cdef int i, count_nz, offset, abs_offset
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_33thresholds_quantile(PyObject *__pyx_v_self, PyObject *__pyx_v_perc); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_33thresholds_quantile(PyObject *__pyx_v_self, PyObject *__pyx_v_perc) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("thresholds_quantile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_32thresholds_quantile(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self), ((PyObject *)__pyx_v_perc));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_32thresholds_quantile(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_perc) {
  PyArrayObject *__pyx_v_results = 0;
  int __pyx_v_i;
  int __pyx_v_count_nz;
  int __pyx_v_offset;
  int __pyx_v_abs_offset;
  CYTHON_UNUSED int __pyx_v_count_targets;
  CYTHON_UNUSED int __pyx_v_count_all;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_nonzeros = 0;
  PyObject *__pyx_v_count_features = NULL;
  PyObject *__pyx_v_nz_vals = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_v = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_results;
  __Pyx_Buffer __pyx_pybuffer_results;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyArrayObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *__pyx_t_14 = NULL;
  PyObject *(*__pyx_t_15)(PyObject *);
  int __pyx_t_16;
  __pyx_t_5numpy_int32_t __pyx_t_17;
  int __pyx_t_18;
  int __pyx_t_19;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("thresholds_quantile", 0);
  __pyx_pybuffer_results.pybuffer.buf = NULL;
  __pyx_pybuffer_results.refcount = 0;
  __pyx_pybuffernd_results.data = NULL;
  __pyx_pybuffernd_results.rcbuffer = &__pyx_pybuffer_results;

  /* "lurrn/sparsmat.pyx":272
 *         cdef int i, count_nz, offset, abs_offset
 *         cdef int count_targets
 *         cdef int count_all=self.get_maxcol()+1             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixD nonzeros=self.transpose()
 *         count_targets=len(self)
 */
  __pyx_v_count_all = (((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0) + 1);

  /* "lurrn/sparsmat.pyx":273
 *         cdef int count_targets
 *         cdef int count_all=self.get_maxcol()+1
 *         cdef CSRMatrixD nonzeros=self.transpose()             # <<<<<<<<<<<<<<
 *         count_targets=len(self)
 *         count_features=len(nonzeros)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transpose); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_nonzeros = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":274
 *         cdef int count_all=self.get_maxcol()+1
 *         cdef CSRMatrixD nonzeros=self.transpose()
 *         count_targets=len(self)             # <<<<<<<<<<<<<<
 *         count_features=len(nonzeros)
 *         results=numpy.zeros(count_features,numpy.int32)
 */
  __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_count_targets = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":275
 *         cdef CSRMatrixD nonzeros=self.transpose()
 *         count_targets=len(self)
 *         count_features=len(nonzeros)             # <<<<<<<<<<<<<<
 *         results=numpy.zeros(count_features,numpy.int32)
 *         abs_offset=count_features*(1.0-perc)+0.5
 */
  __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_nonzeros)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_count_features = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":276
 *         count_targets=len(self)
 *         count_features=len(nonzeros)
 *         results=numpy.zeros(count_features,numpy.int32)             # <<<<<<<<<<<<<<
 *         abs_offset=count_features*(1.0-perc)+0.5
 *         if abs_offset==0:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_v_count_features);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_4, __pyx_v_count_features);
  __Pyx_GIVEREF(__pyx_v_count_features);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_4, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
    __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_results.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_8 < 0)) {
      PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_results.rcbuffer->pybuffer, (PyObject*)__pyx_v_results, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
    }
    __pyx_pybuffernd_results.diminfo[0].strides = __pyx_pybuffernd_results.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_results.diminfo[0].shape = __pyx_pybuffernd_results.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_7 = 0;
  __pyx_v_results = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":277
 *         count_features=len(nonzeros)
 *         results=numpy.zeros(count_features,numpy.int32)
 *         abs_offset=count_features*(1.0-perc)+0.5             # <<<<<<<<<<<<<<
 *         if abs_offset==0:
 *             abs_offset=1
 */
  __pyx_t_1 = PyNumber_Subtract(__pyx_float_1_0, __pyx_v_perc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyNumber_Multiply(__pyx_v_count_features, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_float_0_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_abs_offset = __pyx_t_8;

  /* "lurrn/sparsmat.pyx":278
 *         results=numpy.zeros(count_features,numpy.int32)
 *         abs_offset=count_features*(1.0-perc)+0.5
 *         if abs_offset==0:             # <<<<<<<<<<<<<<
 *             abs_offset=1
 *         for i from 0<=i<count_features:
 */
  __pyx_t_12 = ((__pyx_v_abs_offset == 0) != 0);
  if (__pyx_t_12) {

    /* "lurrn/sparsmat.pyx":279
 *         abs_offset=count_features*(1.0-perc)+0.5
 *         if abs_offset==0:
 *             abs_offset=1             # <<<<<<<<<<<<<<
 *         for i from 0<=i<count_features:
 *             nz_vals=[v for k,v in nonzeros[i]]
 */
    __pyx_v_abs_offset = 1;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":280
 *         if abs_offset==0:
 *             abs_offset=1
 *         for i from 0<=i<count_features:             # <<<<<<<<<<<<<<
 *             nz_vals=[v for k,v in nonzeros[i]]
 *             nz_vals.sort()
 */
  __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_count_features); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":281
 *             abs_offset=1
 *         for i from 0<=i<count_features:
 *             nz_vals=[v for k,v in nonzeros[i]]             # <<<<<<<<<<<<<<
 *             nz_vals.sort()
 *             count_nz=len(nz_vals)
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_v_nonzeros), __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_6 = __pyx_t_3; __Pyx_INCREF(__pyx_t_6); __pyx_t_4 = 0;
      __pyx_t_13 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_13 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (likely(!__pyx_t_13)) {
        if (likely(PyList_CheckExact(__pyx_t_6))) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_13(__pyx_t_6);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
        PyObject* sequence = __pyx_t_3;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_2);
        #else
        __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_14 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_15 = Py_TYPE(__pyx_t_14)->tp_iternext;
        index = 0; __pyx_t_5 = __pyx_t_15(__pyx_t_14); if (unlikely(!__pyx_t_5)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        index = 1; __pyx_t_2 = __pyx_t_15(__pyx_t_14); if (unlikely(!__pyx_t_2)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_14), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_15 = NULL;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        goto __pyx_L9_unpacking_done;
        __pyx_L8_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_15 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L9_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_5);
      __pyx_t_5 = 0;
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_2);
      __pyx_t_2 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_v_v))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_nz_vals, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":282
 *         for i from 0<=i<count_features:
 *             nz_vals=[v for k,v in nonzeros[i]]
 *             nz_vals.sort()             # <<<<<<<<<<<<<<
 *             count_nz=len(nz_vals)
 *             offset=count_nz-abs_offset
 */
    __pyx_t_16 = PyList_Sort(__pyx_v_nz_vals); if (unlikely(__pyx_t_16 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lurrn/sparsmat.pyx":283
 *             nz_vals=[v for k,v in nonzeros[i]]
 *             nz_vals.sort()
 *             count_nz=len(nz_vals)             # <<<<<<<<<<<<<<
 *             offset=count_nz-abs_offset
 *             if offset<0:
 */
    __pyx_t_4 = PyList_GET_SIZE(__pyx_v_nz_vals); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_count_nz = __pyx_t_4;

    /* "lurrn/sparsmat.pyx":284
 *             nz_vals.sort()
 *             count_nz=len(nz_vals)
 *             offset=count_nz-abs_offset             # <<<<<<<<<<<<<<
 *             if offset<0:
 *                 offset=0
 */
    __pyx_v_offset = (__pyx_v_count_nz - __pyx_v_abs_offset);

    /* "lurrn/sparsmat.pyx":285
 *             count_nz=len(nz_vals)
 *             offset=count_nz-abs_offset
 *             if offset<0:             # <<<<<<<<<<<<<<
 *                 offset=0
 *             results[i] = nz_vals[offset]
 */
    __pyx_t_12 = ((__pyx_v_offset < 0) != 0);
    if (__pyx_t_12) {

      /* "lurrn/sparsmat.pyx":286
 *             offset=count_nz-abs_offset
 *             if offset<0:
 *                 offset=0             # <<<<<<<<<<<<<<
 *             results[i] = nz_vals[offset]
 *         return results
 */
      __pyx_v_offset = 0;
      goto __pyx_L10;
    }
    __pyx_L10:;

    /* "lurrn/sparsmat.pyx":287
 *             if offset<0:
 *                 offset=0
 *             results[i] = nz_vals[offset]             # <<<<<<<<<<<<<<
 *         return results
 *     def thresholds_nonzero(self, perc):
 */
    __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_nz_vals, __pyx_v_offset, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_17 = __Pyx_PyInt_As_npy_int32(__pyx_t_1); if (unlikely((__pyx_t_17 == (npy_int32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_18 = __pyx_v_i;
    __pyx_t_19 = -1;
    if (__pyx_t_18 < 0) {
      __pyx_t_18 += __pyx_pybuffernd_results.diminfo[0].shape;
      if (unlikely(__pyx_t_18 < 0)) __pyx_t_19 = 0;
    } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_results.diminfo[0].shape)) __pyx_t_19 = 0;
    if (unlikely(__pyx_t_19 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_19);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_results.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_results.diminfo[0].strides) = __pyx_t_17;
  }

  /* "lurrn/sparsmat.pyx":288
 *                 offset=0
 *             results[i] = nz_vals[offset]
 *         return results             # <<<<<<<<<<<<<<
 *     def thresholds_nonzero(self, perc):
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] results
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_results));
  __pyx_r = ((PyObject *)__pyx_v_results);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":268
 *         stddev=numpy.sqrt(corr_factor * (squared_means - means*means))
 *         return means + zscore * stddev
 *     def thresholds_quantile(self, perc):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] results
 *         cdef int i, count_nz, offset, abs_offset
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_14);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.thresholds_quantile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_results);
  __Pyx_XDECREF((PyObject *)__pyx_v_nonzeros);
  __Pyx_XDECREF(__pyx_v_count_features);
  __Pyx_XDECREF(__pyx_v_nz_vals);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":289
 *             results[i] = nz_vals[offset]
 *         return results
 *     def thresholds_nonzero(self, perc):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] results
 *         cdef int i
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_35thresholds_nonzero(PyObject *__pyx_v_self, PyObject *__pyx_v_perc); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_35thresholds_nonzero(PyObject *__pyx_v_self, PyObject *__pyx_v_perc) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("thresholds_nonzero (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_34thresholds_nonzero(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self), ((PyObject *)__pyx_v_perc));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_34thresholds_nonzero(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_perc) {
  PyArrayObject *__pyx_v_results = 0;
  int __pyx_v_i;
  int __pyx_v_count_all;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_nonzeros = 0;
  PyObject *__pyx_v_nz_vals = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_v = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_results;
  __Pyx_Buffer __pyx_pybuffer_results;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *(*__pyx_t_14)(PyObject *);
  int __pyx_t_15;
  __pyx_t_5numpy_int32_t __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("thresholds_nonzero", 0);
  __pyx_pybuffer_results.pybuffer.buf = NULL;
  __pyx_pybuffer_results.refcount = 0;
  __pyx_pybuffernd_results.data = NULL;
  __pyx_pybuffernd_results.rcbuffer = &__pyx_pybuffer_results;

  /* "lurrn/sparsmat.pyx":292
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] results
 *         cdef int i
 *         cdef int count_all=self.get_maxcol()+1             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixD nonzeros=self.transpose()
 *         results=numpy.zeros(count_all,numpy.int32)
 */
  __pyx_v_count_all = (((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0) + 1);

  /* "lurrn/sparsmat.pyx":293
 *         cdef int i
 *         cdef int count_all=self.get_maxcol()+1
 *         cdef CSRMatrixD nonzeros=self.transpose()             # <<<<<<<<<<<<<<
 *         results=numpy.zeros(count_all,numpy.int32)
 *         for i from 0<=i<count_all:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transpose); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_nonzeros = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":294
 *         cdef int count_all=self.get_maxcol()+1
 *         cdef CSRMatrixD nonzeros=self.transpose()
 *         results=numpy.zeros(count_all,numpy.int32)             # <<<<<<<<<<<<<<
 *         for i from 0<=i<count_all:
 *             nz_vals=[v for k,v in nonzeros[i]]
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_count_all); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_results.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_results.rcbuffer->pybuffer, (PyObject*)__pyx_v_results, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_results.diminfo[0].strides = __pyx_pybuffernd_results.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_results.diminfo[0].shape = __pyx_pybuffernd_results.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __pyx_v_results = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":295
 *         cdef CSRMatrixD nonzeros=self.transpose()
 *         results=numpy.zeros(count_all,numpy.int32)
 *         for i from 0<=i<count_all:             # <<<<<<<<<<<<<<
 *             nz_vals=[v for k,v in nonzeros[i]]
 *             nz_vals.sort()
 */
  __pyx_t_9 = __pyx_v_count_all;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":296
 *         results=numpy.zeros(count_all,numpy.int32)
 *         for i from 0<=i<count_all:
 *             nz_vals=[v for k,v in nonzeros[i]]             # <<<<<<<<<<<<<<
 *             nz_vals.sort()
 *             results[i] = nz_vals[int(len(nz_vals)*perc)]
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_v_nonzeros), __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_7 = __pyx_t_3; __Pyx_INCREF(__pyx_t_7); __pyx_t_6 = 0;
      __pyx_t_13 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_13 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (likely(!__pyx_t_13)) {
        if (likely(PyList_CheckExact(__pyx_t_7))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_7, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_7, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_13(__pyx_t_7);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
        PyObject* sequence = __pyx_t_3;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_2);
        #else
        __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_14 = Py_TYPE(__pyx_t_4)->tp_iternext;
        index = 0; __pyx_t_5 = __pyx_t_14(__pyx_t_4); if (unlikely(!__pyx_t_5)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        index = 1; __pyx_t_2 = __pyx_t_14(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_14 = NULL;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L8_unpacking_done;
        __pyx_L7_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_14 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L8_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_5);
      __pyx_t_5 = 0;
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_2);
      __pyx_t_2 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_v_v))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF_SET(__pyx_v_nz_vals, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":297
 *         for i from 0<=i<count_all:
 *             nz_vals=[v for k,v in nonzeros[i]]
 *             nz_vals.sort()             # <<<<<<<<<<<<<<
 *             results[i] = nz_vals[int(len(nz_vals)*perc)]
 *         return results
 */
    __pyx_t_15 = PyList_Sort(__pyx_v_nz_vals); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lurrn/sparsmat.pyx":298
 *             nz_vals=[v for k,v in nonzeros[i]]
 *             nz_vals.sort()
 *             results[i] = nz_vals[int(len(nz_vals)*perc)]             # <<<<<<<<<<<<<<
 *         return results
 *     def get_quantiles(self, qs):
 */
    __pyx_t_6 = PyList_GET_SIZE(__pyx_v_nz_vals); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = PyNumber_Multiply(__pyx_t_1, __pyx_v_perc); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Int(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyObject_GetItem(__pyx_v_nz_vals, __pyx_t_1); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_16 = __Pyx_PyInt_As_npy_int32(__pyx_t_7); if (unlikely((__pyx_t_16 == (npy_int32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_17 = __pyx_v_i;
    __pyx_t_18 = -1;
    if (__pyx_t_17 < 0) {
      __pyx_t_17 += __pyx_pybuffernd_results.diminfo[0].shape;
      if (unlikely(__pyx_t_17 < 0)) __pyx_t_18 = 0;
    } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_results.diminfo[0].shape)) __pyx_t_18 = 0;
    if (unlikely(__pyx_t_18 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_18);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_results.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_results.diminfo[0].strides) = __pyx_t_16;
  }

  /* "lurrn/sparsmat.pyx":299
 *             nz_vals.sort()
 *             results[i] = nz_vals[int(len(nz_vals)*perc)]
 *         return results             # <<<<<<<<<<<<<<
 *     def get_quantiles(self, qs):
 *         cdef coordinate_t k, nnz
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_results));
  __pyx_r = ((PyObject *)__pyx_v_results);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":289
 *             results[i] = nz_vals[offset]
 *         return results
 *     def thresholds_nonzero(self, perc):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] results
 *         cdef int i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.thresholds_nonzero", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_results);
  __Pyx_XDECREF((PyObject *)__pyx_v_nonzeros);
  __Pyx_XDECREF(__pyx_v_nz_vals);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":300
 *             results[i] = nz_vals[int(len(nz_vals)*perc)]
 *         return results
 *     def get_quantiles(self, qs):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, nnz
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] allvals
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_37get_quantiles(PyObject *__pyx_v_self, PyObject *__pyx_v_qs); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_37get_quantiles(PyObject *__pyx_v_self, PyObject *__pyx_v_qs) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_quantiles (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_36get_quantiles(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self), ((PyObject *)__pyx_v_qs));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_36get_quantiles(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_qs) {
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_nnz;
  PyArrayObject *__pyx_v_allvals = 0;
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_q = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_allvals;
  __Pyx_Buffer __pyx_pybuffer_allvals;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  coordinate_t __pyx_t_13;
  int __pyx_t_14;
  PyObject *(*__pyx_t_15)(PyObject *);
  coordinate_t __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_quantiles", 0);
  __pyx_pybuffer_allvals.pybuffer.buf = NULL;
  __pyx_pybuffer_allvals.refcount = 0;
  __pyx_pybuffernd_allvals.data = NULL;
  __pyx_pybuffernd_allvals.rcbuffer = &__pyx_pybuffer_allvals;

  /* "lurrn/sparsmat.pyx":303
 *         cdef coordinate_t k, nnz
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] allvals
 *         nnz = self.mat.offsets[self.mat.num_rows]             # <<<<<<<<<<<<<<
 *         allvals = numpy.empty(self.mat.offsets[self.mat.num_rows],
 *                               numpy.int32)
 */
  __pyx_v_nnz = (__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]);

  /* "lurrn/sparsmat.pyx":304
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] allvals
 *         nnz = self.mat.offsets[self.mat.num_rows]
 *         allvals = numpy.empty(self.mat.offsets[self.mat.num_rows],             # <<<<<<<<<<<<<<
 *                               numpy.int32)
 *         for k from 0<=k<self.mat.offsets[self.mat.num_rows]:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "lurrn/sparsmat.pyx":305
 *         nnz = self.mat.offsets[self.mat.num_rows]
 *         allvals = numpy.empty(self.mat.offsets[self.mat.num_rows],
 *                               numpy.int32)             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.offsets[self.mat.num_rows]:
 *             allvals[k] = self.mat.values[k]
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "lurrn/sparsmat.pyx":304
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] allvals
 *         nnz = self.mat.offsets[self.mat.num_rows]
 *         allvals = numpy.empty(self.mat.offsets[self.mat.num_rows],             # <<<<<<<<<<<<<<
 *                               numpy.int32)
 *         for k from 0<=k<self.mat.offsets[self.mat.num_rows]:
 */
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_allvals.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_allvals.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_allvals.rcbuffer->pybuffer, (PyObject*)__pyx_v_allvals, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_allvals.diminfo[0].strides = __pyx_pybuffernd_allvals.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_allvals.diminfo[0].shape = __pyx_pybuffernd_allvals.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __pyx_v_allvals = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":306
 *         allvals = numpy.empty(self.mat.offsets[self.mat.num_rows],
 *                               numpy.int32)
 *         for k from 0<=k<self.mat.offsets[self.mat.num_rows]:             # <<<<<<<<<<<<<<
 *             allvals[k] = self.mat.values[k]
 *         allvals.sort()
 */
  __pyx_t_9 = (__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]);
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_9; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":307
 *                               numpy.int32)
 *         for k from 0<=k<self.mat.offsets[self.mat.num_rows]:
 *             allvals[k] = self.mat.values[k]             # <<<<<<<<<<<<<<
 *         allvals.sort()
 *         result = []
 */
    __pyx_t_13 = __pyx_v_k;
    __pyx_t_14 = -1;
    if (unlikely(__pyx_t_13 >= (size_t)__pyx_pybuffernd_allvals.diminfo[0].shape)) __pyx_t_14 = 0;
    if (unlikely(__pyx_t_14 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_14);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_allvals.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_allvals.diminfo[0].strides) = (__pyx_v_self->mat->values[__pyx_v_k]);
  }

  /* "lurrn/sparsmat.pyx":308
 *         for k from 0<=k<self.mat.offsets[self.mat.num_rows]:
 *             allvals[k] = self.mat.values[k]
 *         allvals.sort()             # <<<<<<<<<<<<<<
 *         result = []
 *         for q in qs:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_allvals), __pyx_n_s_sort); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_7) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":309
 *             allvals[k] = self.mat.values[k]
 *         allvals.sort()
 *         result = []             # <<<<<<<<<<<<<<
 *         for q in qs:
 *             k = nnz*q
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":310
 *         allvals.sort()
 *         result = []
 *         for q in qs:             # <<<<<<<<<<<<<<
 *             k = nnz*q
 *             if k >= nnz:
 */
  if (likely(PyList_CheckExact(__pyx_v_qs)) || PyTuple_CheckExact(__pyx_v_qs)) {
    __pyx_t_1 = __pyx_v_qs; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_15 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_qs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_15 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_15)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_15(__pyx_t_1);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_q, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "lurrn/sparsmat.pyx":311
 *         result = []
 *         for q in qs:
 *             k = nnz*q             # <<<<<<<<<<<<<<
 *             if k >= nnz:
 *                 k = nnz-1
 */
    __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_nnz); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = PyNumber_Multiply(__pyx_t_3, __pyx_v_q); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_16 = __Pyx_PyInt_As_coordinate_t(__pyx_t_7); if (unlikely((__pyx_t_16 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_k = __pyx_t_16;

    /* "lurrn/sparsmat.pyx":312
 *         for q in qs:
 *             k = nnz*q
 *             if k >= nnz:             # <<<<<<<<<<<<<<
 *                 k = nnz-1
 *             result.append(allvals[k])
 */
    __pyx_t_17 = ((__pyx_v_k >= __pyx_v_nnz) != 0);
    if (__pyx_t_17) {

      /* "lurrn/sparsmat.pyx":313
 *             k = nnz*q
 *             if k >= nnz:
 *                 k = nnz-1             # <<<<<<<<<<<<<<
 *             result.append(allvals[k])
 *         return result
 */
      __pyx_v_k = (__pyx_v_nnz - 1);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "lurrn/sparsmat.pyx":314
 *             if k >= nnz:
 *                 k = nnz-1
 *             result.append(allvals[k])             # <<<<<<<<<<<<<<
 *         return result
 *     cpdef CSRMatrixI apply_threshold(self, numpy.ndarray thr):
 */
    __pyx_t_16 = __pyx_v_k;
    __pyx_t_9 = -1;
    if (unlikely(__pyx_t_16 >= (size_t)__pyx_pybuffernd_allvals.diminfo[0].shape)) __pyx_t_9 = 0;
    if (unlikely(__pyx_t_9 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_9);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_7 = __Pyx_PyInt_From_npy_int32((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_allvals.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_allvals.diminfo[0].strides))); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_18 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "lurrn/sparsmat.pyx":310
 *         allvals.sort()
 *         result = []
 *         for q in qs:             # <<<<<<<<<<<<<<
 *             k = nnz*q
 *             if k >= nnz:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":315
 *                 k = nnz-1
 *             result.append(allvals[k])
 *         return result             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixI apply_threshold(self, numpy.ndarray thr):
 *         cdef VecD2 tmp=VecD2()
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":300
 *             results[i] = nz_vals[int(len(nz_vals)*perc)]
 *         return results
 *     def get_quantiles(self, qs):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, nnz
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] allvals
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_allvals.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.get_quantiles", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_allvals.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_allvals);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_q);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":316
 *             result.append(allvals[k])
 *         return result
 *     cpdef CSRMatrixI apply_threshold(self, numpy.ndarray thr):             # <<<<<<<<<<<<<<
 *         cdef VecD2 tmp=VecD2()
 *         cdef coordinate_t k, i, k2
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_39apply_threshold(PyObject *__pyx_v_self, PyObject *__pyx_v_thr); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_apply_threshold(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyArrayObject *__pyx_v_thr, int __pyx_skip_dispatch) {
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp = 0;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_k2;
  int __pyx_v_off1;
  int __pyx_v_off2;
  double __pyx_v_v;
  PyArrayObject *__pyx_v_thresholds = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_thresholds;
  __Pyx_Buffer __pyx_pybuffer_thresholds;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  coordinate_t __pyx_t_7;
  int __pyx_t_8;
  coordinate_t __pyx_t_9;
  int __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("apply_threshold", 0);
  __pyx_pybuffer_thresholds.pybuffer.buf = NULL;
  __pyx_pybuffer_thresholds.refcount = 0;
  __pyx_pybuffernd_thresholds.data = NULL;
  __pyx_pybuffernd_thresholds.rcbuffer = &__pyx_pybuffer_thresholds;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_apply_threshold); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_39apply_threshold)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_thr)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_thr));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_thr));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_thr));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":317
 *         return result
 *     cpdef CSRMatrixI apply_threshold(self, numpy.ndarray thr):
 *         cdef VecD2 tmp=VecD2()             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, i, k2
 *         cdef int off1, off2
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":321
 *         cdef int off1, off2
 *         cdef double v, marg_l
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] thresholds=thr             # <<<<<<<<<<<<<<
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 */
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_thresholds.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_thr), &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_thresholds = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_thresholds.diminfo[0].strides = __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_thresholds.diminfo[0].shape = __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.shape[0];
    }
  }
  __Pyx_INCREF(((PyObject *)__pyx_v_thr));
  __pyx_v_thresholds = ((PyArrayObject *)__pyx_v_thr);

  /* "lurrn/sparsmat.pyx":322
 *         cdef double v, marg_l
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] thresholds=thr
 *         if self.mat.num_rows<100000:             # <<<<<<<<<<<<<<
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 */
  __pyx_t_6 = ((__pyx_v_self->mat->num_rows < 100000) != 0);
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":323
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] thresholds=thr
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         else:
 *             tmp.vec.reserve(100000)
 */
    __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":325
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 *             tmp.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.num_rows:
 *             off1=self.mat.offsets[k]
 */
    __pyx_v_tmp->vec.reserve(100000);
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":326
 *         else:
 *             tmp.vec.reserve(100000)
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 */
  __pyx_t_7 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_7; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":327
 *             tmp.vec.reserve(100000)
 *         for k from 0<=k<self.mat.num_rows:
 *             off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":328
 *         for k from 0<=k<self.mat.num_rows:
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":329
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                v=self.mat.values[i]
 *                k2=self.mat.rightColumns[i]
 */
    __pyx_t_8 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":330
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]             # <<<<<<<<<<<<<<
 *                k2=self.mat.rightColumns[i]
 *                if v>=thresholds[k2]:
 */
      __pyx_v_v = (__pyx_v_self->mat->values[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":331
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 *                k2=self.mat.rightColumns[i]             # <<<<<<<<<<<<<<
 *                if v>=thresholds[k2]:
 *                    tmp.add_count(k,k2,1.0)
 */
      __pyx_v_k2 = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":332
 *                v=self.mat.values[i]
 *                k2=self.mat.rightColumns[i]
 *                if v>=thresholds[k2]:             # <<<<<<<<<<<<<<
 *                    tmp.add_count(k,k2,1.0)
 *         return tmp.to_csr()
 */
      __pyx_t_9 = __pyx_v_k2;
      __pyx_t_10 = -1;
      if (unlikely(__pyx_t_9 >= (size_t)__pyx_pybuffernd_thresholds.diminfo[0].shape)) __pyx_t_10 = 0;
      if (unlikely(__pyx_t_10 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_10);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = ((__pyx_v_v >= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_thresholds.diminfo[0].strides))) != 0);
      if (__pyx_t_6) {

        /* "lurrn/sparsmat.pyx":333
 *                k2=self.mat.rightColumns[i]
 *                if v>=thresholds[k2]:
 *                    tmp.add_count(k,k2,1.0)             # <<<<<<<<<<<<<<
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD apply_scaling(self, numpy.ndarray thr):
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_5 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = NULL;
        __pyx_t_11 = 0;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
            __pyx_t_11 = 1;
          }
        }
        __pyx_t_12 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        if (__pyx_t_4) {
          PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        }
        PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_float_1_0);
        PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_11, __pyx_float_1_0);
        __Pyx_GIVEREF(__pyx_float_1_0);
        __pyx_t_3 = 0;
        __pyx_t_5 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L8;
      }
      __pyx_L8:;
    }
  }

  /* "lurrn/sparsmat.pyx":334
 *                if v>=thresholds[k2]:
 *                    tmp.add_count(k,k2,1.0)
 *         return tmp.to_csr()             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixD apply_scaling(self, numpy.ndarray thr):
 *         cdef VecD2 tmp=VecD2()
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp->__pyx_vtab)->to_csr(__pyx_v_tmp, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":316
 *             result.append(allvals[k])
 *         return result
 *     cpdef CSRMatrixI apply_threshold(self, numpy.ndarray thr):             # <<<<<<<<<<<<<<
 *         cdef VecD2 tmp=VecD2()
 *         cdef coordinate_t k, i, k2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_12);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_thresholds.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.apply_threshold", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_thresholds.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XDECREF((PyObject *)__pyx_v_thresholds);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_39apply_threshold(PyObject *__pyx_v_self, PyObject *__pyx_v_thr); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_39apply_threshold(PyObject *__pyx_v_self, PyObject *__pyx_v_thr) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("apply_threshold (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_thr), __pyx_ptype_5numpy_ndarray, 1, "thr", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_38apply_threshold(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self), ((PyArrayObject *)__pyx_v_thr));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_38apply_threshold(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyArrayObject *__pyx_v_thr) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("apply_threshold", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_apply_threshold(__pyx_v_self, __pyx_v_thr, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.apply_threshold", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":335
 *                    tmp.add_count(k,k2,1.0)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD apply_scaling(self, numpy.ndarray thr):             # <<<<<<<<<<<<<<
 *         cdef VecD2 tmp=VecD2()
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] thresholds=thr
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_41apply_scaling(PyObject *__pyx_v_self, PyObject *__pyx_v_thr); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_apply_scaling(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyArrayObject *__pyx_v_thr, int __pyx_skip_dispatch) {
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp = 0;
  PyArrayObject *__pyx_v_thresholds = 0;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_k2;
  int __pyx_v_off1;
  int __pyx_v_off2;
  double __pyx_v_v;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_thresholds;
  __Pyx_Buffer __pyx_pybuffer_thresholds;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  coordinate_t __pyx_t_7;
  int __pyx_t_8;
  coordinate_t __pyx_t_9;
  int __pyx_t_10;
  __pyx_t_5numpy_int32_t __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("apply_scaling", 0);
  __pyx_pybuffer_thresholds.pybuffer.buf = NULL;
  __pyx_pybuffer_thresholds.refcount = 0;
  __pyx_pybuffernd_thresholds.data = NULL;
  __pyx_pybuffernd_thresholds.rcbuffer = &__pyx_pybuffer_thresholds;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_apply_scaling); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_41apply_scaling)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_thr)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_thr));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_thr));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_thr));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":336
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD apply_scaling(self, numpy.ndarray thr):
 *         cdef VecD2 tmp=VecD2()             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] thresholds=thr
 *         cdef coordinate_t k, i, k2
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":337
 *     cpdef CSRMatrixD apply_scaling(self, numpy.ndarray thr):
 *         cdef VecD2 tmp=VecD2()
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] thresholds=thr             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, i, k2
 *         cdef int off1, off2
 */
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_thresholds.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_thr), &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_thresholds = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_thresholds.diminfo[0].strides = __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_thresholds.diminfo[0].shape = __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.shape[0];
    }
  }
  __Pyx_INCREF(((PyObject *)__pyx_v_thr));
  __pyx_v_thresholds = ((PyArrayObject *)__pyx_v_thr);

  /* "lurrn/sparsmat.pyx":341
 *         cdef int off1, off2
 *         cdef double v, marg_l
 *         if self.mat.num_rows<100000:             # <<<<<<<<<<<<<<
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 */
  __pyx_t_6 = ((__pyx_v_self->mat->num_rows < 100000) != 0);
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":342
 *         cdef double v, marg_l
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         else:
 *             tmp.vec.reserve(100000)
 */
    __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":344
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 *             tmp.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.num_rows:
 *             off1=self.mat.offsets[k]
 */
    __pyx_v_tmp->vec.reserve(100000);
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":345
 *         else:
 *             tmp.vec.reserve(100000)
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 */
  __pyx_t_7 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_7; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":346
 *             tmp.vec.reserve(100000)
 *         for k from 0<=k<self.mat.num_rows:
 *             off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":347
 *         for k from 0<=k<self.mat.num_rows:
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                k2=self.mat.rightColumns[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":348
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                k2=self.mat.rightColumns[i]
 *                v=self.mat.values[i]/thresholds[k2]
 */
    __pyx_t_8 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":349
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                k2=self.mat.rightColumns[i]             # <<<<<<<<<<<<<<
 *                v=self.mat.values[i]/thresholds[k2]
 *                if v>=1.0:
 */
      __pyx_v_k2 = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":350
 *             for i from off1<=i<off2:
 *                k2=self.mat.rightColumns[i]
 *                v=self.mat.values[i]/thresholds[k2]             # <<<<<<<<<<<<<<
 *                if v>=1.0:
 *                    tmp.add_count(k,k2,1.0)
 */
      __pyx_t_9 = __pyx_v_k2;
      __pyx_t_10 = -1;
      if (unlikely(__pyx_t_9 >= (size_t)__pyx_pybuffernd_thresholds.diminfo[0].shape)) __pyx_t_10 = 0;
      if (unlikely(__pyx_t_10 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_10);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_11 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_thresholds.diminfo[0].strides));
      if (unlikely(__pyx_t_11 == 0)) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
        #ifdef WITH_THREAD
        PyGILState_Release(__pyx_gilstate_save);
        #endif
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      else if (sizeof(int) == sizeof(long) && unlikely(__pyx_t_11 == -1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW((__pyx_v_self->mat->values[__pyx_v_i])))) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
        #ifdef WITH_THREAD
        PyGILState_Release(__pyx_gilstate_save);
        #endif
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_v_v = __Pyx_div_int((__pyx_v_self->mat->values[__pyx_v_i]), __pyx_t_11);

      /* "lurrn/sparsmat.pyx":351
 *                k2=self.mat.rightColumns[i]
 *                v=self.mat.values[i]/thresholds[k2]
 *                if v>=1.0:             # <<<<<<<<<<<<<<
 *                    tmp.add_count(k,k2,1.0)
 *                else:
 */
      __pyx_t_6 = ((__pyx_v_v >= 1.0) != 0);
      if (__pyx_t_6) {

        /* "lurrn/sparsmat.pyx":352
 *                v=self.mat.values[i]/thresholds[k2]
 *                if v>=1.0:
 *                    tmp.add_count(k,k2,1.0)             # <<<<<<<<<<<<<<
 *                else:
 *                    tmp.add_count(k,k2,v)
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_5 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = NULL;
        __pyx_t_12 = 0;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
            __pyx_t_12 = 1;
          }
        }
        __pyx_t_13 = PyTuple_New(3+__pyx_t_12); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_13);
        if (__pyx_t_4) {
          PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        }
        PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_float_1_0);
        PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_12, __pyx_float_1_0);
        __Pyx_GIVEREF(__pyx_float_1_0);
        __pyx_t_3 = 0;
        __pyx_t_5 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_13, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L8;
      }
      /*else*/ {

        /* "lurrn/sparsmat.pyx":354
 *                    tmp.add_count(k,k2,1.0)
 *                else:
 *                    tmp.add_count(k,k2,v)             # <<<<<<<<<<<<<<
 *         return tmp.to_csr()
 *     def scale_columns(self, factors):
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_13 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_5 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = PyFloat_FromDouble(__pyx_v_v); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = NULL;
        __pyx_t_12 = 0;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
            __pyx_t_12 = 1;
          }
        }
        __pyx_t_14 = PyTuple_New(3+__pyx_t_12); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_14);
        if (__pyx_t_4) {
          PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        }
        PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_12, __pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_13);
        PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_12, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_12, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_13 = 0;
        __pyx_t_5 = 0;
        __pyx_t_3 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_14, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __pyx_L8:;
    }
  }

  /* "lurrn/sparsmat.pyx":355
 *                else:
 *                    tmp.add_count(k,k2,v)
 *         return tmp.to_csr()             # <<<<<<<<<<<<<<
 *     def scale_columns(self, factors):
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] factors_l = factors
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp->__pyx_vtab)->to_csr(__pyx_v_tmp, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":335
 *                    tmp.add_count(k,k2,1.0)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD apply_scaling(self, numpy.ndarray thr):             # <<<<<<<<<<<<<<
 *         cdef VecD2 tmp=VecD2()
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] thresholds=thr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_thresholds.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.apply_scaling", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_thresholds.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XDECREF((PyObject *)__pyx_v_thresholds);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_41apply_scaling(PyObject *__pyx_v_self, PyObject *__pyx_v_thr); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_41apply_scaling(PyObject *__pyx_v_self, PyObject *__pyx_v_thr) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("apply_scaling (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_thr), __pyx_ptype_5numpy_ndarray, 1, "thr", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_40apply_scaling(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self), ((PyArrayObject *)__pyx_v_thr));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_40apply_scaling(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyArrayObject *__pyx_v_thr) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("apply_scaling", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_apply_scaling(__pyx_v_self, __pyx_v_thr, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.apply_scaling", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":356
 *                    tmp.add_count(k,k2,v)
 *         return tmp.to_csr()
 *     def scale_columns(self, factors):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] factors_l = factors
 *         cdef coordinate_t k
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_43scale_columns(PyObject *__pyx_v_self, PyObject *__pyx_v_factors); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_43scale_columns(PyObject *__pyx_v_self, PyObject *__pyx_v_factors) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("scale_columns (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_42scale_columns(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self), ((PyObject *)__pyx_v_factors));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_42scale_columns(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_factors) {
  PyArrayObject *__pyx_v_factors_l = 0;
  coordinate_t __pyx_v_k;
  int __pyx_v_off1;
  int __pyx_v_off2;
  int __pyx_v_i;
  coordinate_t __pyx_v_k2;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_factors_l;
  __Pyx_Buffer __pyx_pybuffer_factors_l;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  coordinate_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  coordinate_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("scale_columns", 0);
  __pyx_pybuffer_factors_l.pybuffer.buf = NULL;
  __pyx_pybuffer_factors_l.refcount = 0;
  __pyx_pybuffernd_factors_l.data = NULL;
  __pyx_pybuffernd_factors_l.rcbuffer = &__pyx_pybuffer_factors_l;

  /* "lurrn/sparsmat.pyx":357
 *         return tmp.to_csr()
 *     def scale_columns(self, factors):
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] factors_l = factors             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k
 *         cdef int off1, off2
 */
  if (!(likely(((__pyx_v_factors) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_factors, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_factors;
  __Pyx_INCREF(__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_factors_l.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_factors_l = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_factors_l.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_factors_l.diminfo[0].strides = __pyx_pybuffernd_factors_l.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_factors_l.diminfo[0].shape = __pyx_pybuffernd_factors_l.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_v_factors_l = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":360
 *         cdef coordinate_t k
 *         cdef int off1, off2
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             off1 = self.mat.offsets[k]
 *             off2 = self.mat.offsets[k+1]
 */
  __pyx_t_2 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_2; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":361
 *         cdef int off1, off2
 *         for k from 0<=k<self.mat.num_rows:
 *             off1 = self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2 = self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":362
 *         for k from 0<=k<self.mat.num_rows:
 *             off1 = self.mat.offsets[k]
 *             off2 = self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                 k2 = self.mat.rightColumns[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":363
 *             off1 = self.mat.offsets[k]
 *             off2 = self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                 k2 = self.mat.rightColumns[i]
 *                 self.mat.values[i] *= factors_l[k2]
 */
    __pyx_t_3 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":364
 *             off2 = self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                 k2 = self.mat.rightColumns[i]             # <<<<<<<<<<<<<<
 *                 self.mat.values[i] *= factors_l[k2]
 *     def scale_rows(self, factors):
 */
      __pyx_v_k2 = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":365
 *             for i from off1<=i<off2:
 *                 k2 = self.mat.rightColumns[i]
 *                 self.mat.values[i] *= factors_l[k2]             # <<<<<<<<<<<<<<
 *     def scale_rows(self, factors):
 *         cdef coordinate_t k
 */
      __pyx_t_4 = __pyx_v_i;
      __pyx_t_5 = __pyx_v_k2;
      __pyx_t_6 = -1;
      if (unlikely(__pyx_t_5 >= (size_t)__pyx_pybuffernd_factors_l.diminfo[0].shape)) __pyx_t_6 = 0;
      if (unlikely(__pyx_t_6 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_6);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      (__pyx_v_self->mat->values[__pyx_t_4]) = ((__pyx_v_self->mat->values[__pyx_t_4]) * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_factors_l.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_factors_l.diminfo[0].strides)));
    }
  }

  /* "lurrn/sparsmat.pyx":356
 *                    tmp.add_count(k,k2,v)
 *         return tmp.to_csr()
 *     def scale_columns(self, factors):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] factors_l = factors
 *         cdef coordinate_t k
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_factors_l.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.scale_columns", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_factors_l.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_factors_l);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":366
 *                 k2 = self.mat.rightColumns[i]
 *                 self.mat.values[i] *= factors_l[k2]
 *     def scale_rows(self, factors):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k
 *         cdef int factor
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_45scale_rows(PyObject *__pyx_v_self, PyObject *__pyx_v_factors); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_45scale_rows(PyObject *__pyx_v_self, PyObject *__pyx_v_factors) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("scale_rows (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_44scale_rows(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self), ((PyObject *)__pyx_v_factors));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_44scale_rows(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_factors) {
  coordinate_t __pyx_v_k;
  int __pyx_v_factor;
  int __pyx_v_off1;
  int __pyx_v_off2;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  coordinate_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("scale_rows", 0);

  /* "lurrn/sparsmat.pyx":370
 *         cdef int factor
 *         cdef int off1, off2
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             off1 = self.mat.offsets[k]
 *             off2 = self.mat.offsets[k+1]
 */
  __pyx_t_1 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":371
 *         cdef int off1, off2
 *         for k from 0<=k<self.mat.num_rows:
 *             off1 = self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2 = self.mat.offsets[k+1]
 *             factor = factors[k]
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":372
 *         for k from 0<=k<self.mat.num_rows:
 *             off1 = self.mat.offsets[k]
 *             off2 = self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             factor = factors[k]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":373
 *             off1 = self.mat.offsets[k]
 *             off2 = self.mat.offsets[k+1]
 *             factor = factors[k]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                 self.mat.values[i] *= factor
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_factors, __pyx_v_k, coordinate_t, 0, __Pyx_PyInt_From_coordinate_t, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_factor = __pyx_t_3;

    /* "lurrn/sparsmat.pyx":374
 *             off2 = self.mat.offsets[k+1]
 *             factor = factors[k]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                 self.mat.values[i] *= factor
 *     def left_marginals(self):
 */
    __pyx_t_3 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":375
 *             factor = factors[k]
 *             for i from off1<=i<off2:
 *                 self.mat.values[i] *= factor             # <<<<<<<<<<<<<<
 *     def left_marginals(self):
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 */
      __pyx_t_4 = __pyx_v_i;
      (__pyx_v_self->mat->values[__pyx_t_4]) = ((__pyx_v_self->mat->values[__pyx_t_4]) * __pyx_v_factor);
    }
  }

  /* "lurrn/sparsmat.pyx":366
 *                 k2 = self.mat.rightColumns[i]
 *                 self.mat.values[i] *= factors_l[k2]
 *     def scale_rows(self, factors):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k
 *         cdef int factor
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.scale_rows", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":376
 *             for i from off1<=i<off2:
 *                 self.mat.values[i] *= factor
 *     def left_marginals(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 *         marginals_l=numpy.zeros(self.mat.num_rows,numpy.int32)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_47left_marginals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_47left_marginals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("left_marginals (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_46left_marginals(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_46left_marginals(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self) {
  PyArrayObject *__pyx_v_marginals_l = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_l;
  __Pyx_Buffer __pyx_pybuffer_marginals_l;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("left_marginals", 0);
  __pyx_pybuffer_marginals_l.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_l.refcount = 0;
  __pyx_pybuffernd_marginals_l.data = NULL;
  __pyx_pybuffernd_marginals_l.rcbuffer = &__pyx_pybuffer_marginals_l;

  /* "lurrn/sparsmat.pyx":378
 *     def left_marginals(self):
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 *         marginals_l=numpy.zeros(self.mat.num_rows,numpy.int32)             # <<<<<<<<<<<<<<
 *         self.mat.compute_left_marginals(<int *> marginals_l.data)
 *         return marginals_l
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_coordinate_t(__pyx_v_self->mat->num_rows); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_l, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_marginals_l.diminfo[0].strides = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_l.diminfo[0].shape = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __pyx_v_marginals_l = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":379
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 *         marginals_l=numpy.zeros(self.mat.num_rows,numpy.int32)
 *         self.mat.compute_left_marginals(<int *> marginals_l.data)             # <<<<<<<<<<<<<<
 *         return marginals_l
 *     def right_marginals(self):
 */
  __pyx_v_self->mat->compute_left_marginals(((int *)__pyx_v_marginals_l->data));

  /* "lurrn/sparsmat.pyx":380
 *         marginals_l=numpy.zeros(self.mat.num_rows,numpy.int32)
 *         self.mat.compute_left_marginals(<int *> marginals_l.data)
 *         return marginals_l             # <<<<<<<<<<<<<<
 *     def right_marginals(self):
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_r
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_marginals_l));
  __pyx_r = ((PyObject *)__pyx_v_marginals_l);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":376
 *             for i from off1<=i<off2:
 *                 self.mat.values[i] *= factor
 *     def left_marginals(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_l
 *         marginals_l=numpy.zeros(self.mat.num_rows,numpy.int32)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.left_marginals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_l);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":381
 *         self.mat.compute_left_marginals(<int *> marginals_l.data)
 *         return marginals_l
 *     def right_marginals(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.int32)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_49right_marginals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_49right_marginals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("right_marginals (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_48right_marginals(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_48right_marginals(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self) {
  PyArrayObject *__pyx_v_marginals_r = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_r;
  __Pyx_Buffer __pyx_pybuffer_marginals_r;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("right_marginals", 0);
  __pyx_pybuffer_marginals_r.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_r.refcount = 0;
  __pyx_pybuffernd_marginals_r.data = NULL;
  __pyx_pybuffernd_marginals_r.rcbuffer = &__pyx_pybuffer_marginals_r;

  /* "lurrn/sparsmat.pyx":383
 *     def right_marginals(self):
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.int32)             # <<<<<<<<<<<<<<
 *         self.mat.compute_right_marginals(<int *> marginals_r.data)
 *         return marginals_r
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_long((((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0) + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_r, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_marginals_r.diminfo[0].strides = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_r.diminfo[0].shape = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __pyx_v_marginals_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":384
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.int32)
 *         self.mat.compute_right_marginals(<int *> marginals_r.data)             # <<<<<<<<<<<<<<
 *         return marginals_r
 *     def right_squared_marginals(self):
 */
  __pyx_v_self->mat->compute_right_marginals(((int *)__pyx_v_marginals_r->data));

  /* "lurrn/sparsmat.pyx":385
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.int32)
 *         self.mat.compute_right_marginals(<int *> marginals_r.data)
 *         return marginals_r             # <<<<<<<<<<<<<<
 *     def right_squared_marginals(self):
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_r
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_marginals_r));
  __pyx_r = ((PyObject *)__pyx_v_marginals_r);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":381
 *         self.mat.compute_left_marginals(<int *> marginals_l.data)
 *         return marginals_l
 *     def right_marginals(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.int32)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.right_marginals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_r);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":386
 *         self.mat.compute_right_marginals(<int *> marginals_r.data)
 *         return marginals_r
 *     def right_squared_marginals(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.int32)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_51right_squared_marginals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_51right_squared_marginals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("right_squared_marginals (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_50right_squared_marginals(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_50right_squared_marginals(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self) {
  PyArrayObject *__pyx_v_marginals_r = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_r;
  __Pyx_Buffer __pyx_pybuffer_marginals_r;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("right_squared_marginals", 0);
  __pyx_pybuffer_marginals_r.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_r.refcount = 0;
  __pyx_pybuffernd_marginals_r.data = NULL;
  __pyx_pybuffernd_marginals_r.rcbuffer = &__pyx_pybuffer_marginals_r;

  /* "lurrn/sparsmat.pyx":388
 *     def right_squared_marginals(self):
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.int32)             # <<<<<<<<<<<<<<
 *         self.mat.compute_right_squared_marginals(<int *> marginals_r.data)
 *         return marginals_r
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_long((((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0) + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_r, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_marginals_r.diminfo[0].strides = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_r.diminfo[0].shape = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __pyx_v_marginals_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":389
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.int32)
 *         self.mat.compute_right_squared_marginals(<int *> marginals_r.data)             # <<<<<<<<<<<<<<
 *         return marginals_r
 *     cpdef int get_count(self,coordinate_t k, coordinate_t k2):
 */
  __pyx_v_self->mat->compute_right_squared_marginals(((int *)__pyx_v_marginals_r->data));

  /* "lurrn/sparsmat.pyx":390
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.int32)
 *         self.mat.compute_right_squared_marginals(<int *> marginals_r.data)
 *         return marginals_r             # <<<<<<<<<<<<<<
 *     cpdef int get_count(self,coordinate_t k, coordinate_t k2):
 *         if k<0 or k>=self.mat.num_rows:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_marginals_r));
  __pyx_r = ((PyObject *)__pyx_v_marginals_r);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":386
 *         self.mat.compute_right_marginals(<int *> marginals_r.data)
 *         return marginals_r
 *     def right_squared_marginals(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.int32)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.right_squared_marginals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_r);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":391
 *         self.mat.compute_right_squared_marginals(<int *> marginals_r.data)
 *         return marginals_r
 *     cpdef int get_count(self,coordinate_t k, coordinate_t k2):             # <<<<<<<<<<<<<<
 *         if k<0 or k>=self.mat.num_rows:
 *             return 0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_53get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_10CSRMatrixI_get_count(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, coordinate_t __pyx_v_k, coordinate_t __pyx_v_k2, int __pyx_skip_dispatch) {
  int __pyx_v_lo;
  int __pyx_v_hi;
  int __pyx_v_mi;
  coordinate_t __pyx_v_a_mi;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_53get_count)) {
      __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_5 = __pyx_t_1; __pyx_t_6 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_7 = 1;
        }
      }
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_6) {
        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_9;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":392
 *         return marginals_r
 *     cpdef int get_count(self,coordinate_t k, coordinate_t k2):
 *         if k<0 or k>=self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             return 0
 *         assert k<self.mat.num_rows
 */
  __pyx_t_11 = ((__pyx_v_k < 0) != 0);
  if (!__pyx_t_11) {
  } else {
    __pyx_t_10 = __pyx_t_11;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_11 = ((__pyx_v_k >= __pyx_v_self->mat->num_rows) != 0);
  __pyx_t_10 = __pyx_t_11;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_10) {

    /* "lurrn/sparsmat.pyx":393
 *     cpdef int get_count(self,coordinate_t k, coordinate_t k2):
 *         if k<0 or k>=self.mat.num_rows:
 *             return 0             # <<<<<<<<<<<<<<
 *         assert k<self.mat.num_rows
 *         cdef int lo=self.mat.offsets[k]
 */
    __pyx_r = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":394
 *         if k<0 or k>=self.mat.num_rows:
 *             return 0
 *         assert k<self.mat.num_rows             # <<<<<<<<<<<<<<
 *         cdef int lo=self.mat.offsets[k]
 *         cdef int hi=self.mat.offsets[k+1]
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_k < __pyx_v_self->mat->num_rows) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":395
 *             return 0
 *         assert k<self.mat.num_rows
 *         cdef int lo=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *         cdef int hi=self.mat.offsets[k+1]
 *         cdef int mi
 */
  __pyx_v_lo = (__pyx_v_self->mat->offsets[__pyx_v_k]);

  /* "lurrn/sparsmat.pyx":396
 *         assert k<self.mat.num_rows
 *         cdef int lo=self.mat.offsets[k]
 *         cdef int hi=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *         cdef int mi
 *         cdef coordinate_t a_mi
 */
  __pyx_v_hi = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

  /* "lurrn/sparsmat.pyx":399
 *         cdef int mi
 *         cdef coordinate_t a_mi
 *         if hi==lo: return 0             # <<<<<<<<<<<<<<
 *         while hi-lo>1:
 *             mi=(hi+lo)//2
 */
  __pyx_t_10 = ((__pyx_v_hi == __pyx_v_lo) != 0);
  if (__pyx_t_10) {
    __pyx_r = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":400
 *         cdef coordinate_t a_mi
 *         if hi==lo: return 0
 *         while hi-lo>1:             # <<<<<<<<<<<<<<
 *             mi=(hi+lo)//2
 *             a_mi=self.mat.rightColumns[mi]
 */
  while (1) {
    __pyx_t_10 = (((__pyx_v_hi - __pyx_v_lo) > 1) != 0);
    if (!__pyx_t_10) break;

    /* "lurrn/sparsmat.pyx":401
 *         if hi==lo: return 0
 *         while hi-lo>1:
 *             mi=(hi+lo)//2             # <<<<<<<<<<<<<<
 *             a_mi=self.mat.rightColumns[mi]
 *             if a_mi>k2:
 */
    __pyx_v_mi = __Pyx_div_long((__pyx_v_hi + __pyx_v_lo), 2);

    /* "lurrn/sparsmat.pyx":402
 *         while hi-lo>1:
 *             mi=(hi+lo)//2
 *             a_mi=self.mat.rightColumns[mi]             # <<<<<<<<<<<<<<
 *             if a_mi>k2:
 *                 hi=mi
 */
    __pyx_v_a_mi = (__pyx_v_self->mat->rightColumns[__pyx_v_mi]);

    /* "lurrn/sparsmat.pyx":403
 *             mi=(hi+lo)//2
 *             a_mi=self.mat.rightColumns[mi]
 *             if a_mi>k2:             # <<<<<<<<<<<<<<
 *                 hi=mi
 *             elif a_mi==k2:
 */
    __pyx_t_10 = ((__pyx_v_a_mi > __pyx_v_k2) != 0);
    if (__pyx_t_10) {

      /* "lurrn/sparsmat.pyx":404
 *             a_mi=self.mat.rightColumns[mi]
 *             if a_mi>k2:
 *                 hi=mi             # <<<<<<<<<<<<<<
 *             elif a_mi==k2:
 *                 return self.mat.values[mi]
 */
      __pyx_v_hi = __pyx_v_mi;
      goto __pyx_L9;
    }

    /* "lurrn/sparsmat.pyx":405
 *             if a_mi>k2:
 *                 hi=mi
 *             elif a_mi==k2:             # <<<<<<<<<<<<<<
 *                 return self.mat.values[mi]
 *             else:
 */
    __pyx_t_10 = ((__pyx_v_a_mi == __pyx_v_k2) != 0);
    if (__pyx_t_10) {

      /* "lurrn/sparsmat.pyx":406
 *                 hi=mi
 *             elif a_mi==k2:
 *                 return self.mat.values[mi]             # <<<<<<<<<<<<<<
 *             else:
 *                 lo=mi+1
 */
      __pyx_r = (__pyx_v_self->mat->values[__pyx_v_mi]);
      goto __pyx_L0;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":408
 *                 return self.mat.values[mi]
 *             else:
 *                 lo=mi+1             # <<<<<<<<<<<<<<
 *         if self.mat.rightColumns[lo]==k2:
 *             return self.mat.values[lo]
 */
      __pyx_v_lo = (__pyx_v_mi + 1);
    }
    __pyx_L9:;
  }

  /* "lurrn/sparsmat.pyx":409
 *             else:
 *                 lo=mi+1
 *         if self.mat.rightColumns[lo]==k2:             # <<<<<<<<<<<<<<
 *             return self.mat.values[lo]
 *         return 0
 */
  __pyx_t_10 = (((__pyx_v_self->mat->rightColumns[__pyx_v_lo]) == __pyx_v_k2) != 0);
  if (__pyx_t_10) {

    /* "lurrn/sparsmat.pyx":410
 *                 lo=mi+1
 *         if self.mat.rightColumns[lo]==k2:
 *             return self.mat.values[lo]             # <<<<<<<<<<<<<<
 *         return 0
 *     def write_binary(self,f):
 */
    __pyx_r = (__pyx_v_self->mat->values[__pyx_v_lo]);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":411
 *         if self.mat.rightColumns[lo]==k2:
 *             return self.mat.values[lo]
 *         return 0             # <<<<<<<<<<<<<<
 *     def write_binary(self,f):
 *         """writes the matrix in binary format"""
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":391
 *         self.mat.compute_right_squared_marginals(<int *> marginals_r.data)
 *         return marginals_r
 *     cpdef int get_count(self,coordinate_t k, coordinate_t k2):             # <<<<<<<<<<<<<<
 *         if k<0 or k>=self.mat.num_rows:
 *             return 0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_WriteUnraisable("lurrn.sparsmat.CSRMatrixI.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_53get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_53get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_k2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_k2,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_count", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k2 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k2 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_count", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_52get_count(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self), __pyx_v_k, __pyx_v_k2);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_52get_count(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, coordinate_t __pyx_v_k, coordinate_t __pyx_v_k2) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_get_count(__pyx_v_self, __pyx_v_k, __pyx_v_k2, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":412
 *             return self.mat.values[lo]
 *         return 0
 *     def write_binary(self,f):             # <<<<<<<<<<<<<<
 *         """writes the matrix in binary format"""
 *         cdef int fileno=f.fileno()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_55write_binary(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static char __pyx_doc_5lurrn_8sparsmat_10CSRMatrixI_54write_binary[] = "writes the matrix in binary format";
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_55write_binary(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_binary (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_54write_binary(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_54write_binary(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, PyObject *__pyx_v_f) {
  int __pyx_v_fileno;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("write_binary", 0);

  /* "lurrn/sparsmat.pyx":414
 *     def write_binary(self,f):
 *         """writes the matrix in binary format"""
 *         cdef int fileno=f.fileno()             # <<<<<<<<<<<<<<
 *         self.mat.write_binary(fileno)
 *     def transpose(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_fileno); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_fileno = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":415
 *         """writes the matrix in binary format"""
 *         cdef int fileno=f.fileno()
 *         self.mat.write_binary(fileno)             # <<<<<<<<<<<<<<
 *     def transpose(self):
 *         cdef c_CSRMatrixI *matC=self.mat.transpose()
 */
  __pyx_v_self->mat->write_binary(__pyx_v_fileno);

  /* "lurrn/sparsmat.pyx":412
 *             return self.mat.values[lo]
 *         return 0
 *     def write_binary(self,f):             # <<<<<<<<<<<<<<
 *         """writes the matrix in binary format"""
 *         cdef int fileno=f.fileno()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.write_binary", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":416
 *         cdef int fileno=f.fileno()
 *         self.mat.write_binary(fileno)
 *     def transpose(self):             # <<<<<<<<<<<<<<
 *         cdef c_CSRMatrixI *matC=self.mat.transpose()
 *         cdef CSRMatrixI mat=CSRMatrixI()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_57transpose(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_57transpose(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("transpose (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_56transpose(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_56transpose(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self) {
  struct CSRMatrix<int> *__pyx_v_matC;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_mat = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transpose", 0);

  /* "lurrn/sparsmat.pyx":417
 *         self.mat.write_binary(fileno)
 *     def transpose(self):
 *         cdef c_CSRMatrixI *matC=self.mat.transpose()             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixI mat=CSRMatrixI()
 *         mat.set_matrix(matC)
 */
  __pyx_v_matC = __pyx_v_self->mat->transpose();

  /* "lurrn/sparsmat.pyx":418
 *     def transpose(self):
 *         cdef c_CSRMatrixI *matC=self.mat.transpose()
 *         cdef CSRMatrixI mat=CSRMatrixI()             # <<<<<<<<<<<<<<
 *         mat.set_matrix(matC)
 *         return mat
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixI)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_mat = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":419
 *         cdef c_CSRMatrixI *matC=self.mat.transpose()
 *         cdef CSRMatrixI mat=CSRMatrixI()
 *         mat.set_matrix(matC)             # <<<<<<<<<<<<<<
 *         return mat
 *     def __add__(self,other):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_mat->__pyx_vtab)->set_matrix(__pyx_v_mat, __pyx_v_matC);

  /* "lurrn/sparsmat.pyx":420
 *         cdef CSRMatrixI mat=CSRMatrixI()
 *         mat.set_matrix(matC)
 *         return mat             # <<<<<<<<<<<<<<
 *     def __add__(self,other):
 *         cdef CSRMatrixI mat1
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_mat));
  __pyx_r = ((PyObject *)__pyx_v_mat);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":416
 *         cdef int fileno=f.fileno()
 *         self.mat.write_binary(fileno)
 *     def transpose(self):             # <<<<<<<<<<<<<<
 *         cdef c_CSRMatrixI *matC=self.mat.transpose()
 *         cdef CSRMatrixI mat=CSRMatrixI()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.transpose", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mat);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":421
 *         mat.set_matrix(matC)
 *         return mat
 *     def __add__(self,other):             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixI mat1
 *         cdef CSRMatrixI mat2
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_59__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_59__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_58__add__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_58__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_mat1 = 0;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_mat2 = 0;
  struct CSRMatrix<int> *__pyx_v_matC;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_mat = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":425
 *         cdef CSRMatrixI mat2
 *         cdef c_CSRMatrixI *matC
 *         mat1=self             # <<<<<<<<<<<<<<
 *         mat2=other
 *         matC=add_csrI(mat1.mat,mat2.mat)
 */
  if (!(likely(((__pyx_v_self) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_self, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_self;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_mat1 = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":426
 *         cdef c_CSRMatrixI *matC
 *         mat1=self
 *         mat2=other             # <<<<<<<<<<<<<<
 *         matC=add_csrI(mat1.mat,mat2.mat)
 *         cdef CSRMatrixI mat=CSRMatrixI()
 */
  if (!(likely(((__pyx_v_other) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_other, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_other;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_mat2 = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":427
 *         mat1=self
 *         mat2=other
 *         matC=add_csrI(mat1.mat,mat2.mat)             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixI mat=CSRMatrixI()
 *         mat.set_matrix(matC)
 */
  __pyx_v_matC = add_csr(__pyx_v_mat1->mat, __pyx_v_mat2->mat);

  /* "lurrn/sparsmat.pyx":428
 *         mat2=other
 *         matC=add_csrI(mat1.mat,mat2.mat)
 *         cdef CSRMatrixI mat=CSRMatrixI()             # <<<<<<<<<<<<<<
 *         mat.set_matrix(matC)
 *         return mat
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixI)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_mat = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":429
 *         matC=add_csrI(mat1.mat,mat2.mat)
 *         cdef CSRMatrixI mat=CSRMatrixI()
 *         mat.set_matrix(matC)             # <<<<<<<<<<<<<<
 *         return mat
 *     def __dealloc__(self):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_mat->__pyx_vtab)->set_matrix(__pyx_v_mat, __pyx_v_matC);

  /* "lurrn/sparsmat.pyx":430
 *         cdef CSRMatrixI mat=CSRMatrixI()
 *         mat.set_matrix(matC)
 *         return mat             # <<<<<<<<<<<<<<
 *     def __dealloc__(self):
 *         if self.mat!=NULL:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_mat));
  __pyx_r = ((PyObject *)__pyx_v_mat);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":421
 *         mat.set_matrix(matC)
 *         return mat
 *     def __add__(self,other):             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixI mat1
 *         cdef CSRMatrixI mat2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mat1);
  __Pyx_XDECREF((PyObject *)__pyx_v_mat2);
  __Pyx_XDECREF((PyObject *)__pyx_v_mat);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":431
 *         mat.set_matrix(matC)
 *         return mat
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.mat!=NULL:
 *             if self.buf is not None:
 */

/* Python wrapper */
static void __pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_61__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_61__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_60__dealloc__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_60__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lurrn/sparsmat.pyx":432
 *         return mat
 *     def __dealloc__(self):
 *         if self.mat!=NULL:             # <<<<<<<<<<<<<<
 *             if self.buf is not None:
 *                 self.buf=None
 */
  __pyx_t_1 = ((__pyx_v_self->mat != NULL) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":433
 *     def __dealloc__(self):
 *         if self.mat!=NULL:
 *             if self.buf is not None:             # <<<<<<<<<<<<<<
 *                 self.buf=None
 *             else:
 */
    __pyx_t_1 = (__pyx_v_self->buf != Py_None);
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":434
 *         if self.mat!=NULL:
 *             if self.buf is not None:
 *                 self.buf=None             # <<<<<<<<<<<<<<
 *             else:
 *                 cxx_deleteA(self.mat.offsets)
 */
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      __Pyx_GOTREF(__pyx_v_self->buf);
      __Pyx_DECREF(__pyx_v_self->buf);
      __pyx_v_self->buf = Py_None;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":436
 *                 self.buf=None
 *             else:
 *                 cxx_deleteA(self.mat.offsets)             # <<<<<<<<<<<<<<
 *                 if (self.mat.rightColumns!=NULL):
 *                     cxx_deleteA(self.mat.rightColumns)
 */
      delete [](__pyx_v_self->mat->offsets);

      /* "lurrn/sparsmat.pyx":437
 *             else:
 *                 cxx_deleteA(self.mat.offsets)
 *                 if (self.mat.rightColumns!=NULL):             # <<<<<<<<<<<<<<
 *                     cxx_deleteA(self.mat.rightColumns)
 *                     cxx_deleteA(self.mat.values)
 */
      __pyx_t_2 = ((__pyx_v_self->mat->rightColumns != NULL) != 0);
      if (__pyx_t_2) {

        /* "lurrn/sparsmat.pyx":438
 *                 cxx_deleteA(self.mat.offsets)
 *                 if (self.mat.rightColumns!=NULL):
 *                     cxx_deleteA(self.mat.rightColumns)             # <<<<<<<<<<<<<<
 *                     cxx_deleteA(self.mat.values)
 *             cxx_delete(self.mat)
 */
        delete [](__pyx_v_self->mat->rightColumns);

        /* "lurrn/sparsmat.pyx":439
 *                 if (self.mat.rightColumns!=NULL):
 *                     cxx_deleteA(self.mat.rightColumns)
 *                     cxx_deleteA(self.mat.values)             # <<<<<<<<<<<<<<
 *             cxx_delete(self.mat)
 *     def __reduce__(self):
 */
        delete [](__pyx_v_self->mat->values);
        goto __pyx_L5;
      }
      __pyx_L5:;
    }
    __pyx_L4:;

    /* "lurrn/sparsmat.pyx":440
 *                     cxx_deleteA(self.mat.rightColumns)
 *                     cxx_deleteA(self.mat.values)
 *             cxx_delete(self.mat)             # <<<<<<<<<<<<<<
 *     def __reduce__(self):
 *         # choose compatibility over performance.
 */
    delete(__pyx_v_self->mat);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":431
 *         mat.set_matrix(matC)
 *         return mat
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.mat!=NULL:
 *             if self.buf is not None:
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":441
 *                     cxx_deleteA(self.mat.values)
 *             cxx_delete(self.mat)
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         # choose compatibility over performance.
 *         cdef VecI2 tmp=VecI2()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_63__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_63__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_62__reduce__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_62__reduce__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self) {
  struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_tmp = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "lurrn/sparsmat.pyx":443
 *     def __reduce__(self):
 *         # choose compatibility over performance.
 *         cdef VecI2 tmp=VecI2()             # <<<<<<<<<<<<<<
 *         tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         tmp.extend(self.item_iter())
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":444
 *         # choose compatibility over performance.
 *         cdef VecI2 tmp=VecI2()
 *         tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         tmp.extend(self.item_iter())
 *         return (CSRMatrixI,(),tmp)
 */
  __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));

  /* "lurrn/sparsmat.pyx":445
 *         cdef VecI2 tmp=VecI2()
 *         tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         tmp.extend(self.item_iter())             # <<<<<<<<<<<<<<
 *         return (CSRMatrixI,(),tmp)
 *     def __setstate__(self,VecI2 tmp):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_extend); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":446
 *         tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         tmp.extend(self.item_iter())
 *         return (CSRMatrixI,(),tmp)             # <<<<<<<<<<<<<<
 *     def __setstate__(self,VecI2 tmp):
 *         tmp.ensure_compact()
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixI)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixI)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixI)));
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  __Pyx_INCREF(((PyObject *)__pyx_v_tmp));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_tmp));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_tmp));
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":441
 *                     cxx_deleteA(self.mat.values)
 *             cxx_delete(self.mat)
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         # choose compatibility over performance.
 *         cdef VecI2 tmp=VecI2()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":447
 *         tmp.extend(self.item_iter())
 *         return (CSRMatrixI,(),tmp)
 *     def __setstate__(self,VecI2 tmp):             # <<<<<<<<<<<<<<
 *         tmp.ensure_compact()
 *         self.set_matrix(vec2csrI(&tmp.vec))
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_65__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_tmp); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_65__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_tmp) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tmp), __pyx_ptype_5lurrn_8sparsmat_VecI2, 1, "tmp", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_64__setstate__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_tmp));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixI_64__setstate__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_tmp) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* "lurrn/sparsmat.pyx":448
 *         return (CSRMatrixI,(),tmp)
 *     def __setstate__(self,VecI2 tmp):
 *         tmp.ensure_compact()             # <<<<<<<<<<<<<<
 *         self.set_matrix(vec2csrI(&tmp.vec))
 * 
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_tmp->__pyx_vtab)->ensure_compact(__pyx_v_tmp);

  /* "lurrn/sparsmat.pyx":449
 *     def __setstate__(self,VecI2 tmp):
 *         tmp.ensure_compact()
 *         self.set_matrix(vec2csrI(&tmp.vec))             # <<<<<<<<<<<<<<
 * 
 * cdef class CSRMatrixI_item_iter:
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_self->__pyx_vtab)->set_matrix(__pyx_v_self, vec2csr((&__pyx_v_tmp->vec)));

  /* "lurrn/sparsmat.pyx":447
 *         tmp.extend(self.item_iter())
 *         return (CSRMatrixI,(),tmp)
 *     def __setstate__(self,VecI2 tmp):             # <<<<<<<<<<<<<<
 *         tmp.ensure_compact()
 *         self.set_matrix(vec2csrI(&tmp.vec))
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":456
 *     cdef coordinate_t k
 *     cdef int off
 *     def __init__(self, mat):             # <<<<<<<<<<<<<<
 *         self.mat=mat
 *         self.matC=self.mat.mat
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_20CSRMatrixI_item_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_20CSRMatrixI_item_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_mat = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mat,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mat)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_mat = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI_item_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_20CSRMatrixI_item_iter___init__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter *)__pyx_v_self), __pyx_v_mat);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_20CSRMatrixI_item_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter *__pyx_v_self, PyObject *__pyx_v_mat) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct CSRMatrix<int> *__pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":457
 *     cdef int off
 *     def __init__(self, mat):
 *         self.mat=mat             # <<<<<<<<<<<<<<
 *         self.matC=self.mat.mat
 *         self.k=0
 */
  if (!(likely(((__pyx_v_mat) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_mat, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_mat;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->mat);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->mat));
  __pyx_v_self->mat = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":458
 *     def __init__(self, mat):
 *         self.mat=mat
 *         self.matC=self.mat.mat             # <<<<<<<<<<<<<<
 *         self.k=0
 *         self.off=0
 */
  __pyx_t_2 = __pyx_v_self->mat->mat;
  __pyx_v_self->matC = __pyx_t_2;

  /* "lurrn/sparsmat.pyx":459
 *         self.mat=mat
 *         self.matC=self.mat.mat
 *         self.k=0             # <<<<<<<<<<<<<<
 *         self.off=0
 *     def __iter__(self):
 */
  __pyx_v_self->k = 0;

  /* "lurrn/sparsmat.pyx":460
 *         self.matC=self.mat.mat
 *         self.k=0
 *         self.off=0             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self
 */
  __pyx_v_self->off = 0;

  /* "lurrn/sparsmat.pyx":456
 *     cdef coordinate_t k
 *     cdef int off
 *     def __init__(self, mat):             # <<<<<<<<<<<<<<
 *         self.mat=mat
 *         self.matC=self.mat.mat
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI_item_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":461
 *         self.k=0
 *         self.off=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_20CSRMatrixI_item_iter_3__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_20CSRMatrixI_item_iter_3__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_20CSRMatrixI_item_iter_2__iter__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_20CSRMatrixI_item_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":462
 *         self.off=0
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 *     def __next__(self):
 *         while self.off==self.matC.offsets[self.k+1]:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":461
 *         self.k=0
 *         self.off=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":463
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         while self.off==self.matC.offsets[self.k+1]:
 *             self.k+=1
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_20CSRMatrixI_item_iter_5__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_20CSRMatrixI_item_iter_5__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_20CSRMatrixI_item_iter_4__next__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_20CSRMatrixI_item_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter *__pyx_v_self) {
  PyObject *__pyx_v_res = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "lurrn/sparsmat.pyx":464
 *         return self
 *     def __next__(self):
 *         while self.off==self.matC.offsets[self.k+1]:             # <<<<<<<<<<<<<<
 *             self.k+=1
 *             if self.k>=self.matC.num_rows:
 */
  while (1) {
    __pyx_t_1 = ((__pyx_v_self->off == (__pyx_v_self->matC->offsets[(__pyx_v_self->k + 1)])) != 0);
    if (!__pyx_t_1) break;

    /* "lurrn/sparsmat.pyx":465
 *     def __next__(self):
 *         while self.off==self.matC.offsets[self.k+1]:
 *             self.k+=1             # <<<<<<<<<<<<<<
 *             if self.k>=self.matC.num_rows:
 *                 raise StopIteration
 */
    __pyx_v_self->k = (__pyx_v_self->k + 1);

    /* "lurrn/sparsmat.pyx":466
 *         while self.off==self.matC.offsets[self.k+1]:
 *             self.k+=1
 *             if self.k>=self.matC.num_rows:             # <<<<<<<<<<<<<<
 *                 raise StopIteration
 *         res=(self.k,
 */
    __pyx_t_1 = ((__pyx_v_self->k >= __pyx_v_self->matC->num_rows) != 0);
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":467
 *             self.k+=1
 *             if self.k>=self.matC.num_rows:
 *                 raise StopIteration             # <<<<<<<<<<<<<<
 *         res=(self.k,
 *              self.matC.rightColumns[self.off],
 */
      __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }

  /* "lurrn/sparsmat.pyx":468
 *             if self.k>=self.matC.num_rows:
 *                 raise StopIteration
 *         res=(self.k,             # <<<<<<<<<<<<<<
 *              self.matC.rightColumns[self.off],
 *              self.matC.values[self.off])
 */
  __pyx_t_2 = __Pyx_PyInt_From_coordinate_t(__pyx_v_self->k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "lurrn/sparsmat.pyx":469
 *                 raise StopIteration
 *         res=(self.k,
 *              self.matC.rightColumns[self.off],             # <<<<<<<<<<<<<<
 *              self.matC.values[self.off])
 *         self.off+=1
 */
  __pyx_t_3 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->matC->rightColumns[__pyx_v_self->off])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "lurrn/sparsmat.pyx":470
 *         res=(self.k,
 *              self.matC.rightColumns[self.off],
 *              self.matC.values[self.off])             # <<<<<<<<<<<<<<
 *         self.off+=1
 *         return res
 */
  __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_self->matC->values[__pyx_v_self->off])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":468
 *             if self.k>=self.matC.num_rows:
 *                 raise StopIteration
 *         res=(self.k,             # <<<<<<<<<<<<<<
 *              self.matC.rightColumns[self.off],
 *              self.matC.values[self.off])
 */
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_v_res = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "lurrn/sparsmat.pyx":471
 *              self.matC.rightColumns[self.off],
 *              self.matC.values[self.off])
 *         self.off+=1             # <<<<<<<<<<<<<<
 *         return res
 * ## F -> float, float32
 */
  __pyx_v_self->off = (__pyx_v_self->off + 1);

  /* "lurrn/sparsmat.pyx":472
 *              self.matC.values[self.off])
 *         self.off+=1
 *         return res             # <<<<<<<<<<<<<<
 * ## F -> float, float32
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_res);
  __pyx_r = __pyx_v_res;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":463
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         while self.off==self.matC.offsets[self.k+1]:
 *             self.k+=1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixI_item_iter.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_res);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":481
 * 
 * cdef class CSRMatrixF:
 *     def __cinit__(self, vecs=None):             # <<<<<<<<<<<<<<
 *         self.mat=NULL
 *         self.cache_maxcol=-1
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_vecs = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_vecs,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vecs);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_vecs = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF___cinit__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self), __pyx_v_vecs);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF___cinit__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_vecs) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "lurrn/sparsmat.pyx":482
 * cdef class CSRMatrixF:
 *     def __cinit__(self, vecs=None):
 *         self.mat=NULL             # <<<<<<<<<<<<<<
 *         self.cache_maxcol=-1
 *         if vecs is not None:
 */
  __pyx_v_self->mat = NULL;

  /* "lurrn/sparsmat.pyx":483
 *     def __cinit__(self, vecs=None):
 *         self.mat=NULL
 *         self.cache_maxcol=-1             # <<<<<<<<<<<<<<
 *         if vecs is not None:
 *             self.fromVectors(vecs)
 */
  __pyx_v_self->cache_maxcol = -1;

  /* "lurrn/sparsmat.pyx":484
 *         self.mat=NULL
 *         self.cache_maxcol=-1
 *         if vecs is not None:             # <<<<<<<<<<<<<<
 *             self.fromVectors(vecs)
 *     cdef void set_matrix(self,c_CSRMatrixF *mat_new):
 */
  __pyx_t_1 = (__pyx_v_vecs != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lurrn/sparsmat.pyx":485
 *         self.cache_maxcol=-1
 *         if vecs is not None:
 *             self.fromVectors(vecs)             # <<<<<<<<<<<<<<
 *     cdef void set_matrix(self,c_CSRMatrixF *mat_new):
 *         self.mat=mat_new
 */
    __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self->__pyx_vtab)->fromVectors(__pyx_v_self, __pyx_v_vecs, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":481
 * 
 * cdef class CSRMatrixF:
 *     def __cinit__(self, vecs=None):             # <<<<<<<<<<<<<<
 *         self.mat=NULL
 *         self.cache_maxcol=-1
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":486
 *         if vecs is not None:
 *             self.fromVectors(vecs)
 *     cdef void set_matrix(self,c_CSRMatrixF *mat_new):             # <<<<<<<<<<<<<<
 *         self.mat=mat_new
 *         self.cache_maxcol=-1
 */

static void __pyx_f_5lurrn_8sparsmat_10CSRMatrixF_set_matrix(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, struct CSRMatrix<float> *__pyx_v_mat_new) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_matrix", 0);

  /* "lurrn/sparsmat.pyx":487
 *             self.fromVectors(vecs)
 *     cdef void set_matrix(self,c_CSRMatrixF *mat_new):
 *         self.mat=mat_new             # <<<<<<<<<<<<<<
 *         self.cache_maxcol=-1
 *     cpdef CSRMatrixF fromVectors(self, vectors):
 */
  __pyx_v_self->mat = __pyx_v_mat_new;

  /* "lurrn/sparsmat.pyx":488
 *     cdef void set_matrix(self,c_CSRMatrixF *mat_new):
 *         self.mat=mat_new
 *         self.cache_maxcol=-1             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixF fromVectors(self, vectors):
 *         cdef int spaceNeeded=0
 */
  __pyx_v_self->cache_maxcol = -1;

  /* "lurrn/sparsmat.pyx":486
 *         if vecs is not None:
 *             self.fromVectors(vecs)
 *     cdef void set_matrix(self,c_CSRMatrixF *mat_new):             # <<<<<<<<<<<<<<
 *         self.mat=mat_new
 *         self.cache_maxcol=-1
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":489
 *         self.mat=mat_new
 *         self.cache_maxcol=-1
 *     cpdef CSRMatrixF fromVectors(self, vectors):             # <<<<<<<<<<<<<<
 *         cdef int spaceNeeded=0
 *         cdef int i=0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_3fromVectors(PyObject *__pyx_v_self, PyObject *__pyx_v_vectors); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_fromVectors(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_vectors, int __pyx_skip_dispatch) {
  int __pyx_v_spaceNeeded;
  int __pyx_v_i;
  int __pyx_v_j;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_vec = 0;
  struct CSRMatrix<float> *__pyx_v_c_result;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  unsigned int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromVectors", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_fromVectors); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_3fromVectors)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_vectors); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(__pyx_v_vectors);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_vectors);
        __Pyx_GIVEREF(__pyx_v_vectors);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":490
 *         self.cache_maxcol=-1
 *     cpdef CSRMatrixF fromVectors(self, vectors):
 *         cdef int spaceNeeded=0             # <<<<<<<<<<<<<<
 *         cdef int i=0
 *         cdef int j=0
 */
  __pyx_v_spaceNeeded = 0;

  /* "lurrn/sparsmat.pyx":491
 *     cpdef CSRMatrixF fromVectors(self, vectors):
 *         cdef int spaceNeeded=0
 *         cdef int i=0             # <<<<<<<<<<<<<<
 *         cdef int j=0
 *         cdef SparseVectorF vec
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":492
 *         cdef int spaceNeeded=0
 *         cdef int i=0
 *         cdef int j=0             # <<<<<<<<<<<<<<
 *         cdef SparseVectorF vec
 *         cdef c_CSRMatrixF *c_result
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":496
 *         cdef c_CSRMatrixF *c_result
 *         cdef CSRMatrixF result
 *         for vec in vectors:             # <<<<<<<<<<<<<<
 *             spaceNeeded+=vec.my_len
 *             i+=1
 */
  if (likely(PyList_CheckExact(__pyx_v_vectors)) || PyTuple_CheckExact(__pyx_v_vectors)) {
    __pyx_t_1 = __pyx_v_vectors; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_vectors); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_SparseVectorF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":497
 *         cdef CSRMatrixF result
 *         for vec in vectors:
 *             spaceNeeded+=vec.my_len             # <<<<<<<<<<<<<<
 *             i+=1
 *         c_result=new_csrF(i,spaceNeeded)
 */
    __pyx_v_spaceNeeded = (__pyx_v_spaceNeeded + __pyx_v_vec->my_len);

    /* "lurrn/sparsmat.pyx":498
 *         for vec in vectors:
 *             spaceNeeded+=vec.my_len
 *             i+=1             # <<<<<<<<<<<<<<
 *         c_result=new_csrF(i,spaceNeeded)
 *         i=0
 */
    __pyx_v_i = (__pyx_v_i + 1);

    /* "lurrn/sparsmat.pyx":496
 *         cdef c_CSRMatrixF *c_result
 *         cdef CSRMatrixF result
 *         for vec in vectors:             # <<<<<<<<<<<<<<
 *             spaceNeeded+=vec.my_len
 *             i+=1
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":499
 *             spaceNeeded+=vec.my_len
 *             i+=1
 *         c_result=new_csrF(i,spaceNeeded)             # <<<<<<<<<<<<<<
 *         i=0
 *         spaceNeeded=0
 */
  __pyx_v_c_result = new_csr<float>(__pyx_v_i, __pyx_v_spaceNeeded);

  /* "lurrn/sparsmat.pyx":500
 *             i+=1
 *         c_result=new_csrF(i,spaceNeeded)
 *         i=0             # <<<<<<<<<<<<<<
 *         spaceNeeded=0
 *         for vec in vectors:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":501
 *         c_result=new_csrF(i,spaceNeeded)
 *         i=0
 *         spaceNeeded=0             # <<<<<<<<<<<<<<
 *         for vec in vectors:
 *             c_result.offsets[i]=spaceNeeded
 */
  __pyx_v_spaceNeeded = 0;

  /* "lurrn/sparsmat.pyx":502
 *         i=0
 *         spaceNeeded=0
 *         for vec in vectors:             # <<<<<<<<<<<<<<
 *             c_result.offsets[i]=spaceNeeded
 *             for j from 0<=j<vec.my_len:
 */
  if (likely(PyList_CheckExact(__pyx_v_vectors)) || PyTuple_CheckExact(__pyx_v_vectors)) {
    __pyx_t_1 = __pyx_v_vectors; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_vectors); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_SparseVectorF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":503
 *         spaceNeeded=0
 *         for vec in vectors:
 *             c_result.offsets[i]=spaceNeeded             # <<<<<<<<<<<<<<
 *             for j from 0<=j<vec.my_len:
 *                  c_result.rightColumns[spaceNeeded]=vec.idx_ptr[j]
 */
    (__pyx_v_c_result->offsets[__pyx_v_i]) = __pyx_v_spaceNeeded;

    /* "lurrn/sparsmat.pyx":504
 *         for vec in vectors:
 *             c_result.offsets[i]=spaceNeeded
 *             for j from 0<=j<vec.my_len:             # <<<<<<<<<<<<<<
 *                  c_result.rightColumns[spaceNeeded]=vec.idx_ptr[j]
 *                  c_result.values[spaceNeeded]=vec.vals_ptr[j]
 */
    __pyx_t_8 = __pyx_v_vec->my_len;
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_8; __pyx_v_j++) {

      /* "lurrn/sparsmat.pyx":505
 *             c_result.offsets[i]=spaceNeeded
 *             for j from 0<=j<vec.my_len:
 *                  c_result.rightColumns[spaceNeeded]=vec.idx_ptr[j]             # <<<<<<<<<<<<<<
 *                  c_result.values[spaceNeeded]=vec.vals_ptr[j]
 *                  spaceNeeded+=1
 */
      (__pyx_v_c_result->rightColumns[__pyx_v_spaceNeeded]) = (__pyx_v_vec->idx_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":506
 *             for j from 0<=j<vec.my_len:
 *                  c_result.rightColumns[spaceNeeded]=vec.idx_ptr[j]
 *                  c_result.values[spaceNeeded]=vec.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                  spaceNeeded+=1
 *             i+=1
 */
      (__pyx_v_c_result->values[__pyx_v_spaceNeeded]) = (__pyx_v_vec->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":507
 *                  c_result.rightColumns[spaceNeeded]=vec.idx_ptr[j]
 *                  c_result.values[spaceNeeded]=vec.vals_ptr[j]
 *                  spaceNeeded+=1             # <<<<<<<<<<<<<<
 *             i+=1
 *         c_result.offsets[i]=spaceNeeded
 */
      __pyx_v_spaceNeeded = (__pyx_v_spaceNeeded + 1);
    }

    /* "lurrn/sparsmat.pyx":508
 *                  c_result.values[spaceNeeded]=vec.vals_ptr[j]
 *                  spaceNeeded+=1
 *             i+=1             # <<<<<<<<<<<<<<
 *         c_result.offsets[i]=spaceNeeded
 *         self.set_matrix(c_result)
 */
    __pyx_v_i = (__pyx_v_i + 1);

    /* "lurrn/sparsmat.pyx":502
 *         i=0
 *         spaceNeeded=0
 *         for vec in vectors:             # <<<<<<<<<<<<<<
 *             c_result.offsets[i]=spaceNeeded
 *             for j from 0<=j<vec.my_len:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":509
 *                  spaceNeeded+=1
 *             i+=1
 *         c_result.offsets[i]=spaceNeeded             # <<<<<<<<<<<<<<
 *         self.set_matrix(c_result)
 *         return self
 */
  (__pyx_v_c_result->offsets[__pyx_v_i]) = __pyx_v_spaceNeeded;

  /* "lurrn/sparsmat.pyx":510
 *             i+=1
 *         c_result.offsets[i]=spaceNeeded
 *         self.set_matrix(c_result)             # <<<<<<<<<<<<<<
 *         return self
 *     def __lshift__(CSRMatrixF self,int k):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self->__pyx_vtab)->set_matrix(__pyx_v_self, __pyx_v_c_result);

  /* "lurrn/sparsmat.pyx":511
 *         c_result.offsets[i]=spaceNeeded
 *         self.set_matrix(c_result)
 *         return self             # <<<<<<<<<<<<<<
 *     def __lshift__(CSRMatrixF self,int k):
 *         cdef CSRMatrixF result
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":489
 *         self.mat=mat_new
 *         self.cache_maxcol=-1
 *     cpdef CSRMatrixF fromVectors(self, vectors):             # <<<<<<<<<<<<<<
 *         cdef int spaceNeeded=0
 *         cdef int i=0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.fromVectors", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_vec);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_3fromVectors(PyObject *__pyx_v_self, PyObject *__pyx_v_vectors); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_3fromVectors(PyObject *__pyx_v_self, PyObject *__pyx_v_vectors) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fromVectors (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_2fromVectors(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self), ((PyObject *)__pyx_v_vectors));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_2fromVectors(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_vectors) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromVectors", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_fromVectors(__pyx_v_self, __pyx_v_vectors, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.fromVectors", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":512
 *         self.set_matrix(c_result)
 *         return self
 *     def __lshift__(CSRMatrixF self,int k):             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixF result
 *         cdef c_CSRMatrixF *c_mat
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_5__lshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_5__lshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__lshift__ (wrapper)", 0);
  assert(__pyx_arg_k); {
    __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.__lshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_CSRMatrixF, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_4__lshift__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self), ((int)__pyx_v_k));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_4__lshift__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, int __pyx_v_k) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_result = 0;
  struct CSRMatrix<float> *__pyx_v_c_mat;
  struct CSRMatrix<float> *__pyx_v_c_result;
  int __pyx_v_i;
  int __pyx_v_nnz;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct CSRMatrix<float> *__pyx_t_1;
  coordinate_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__lshift__", 0);

  /* "lurrn/sparsmat.pyx":517
 *         cdef c_CSRMatrixF *c_result
 *         cdef int i, nnz
 *         c_mat=self.mat             # <<<<<<<<<<<<<<
 *         nnz=c_mat.offsets[c_mat.num_rows]
 *         c_result=new_csrF(c_mat.num_rows, nnz)
 */
  __pyx_t_1 = __pyx_v_self->mat;
  __pyx_v_c_mat = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":518
 *         cdef int i, nnz
 *         c_mat=self.mat
 *         nnz=c_mat.offsets[c_mat.num_rows]             # <<<<<<<<<<<<<<
 *         c_result=new_csrF(c_mat.num_rows, nnz)
 *         for i from 0<=i<=c_mat.num_rows:
 */
  __pyx_v_nnz = (__pyx_v_c_mat->offsets[__pyx_v_c_mat->num_rows]);

  /* "lurrn/sparsmat.pyx":519
 *         c_mat=self.mat
 *         nnz=c_mat.offsets[c_mat.num_rows]
 *         c_result=new_csrF(c_mat.num_rows, nnz)             # <<<<<<<<<<<<<<
 *         for i from 0<=i<=c_mat.num_rows:
 *             c_result.offsets[i]=c_mat.offsets[i]
 */
  __pyx_v_c_result = new_csr<float>(__pyx_v_c_mat->num_rows, __pyx_v_nnz);

  /* "lurrn/sparsmat.pyx":520
 *         nnz=c_mat.offsets[c_mat.num_rows]
 *         c_result=new_csrF(c_mat.num_rows, nnz)
 *         for i from 0<=i<=c_mat.num_rows:             # <<<<<<<<<<<<<<
 *             c_result.offsets[i]=c_mat.offsets[i]
 *         for i from 0<=i<nnz:
 */
  __pyx_t_2 = __pyx_v_c_mat->num_rows;
  for (__pyx_v_i = 0; __pyx_v_i <= __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":521
 *         c_result=new_csrF(c_mat.num_rows, nnz)
 *         for i from 0<=i<=c_mat.num_rows:
 *             c_result.offsets[i]=c_mat.offsets[i]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<nnz:
 *             c_result.rightColumns[i]=c_mat.rightColumns[i]+k
 */
    (__pyx_v_c_result->offsets[__pyx_v_i]) = (__pyx_v_c_mat->offsets[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":522
 *         for i from 0<=i<=c_mat.num_rows:
 *             c_result.offsets[i]=c_mat.offsets[i]
 *         for i from 0<=i<nnz:             # <<<<<<<<<<<<<<
 *             c_result.rightColumns[i]=c_mat.rightColumns[i]+k
 *         for i from 0<=i<nnz:
 */
  __pyx_t_3 = __pyx_v_nnz;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":523
 *             c_result.offsets[i]=c_mat.offsets[i]
 *         for i from 0<=i<nnz:
 *             c_result.rightColumns[i]=c_mat.rightColumns[i]+k             # <<<<<<<<<<<<<<
 *         for i from 0<=i<nnz:
 *             c_result.values[i]=c_mat.values[i]
 */
    (__pyx_v_c_result->rightColumns[__pyx_v_i]) = ((__pyx_v_c_mat->rightColumns[__pyx_v_i]) + __pyx_v_k);
  }

  /* "lurrn/sparsmat.pyx":524
 *         for i from 0<=i<nnz:
 *             c_result.rightColumns[i]=c_mat.rightColumns[i]+k
 *         for i from 0<=i<nnz:             # <<<<<<<<<<<<<<
 *             c_result.values[i]=c_mat.values[i]
 *         result=CSRMatrixF()
 */
  __pyx_t_3 = __pyx_v_nnz;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":525
 *             c_result.rightColumns[i]=c_mat.rightColumns[i]+k
 *         for i from 0<=i<nnz:
 *             c_result.values[i]=c_mat.values[i]             # <<<<<<<<<<<<<<
 *         result=CSRMatrixF()
 *         result.set_matrix(c_result)
 */
    (__pyx_v_c_result->values[__pyx_v_i]) = (__pyx_v_c_mat->values[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":526
 *         for i from 0<=i<nnz:
 *             c_result.values[i]=c_mat.values[i]
 *         result=CSRMatrixF()             # <<<<<<<<<<<<<<
 *         result.set_matrix(c_result)
 *         return result
 */
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixF)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "lurrn/sparsmat.pyx":527
 *             c_result.values[i]=c_mat.values[i]
 *         result=CSRMatrixF()
 *         result.set_matrix(c_result)             # <<<<<<<<<<<<<<
 *         return result
 *     def __ilshift__(CSRMatrixF self, int k):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_result->__pyx_vtab)->set_matrix(__pyx_v_result, __pyx_v_c_result);

  /* "lurrn/sparsmat.pyx":528
 *         result=CSRMatrixF()
 *         result.set_matrix(c_result)
 *         return result             # <<<<<<<<<<<<<<
 *     def __ilshift__(CSRMatrixF self, int k):
 *         cdef c_CSRMatrixF *c_mat
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":512
 *         self.set_matrix(c_result)
 *         return self
 *     def __lshift__(CSRMatrixF self,int k):             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixF result
 *         cdef c_CSRMatrixF *c_mat
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.__lshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":529
 *         result.set_matrix(c_result)
 *         return result
 *     def __ilshift__(CSRMatrixF self, int k):             # <<<<<<<<<<<<<<
 *         cdef c_CSRMatrixF *c_mat
 *         cdef int i, nnz
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_7__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_7__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ilshift__ (wrapper)", 0);
  assert(__pyx_arg_k); {
    __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.__ilshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_6__ilshift__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self), ((int)__pyx_v_k));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_6__ilshift__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, int __pyx_v_k) {
  struct CSRMatrix<float> *__pyx_v_c_mat;
  int __pyx_v_i;
  int __pyx_v_nnz;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct CSRMatrix<float> *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("__ilshift__", 0);

  /* "lurrn/sparsmat.pyx":532
 *         cdef c_CSRMatrixF *c_mat
 *         cdef int i, nnz
 *         c_mat=self.mat             # <<<<<<<<<<<<<<
 *         nnz=c_mat.offsets[c_mat.num_rows]
 *         for i from 0<=i<nnz:
 */
  __pyx_t_1 = __pyx_v_self->mat;
  __pyx_v_c_mat = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":533
 *         cdef int i, nnz
 *         c_mat=self.mat
 *         nnz=c_mat.offsets[c_mat.num_rows]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<nnz:
 *             c_mat.rightColumns[i]+=k
 */
  __pyx_v_nnz = (__pyx_v_c_mat->offsets[__pyx_v_c_mat->num_rows]);

  /* "lurrn/sparsmat.pyx":534
 *         c_mat=self.mat
 *         nnz=c_mat.offsets[c_mat.num_rows]
 *         for i from 0<=i<nnz:             # <<<<<<<<<<<<<<
 *             c_mat.rightColumns[i]+=k
 *         return self
 */
  __pyx_t_2 = __pyx_v_nnz;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":535
 *         nnz=c_mat.offsets[c_mat.num_rows]
 *         for i from 0<=i<nnz:
 *             c_mat.rightColumns[i]+=k             # <<<<<<<<<<<<<<
 *         return self
 *     def print_csr(self):
 */
    __pyx_t_3 = __pyx_v_i;
    (__pyx_v_c_mat->rightColumns[__pyx_t_3]) = ((__pyx_v_c_mat->rightColumns[__pyx_t_3]) + __pyx_v_k);
  }

  /* "lurrn/sparsmat.pyx":536
 *         for i from 0<=i<nnz:
 *             c_mat.rightColumns[i]+=k
 *         return self             # <<<<<<<<<<<<<<
 *     def print_csr(self):
 *         print_csrF(self.mat)
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":529
 *         result.set_matrix(c_result)
 *         return result
 *     def __ilshift__(CSRMatrixF self, int k):             # <<<<<<<<<<<<<<
 *         cdef c_CSRMatrixF *c_mat
 *         cdef int i, nnz
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":537
 *             c_mat.rightColumns[i]+=k
 *         return self
 *     def print_csr(self):             # <<<<<<<<<<<<<<
 *         print_csrF(self.mat)
 *     def get_size(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_9print_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_9print_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("print_csr (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_8print_csr(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_8print_csr(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("print_csr", 0);

  /* "lurrn/sparsmat.pyx":538
 *         return self
 *     def print_csr(self):
 *         print_csrF(self.mat)             # <<<<<<<<<<<<<<
 *     def get_size(self):
 *         return self.mat.offsets[self.mat.num_rows]
 */
  print_csr<float>(__pyx_v_self->mat);

  /* "lurrn/sparsmat.pyx":537
 *             c_mat.rightColumns[i]+=k
 *         return self
 *     def print_csr(self):             # <<<<<<<<<<<<<<
 *         print_csrF(self.mat)
 *     def get_size(self):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":539
 *     def print_csr(self):
 *         print_csrF(self.mat)
 *     def get_size(self):             # <<<<<<<<<<<<<<
 *         return self.mat.offsets[self.mat.num_rows]
 *     def __len__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_11get_size(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_11get_size(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_10get_size(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_10get_size(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":540
 *         print_csrF(self.mat)
 *     def get_size(self):
 *         return self.mat.offsets[self.mat.num_rows]             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return self.mat.num_rows
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":539
 *     def print_csr(self):
 *         print_csrF(self.mat)
 *     def get_size(self):             # <<<<<<<<<<<<<<
 *         return self.mat.offsets[self.mat.num_rows]
 *     def __len__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":541
 *     def get_size(self):
 *         return self.mat.offsets[self.mat.num_rows]
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.mat.num_rows
 *     def __getitem__(self,k):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_13__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_13__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_12__len__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_12__len__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":542
 *         return self.mat.offsets[self.mat.num_rows]
 *     def __len__(self):
 *         return self.mat.num_rows             # <<<<<<<<<<<<<<
 *     def __getitem__(self,k):
 *         cdef int off1, off2
 */
  __pyx_r = __pyx_v_self->mat->num_rows;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":541
 *     def get_size(self):
 *         return self.mat.offsets[self.mat.num_rows]
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.mat.num_rows
 *     def __getitem__(self,k):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":543
 *     def __len__(self):
 *         return self.mat.num_rows
 *     def __getitem__(self,k):             # <<<<<<<<<<<<<<
 *         cdef int off1, off2
 *         cdef SparseVectorF res
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_15__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_k); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_15__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_14__getitem__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self), ((PyObject *)__pyx_v_k));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_14__getitem__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_k) {
  int __pyx_v_off1;
  int __pyx_v_off2;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_res = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "lurrn/sparsmat.pyx":546
 *         cdef int off1, off2
 *         cdef SparseVectorF res
 *         if not (k>=0 and k<self.mat.num_rows):             # <<<<<<<<<<<<<<
 *             raise IndexError
 *         off1=self.mat.offsets[k]
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_k, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = __Pyx_PyInt_From_coordinate_t(__pyx_v_self->mat->num_rows); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  __pyx_t_3 = ((!__pyx_t_1) != 0);
  if (__pyx_t_3) {

    /* "lurrn/sparsmat.pyx":547
 *         cdef SparseVectorF res
 *         if not (k>=0 and k<self.mat.num_rows):
 *             raise IndexError             # <<<<<<<<<<<<<<
 *         off1=self.mat.offsets[k]
 *         off2=self.mat.offsets[k+1]
 */
    __Pyx_Raise(__pyx_builtin_IndexError, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lurrn/sparsmat.pyx":548
 *         if not (k>=0 and k<self.mat.num_rows):
 *             raise IndexError
 *         off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *         off2=self.mat.offsets[k+1]
 *         if off1==off2:
 */
  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_k); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_t_5]);

  /* "lurrn/sparsmat.pyx":549
 *             raise IndexError
 *         off1=self.mat.offsets[k]
 *         off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *         if off1==off2:
 *             return emptyvec_F
 */
  __pyx_t_4 = PyNumber_Add(__pyx_v_k, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_off2 = (__pyx_v_self->mat->offsets[__pyx_t_5]);

  /* "lurrn/sparsmat.pyx":550
 *         off1=self.mat.offsets[k]
 *         off2=self.mat.offsets[k+1]
 *         if off1==off2:             # <<<<<<<<<<<<<<
 *             return emptyvec_F
 *         res=SparseVectorF()
 */
  __pyx_t_3 = ((__pyx_v_off1 == __pyx_v_off2) != 0);
  if (__pyx_t_3) {

    /* "lurrn/sparsmat.pyx":551
 *         off2=self.mat.offsets[k+1]
 *         if off1==off2:
 *             return emptyvec_F             # <<<<<<<<<<<<<<
 *         res=SparseVectorF()
 *         res.buf=self
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_5lurrn_8sparsmat_emptyvec_F));
    __pyx_r = ((PyObject *)__pyx_v_5lurrn_8sparsmat_emptyvec_F);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":552
 *         if off1==off2:
 *             return emptyvec_F
 *         res=SparseVectorF()             # <<<<<<<<<<<<<<
 *         res.buf=self
 *         res.my_len=off2-off1
 */
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorF)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_res = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "lurrn/sparsmat.pyx":553
 *             return emptyvec_F
 *         res=SparseVectorF()
 *         res.buf=self             # <<<<<<<<<<<<<<
 *         res.my_len=off2-off1
 *         res.vals_ptr=&self.mat.values[off1]
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __Pyx_GOTREF(__pyx_v_res->buf);
  __Pyx_DECREF(__pyx_v_res->buf);
  __pyx_v_res->buf = ((PyObject *)__pyx_v_self);

  /* "lurrn/sparsmat.pyx":554
 *         res=SparseVectorF()
 *         res.buf=self
 *         res.my_len=off2-off1             # <<<<<<<<<<<<<<
 *         res.vals_ptr=&self.mat.values[off1]
 *         res.idx_ptr=&self.mat.rightColumns[off1]
 */
  __pyx_v_res->my_len = (__pyx_v_off2 - __pyx_v_off1);

  /* "lurrn/sparsmat.pyx":555
 *         res.buf=self
 *         res.my_len=off2-off1
 *         res.vals_ptr=&self.mat.values[off1]             # <<<<<<<<<<<<<<
 *         res.idx_ptr=&self.mat.rightColumns[off1]
 *         return res
 */
  __pyx_v_res->vals_ptr = (&(__pyx_v_self->mat->values[__pyx_v_off1]));

  /* "lurrn/sparsmat.pyx":556
 *         res.my_len=off2-off1
 *         res.vals_ptr=&self.mat.values[off1]
 *         res.idx_ptr=&self.mat.rightColumns[off1]             # <<<<<<<<<<<<<<
 *         return res
 *     def item_iter(self):
 */
  __pyx_v_res->idx_ptr = (&(__pyx_v_self->mat->rightColumns[__pyx_v_off1]));

  /* "lurrn/sparsmat.pyx":557
 *         res.vals_ptr=&self.mat.values[off1]
 *         res.idx_ptr=&self.mat.rightColumns[off1]
 *         return res             # <<<<<<<<<<<<<<
 *     def item_iter(self):
 *         if self.mat.num_rows>0:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_res));
  __pyx_r = ((PyObject *)__pyx_v_res);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":543
 *     def __len__(self):
 *         return self.mat.num_rows
 *     def __getitem__(self,k):             # <<<<<<<<<<<<<<
 *         cdef int off1, off2
 *         cdef SparseVectorF res
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_res);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":558
 *         res.idx_ptr=&self.mat.rightColumns[off1]
 *         return res
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         if self.mat.num_rows>0:
 *             return CSRMatrixF_item_iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_17item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_17item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("item_iter (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_16item_iter(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_16item_iter(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("item_iter", 0);

  /* "lurrn/sparsmat.pyx":559
 *         return res
 *     def item_iter(self):
 *         if self.mat.num_rows>0:             # <<<<<<<<<<<<<<
 *             return CSRMatrixF_item_iter(self)
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_self->mat->num_rows > 0) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":560
 *     def item_iter(self):
 *         if self.mat.num_rows>0:
 *             return CSRMatrixF_item_iter(self)             # <<<<<<<<<<<<<<
 *         else:
 *             return ()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixF_item_iter)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":562
 *             return CSRMatrixF_item_iter(self)
 *         else:
 *             return ()             # <<<<<<<<<<<<<<
 *     def to_scipy(self):
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] data
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_r = __pyx_empty_tuple;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":558
 *         res.idx_ptr=&self.mat.rightColumns[off1]
 *         return res
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         if self.mat.num_rows>0:
 *             return CSRMatrixF_item_iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.item_iter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":563
 *         else:
 *             return ()
 *     def to_scipy(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] data
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indices
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_19to_scipy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_19to_scipy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_scipy (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_18to_scipy(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_18to_scipy(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self) {
  PyArrayObject *__pyx_v_data = 0;
  PyArrayObject *__pyx_v_indices = 0;
  PyArrayObject *__pyx_v_indptr = 0;
  int __pyx_v_num_rows;
  int __pyx_v_max_offset;
  int __pyx_v_i;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_data;
  __Pyx_Buffer __pyx_pybuffer_data;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indices;
  __Pyx_Buffer __pyx_pybuffer_indices;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indptr;
  __Pyx_Buffer __pyx_pybuffer_indptr;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  coordinate_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyArrayObject *__pyx_t_14 = NULL;
  PyArrayObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_t_19;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_scipy", 0);
  __pyx_pybuffer_data.pybuffer.buf = NULL;
  __pyx_pybuffer_data.refcount = 0;
  __pyx_pybuffernd_data.data = NULL;
  __pyx_pybuffernd_data.rcbuffer = &__pyx_pybuffer_data;
  __pyx_pybuffer_indices.pybuffer.buf = NULL;
  __pyx_pybuffer_indices.refcount = 0;
  __pyx_pybuffernd_indices.data = NULL;
  __pyx_pybuffernd_indices.rcbuffer = &__pyx_pybuffer_indices;
  __pyx_pybuffer_indptr.pybuffer.buf = NULL;
  __pyx_pybuffer_indptr.refcount = 0;
  __pyx_pybuffernd_indptr.data = NULL;
  __pyx_pybuffernd_indptr.rcbuffer = &__pyx_pybuffer_indptr;

  /* "lurrn/sparsmat.pyx":567
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indices
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indptr
 *         cdef int num_rows=self.mat.num_rows             # <<<<<<<<<<<<<<
 *         cdef int max_offset=self.mat.offsets[num_rows]
 *         cdef int i,j
 */
  __pyx_t_1 = __pyx_v_self->mat->num_rows;
  __pyx_v_num_rows = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":568
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indptr
 *         cdef int num_rows=self.mat.num_rows
 *         cdef int max_offset=self.mat.offsets[num_rows]             # <<<<<<<<<<<<<<
 *         cdef int i,j
 *         indptr=numpy.zeros(num_rows+1, numpy.int32)
 */
  __pyx_v_max_offset = (__pyx_v_self->mat->offsets[__pyx_v_num_rows]);

  /* "lurrn/sparsmat.pyx":570
 *         cdef int max_offset=self.mat.offsets[num_rows]
 *         cdef int i,j
 *         indptr=numpy.zeros(num_rows+1, numpy.int32)             # <<<<<<<<<<<<<<
 *         indices=numpy.zeros(max_offset, numpy.int32)
 *         data=numpy.zeros(max_offset, numpy.float32)
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_long((__pyx_v_num_rows + 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_int32); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_7 = 1;
    }
  }
  __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (__pyx_t_5) {
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_3 = 0;
  __pyx_t_6 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer, (PyObject*)__pyx_v_indptr, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
    }
    __pyx_pybuffernd_indptr.diminfo[0].strides = __pyx_pybuffernd_indptr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indptr.diminfo[0].shape = __pyx_pybuffernd_indptr.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_9 = 0;
  __pyx_v_indptr = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":571
 *         cdef int i,j
 *         indptr=numpy.zeros(num_rows+1, numpy.int32)
 *         indices=numpy.zeros(max_offset, numpy.int32)             # <<<<<<<<<<<<<<
 *         data=numpy.zeros(max_offset, numpy.float32)
 *         for i from 0<=i<=num_rows:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_max_offset); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int32); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
      __pyx_t_7 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_6) {
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_7, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_7, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_4 = 0;
  __pyx_t_3 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indices.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indices.rcbuffer->pybuffer, (PyObject*)__pyx_v_indices, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
      }
    }
    __pyx_pybuffernd_indices.diminfo[0].strides = __pyx_pybuffernd_indices.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indices.diminfo[0].shape = __pyx_pybuffernd_indices.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_14 = 0;
  __pyx_v_indices = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":572
 *         indptr=numpy.zeros(num_rows+1, numpy.int32)
 *         indices=numpy.zeros(max_offset, numpy.int32)
 *         data=numpy.zeros(max_offset, numpy.float32)             # <<<<<<<<<<<<<<
 *         for i from 0<=i<=num_rows:
 *             indptr[i]=self.mat.offsets[i]
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_max_offset); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float32); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_7 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_3) {
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_8 = 0;
  __pyx_t_4 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_15 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data.rcbuffer->pybuffer, (PyObject*)__pyx_v_data, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
    }
    __pyx_pybuffernd_data.diminfo[0].strides = __pyx_pybuffernd_data.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_data.diminfo[0].shape = __pyx_pybuffernd_data.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_15 = 0;
  __pyx_v_data = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":573
 *         indices=numpy.zeros(max_offset, numpy.int32)
 *         data=numpy.zeros(max_offset, numpy.float32)
 *         for i from 0<=i<=num_rows:             # <<<<<<<<<<<<<<
 *             indptr[i]=self.mat.offsets[i]
 *         for i from 0<=i<max_offset:
 */
  __pyx_t_10 = __pyx_v_num_rows;
  for (__pyx_v_i = 0; __pyx_v_i <= __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":574
 *         data=numpy.zeros(max_offset, numpy.float32)
 *         for i from 0<=i<=num_rows:
 *             indptr[i]=self.mat.offsets[i]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<max_offset:
 *             indices[i]=self.mat.rightColumns[i]
 */
    __pyx_t_16 = __pyx_v_i;
    __pyx_t_17 = -1;
    if (__pyx_t_16 < 0) {
      __pyx_t_16 += __pyx_pybuffernd_indptr.diminfo[0].shape;
      if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 0;
    } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_indptr.diminfo[0].shape)) __pyx_t_17 = 0;
    if (unlikely(__pyx_t_17 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_17);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_indptr.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_indptr.diminfo[0].strides) = (__pyx_v_self->mat->offsets[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":575
 *         for i from 0<=i<=num_rows:
 *             indptr[i]=self.mat.offsets[i]
 *         for i from 0<=i<max_offset:             # <<<<<<<<<<<<<<
 *             indices[i]=self.mat.rightColumns[i]
 *         for i from 0<=i<max_offset:
 */
  __pyx_t_10 = __pyx_v_max_offset;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":576
 *             indptr[i]=self.mat.offsets[i]
 *         for i from 0<=i<max_offset:
 *             indices[i]=self.mat.rightColumns[i]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<max_offset:
 *             data[i]=self.mat.values[i]
 */
    __pyx_t_17 = __pyx_v_i;
    __pyx_t_18 = -1;
    if (__pyx_t_17 < 0) {
      __pyx_t_17 += __pyx_pybuffernd_indices.diminfo[0].shape;
      if (unlikely(__pyx_t_17 < 0)) __pyx_t_18 = 0;
    } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_indices.diminfo[0].shape)) __pyx_t_18 = 0;
    if (unlikely(__pyx_t_18 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_18);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_indices.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_indices.diminfo[0].strides) = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":577
 *         for i from 0<=i<max_offset:
 *             indices[i]=self.mat.rightColumns[i]
 *         for i from 0<=i<max_offset:             # <<<<<<<<<<<<<<
 *             data[i]=self.mat.values[i]
 *         return (data,indices,indptr)
 */
  __pyx_t_10 = __pyx_v_max_offset;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":578
 *             indices[i]=self.mat.rightColumns[i]
 *         for i from 0<=i<max_offset:
 *             data[i]=self.mat.values[i]             # <<<<<<<<<<<<<<
 *         return (data,indices,indptr)
 *     cpdef int get_maxcol(self):
 */
    __pyx_t_18 = __pyx_v_i;
    __pyx_t_19 = -1;
    if (__pyx_t_18 < 0) {
      __pyx_t_18 += __pyx_pybuffernd_data.diminfo[0].shape;
      if (unlikely(__pyx_t_18 < 0)) __pyx_t_19 = 0;
    } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_data.diminfo[0].shape)) __pyx_t_19 = 0;
    if (unlikely(__pyx_t_19 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_19);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_data.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_data.diminfo[0].strides) = (__pyx_v_self->mat->values[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":579
 *         for i from 0<=i<max_offset:
 *             data[i]=self.mat.values[i]
 *         return (data,indices,indptr)             # <<<<<<<<<<<<<<
 *     cpdef int get_maxcol(self):
 *         cdef int result=0
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_data));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_data));
  __Pyx_INCREF(((PyObject *)__pyx_v_indices));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_indices));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_indices));
  __Pyx_INCREF(((PyObject *)__pyx_v_indptr));
  PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_indptr));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_indptr));
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":563
 *         else:
 *             return ()
 *     def to_scipy(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] data
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indices
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.to_scipy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_data);
  __Pyx_XDECREF((PyObject *)__pyx_v_indices);
  __Pyx_XDECREF((PyObject *)__pyx_v_indptr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":580
 *             data[i]=self.mat.values[i]
 *         return (data,indices,indptr)
 *     cpdef int get_maxcol(self):             # <<<<<<<<<<<<<<
 *         cdef int result=0
 *         cdef int col_max
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_21get_maxcol(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_10CSRMatrixF_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, int __pyx_skip_dispatch) {
  int __pyx_v_result;
  int __pyx_v_col_max;
  coordinate_t __pyx_v_i;
  int __pyx_v_off1;
  int __pyx_v_off2;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  coordinate_t __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_maxcol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_21get_maxcol)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_5;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":581
 *         return (data,indices,indptr)
 *     cpdef int get_maxcol(self):
 *         cdef int result=0             # <<<<<<<<<<<<<<
 *         cdef int col_max
 *         cdef coordinate_t i
 */
  __pyx_v_result = 0;

  /* "lurrn/sparsmat.pyx":585
 *         cdef coordinate_t i
 *         cdef int off1, off2
 *         if self.cache_maxcol>=0:             # <<<<<<<<<<<<<<
 *             return self.cache_maxcol
 *         for i from 0<=i<self.mat.num_rows:
 */
  __pyx_t_6 = ((__pyx_v_self->cache_maxcol >= 0) != 0);
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":586
 *         cdef int off1, off2
 *         if self.cache_maxcol>=0:
 *             return self.cache_maxcol             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.mat.num_rows:
 *            off1=self.mat.offsets[i]
 */
    __pyx_r = __pyx_v_self->cache_maxcol;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":587
 *         if self.cache_maxcol>=0:
 *             return self.cache_maxcol
 *         for i from 0<=i<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *            off1=self.mat.offsets[i]
 *            off2=self.mat.offsets[i+1]
 */
  __pyx_t_7 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":588
 *             return self.cache_maxcol
 *         for i from 0<=i<self.mat.num_rows:
 *            off1=self.mat.offsets[i]             # <<<<<<<<<<<<<<
 *            off2=self.mat.offsets[i+1]
 *            if off2>off1:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":589
 *         for i from 0<=i<self.mat.num_rows:
 *            off1=self.mat.offsets[i]
 *            off2=self.mat.offsets[i+1]             # <<<<<<<<<<<<<<
 *            if off2>off1:
 *               col_max=self.mat.rightColumns[off2-1]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_i + 1)]);

    /* "lurrn/sparsmat.pyx":590
 *            off1=self.mat.offsets[i]
 *            off2=self.mat.offsets[i+1]
 *            if off2>off1:             # <<<<<<<<<<<<<<
 *               col_max=self.mat.rightColumns[off2-1]
 *               if result<col_max:
 */
    __pyx_t_6 = ((__pyx_v_off2 > __pyx_v_off1) != 0);
    if (__pyx_t_6) {

      /* "lurrn/sparsmat.pyx":591
 *            off2=self.mat.offsets[i+1]
 *            if off2>off1:
 *               col_max=self.mat.rightColumns[off2-1]             # <<<<<<<<<<<<<<
 *               if result<col_max:
 *                  result=col_max
 */
      __pyx_v_col_max = (__pyx_v_self->mat->rightColumns[(__pyx_v_off2 - 1)]);

      /* "lurrn/sparsmat.pyx":592
 *            if off2>off1:
 *               col_max=self.mat.rightColumns[off2-1]
 *               if result<col_max:             # <<<<<<<<<<<<<<
 *                  result=col_max
 *         self.cache_maxcol=result
 */
      __pyx_t_6 = ((__pyx_v_result < __pyx_v_col_max) != 0);
      if (__pyx_t_6) {

        /* "lurrn/sparsmat.pyx":593
 *               col_max=self.mat.rightColumns[off2-1]
 *               if result<col_max:
 *                  result=col_max             # <<<<<<<<<<<<<<
 *         self.cache_maxcol=result
 *         return result
 */
        __pyx_v_result = __pyx_v_col_max;
        goto __pyx_L7;
      }
      __pyx_L7:;
      goto __pyx_L6;
    }
    __pyx_L6:;
  }

  /* "lurrn/sparsmat.pyx":594
 *               if result<col_max:
 *                  result=col_max
 *         self.cache_maxcol=result             # <<<<<<<<<<<<<<
 *         return result
 *     cpdef CSRMatrixD transform_mi(self):
 */
  __pyx_v_self->cache_maxcol = __pyx_v_result;

  /* "lurrn/sparsmat.pyx":595
 *                  result=col_max
 *         self.cache_maxcol=result
 *         return result             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixD transform_mi(self):
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":580
 *             data[i]=self.mat.values[i]
 *         return (data,indices,indptr)
 *     cpdef int get_maxcol(self):             # <<<<<<<<<<<<<<
 *         cdef int result=0
 *         cdef int col_max
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_WriteUnraisable("lurrn.sparsmat.CSRMatrixF.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_21get_maxcol(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_21get_maxcol(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_maxcol (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_20get_maxcol(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_20get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_get_maxcol(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":596
 *         self.cache_maxcol=result
 *         return result
 *     cpdef CSRMatrixD transform_mi(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_r
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_23transform_mi(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_transform_mi(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_marginals_l = 0;
  PyArrayObject *__pyx_v_marginals_r = 0;
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp = 0;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_i;
  int __pyx_v_off1;
  int __pyx_v_off2;
  double __pyx_v_v;
  double __pyx_v_log_v;
  double __pyx_v_log_N;
  double __pyx_v_log1;
  double __pyx_v_log2;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_l;
  __Pyx_Buffer __pyx_pybuffer_marginals_l;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_r;
  __Pyx_Buffer __pyx_pybuffer_marginals_r;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyArrayObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyArrayObject *__pyx_t_11 = NULL;
  double __pyx_t_12;
  coordinate_t __pyx_t_13;
  coordinate_t __pyx_t_14;
  coordinate_t __pyx_t_15;
  int __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  Py_ssize_t __pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_mi", 0);
  __pyx_pybuffer_marginals_l.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_l.refcount = 0;
  __pyx_pybuffernd_marginals_l.data = NULL;
  __pyx_pybuffernd_marginals_l.rcbuffer = &__pyx_pybuffer_marginals_l;
  __pyx_pybuffer_marginals_r.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_r.refcount = 0;
  __pyx_pybuffernd_marginals_r.data = NULL;
  __pyx_pybuffernd_marginals_r.rcbuffer = &__pyx_pybuffer_marginals_r;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transform_mi); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_23transform_mi)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":599
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_r
 *         cdef VecD2 tmp=VecD2()             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, i
 *         cdef int off1, off2
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":603
 *         cdef int off1, off2
 *         cdef double v, log_v, log_N, log1, log2
 *         if self.mat.num_rows<100000:             # <<<<<<<<<<<<<<
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 */
  __pyx_t_5 = ((__pyx_v_self->mat->num_rows < 100000) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":604
 *         cdef double v, log_v, log_N, log1, log2
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         else:
 *             tmp.vec.reserve(100000)
 */
    __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":606
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 *             tmp.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()
 */
    __pyx_v_tmp->vec.reserve(100000);
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":607
 *         else:
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()             # <<<<<<<<<<<<<<
 *         marginals_r=self.right_marginals()
 *         log_N=log(marginals_l.sum())
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_left_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_l, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_marginals_l.diminfo[0].strides = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_l.diminfo[0].shape = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = 0;
  __pyx_v_marginals_l = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":608
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()             # <<<<<<<<<<<<<<
 *         log_N=log(marginals_l.sum())
 *         for k from 0<=k<self.mat.num_rows:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_right_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_r, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
      }
    }
    __pyx_pybuffernd_marginals_r.diminfo[0].strides = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_r.diminfo[0].shape = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_11 = 0;
  __pyx_v_marginals_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":609
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()
 *         log_N=log(marginals_l.sum())             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.num_rows:
 *             log1=log(marginals_l[k])-log_N
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_marginals_l), __pyx_n_s_sum); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_log_N = log(__pyx_t_12);

  /* "lurrn/sparsmat.pyx":610
 *         marginals_r=self.right_marginals()
 *         log_N=log(marginals_l.sum())
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             log1=log(marginals_l[k])-log_N
 *             off1=self.mat.offsets[k]
 */
  __pyx_t_13 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_13; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":611
 *         log_N=log(marginals_l.sum())
 *         for k from 0<=k<self.mat.num_rows:
 *             log1=log(marginals_l[k])-log_N             # <<<<<<<<<<<<<<
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 */
    __pyx_t_14 = __pyx_v_k;
    __pyx_t_7 = -1;
    if (unlikely(__pyx_t_14 >= (size_t)__pyx_pybuffernd_marginals_l.diminfo[0].shape)) __pyx_t_7 = 0;
    if (unlikely(__pyx_t_7 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_7);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_log1 = (log((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_marginals_l.diminfo[0].strides))) - __pyx_v_log_N);

    /* "lurrn/sparsmat.pyx":612
 *         for k from 0<=k<self.mat.num_rows:
 *             log1=log(marginals_l[k])-log_N
 *             off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":613
 *             log1=log(marginals_l[k])-log_N
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":614
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                v=self.mat.values[i]
 *                if v>0:
 */
    __pyx_t_7 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":615
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]             # <<<<<<<<<<<<<<
 *                if v>0:
 *                    log2=log(marginals_r[self.mat.rightColumns[i]])
 */
      __pyx_v_v = (__pyx_v_self->mat->values[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":616
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 *                if v>0:             # <<<<<<<<<<<<<<
 *                    log2=log(marginals_r[self.mat.rightColumns[i]])
 *                    log_v=log(v)-log2-log1
 */
      __pyx_t_5 = ((__pyx_v_v > 0.0) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":617
 *                v=self.mat.values[i]
 *                if v>0:
 *                    log2=log(marginals_r[self.mat.rightColumns[i]])             # <<<<<<<<<<<<<<
 *                    log_v=log(v)-log2-log1
 *                    if log_v>0:
 */
        __pyx_t_15 = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);
        __pyx_t_16 = -1;
        if (unlikely(__pyx_t_15 >= (size_t)__pyx_pybuffernd_marginals_r.diminfo[0].shape)) __pyx_t_16 = 0;
        if (unlikely(__pyx_t_16 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_16);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_log2 = log((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_marginals_r.diminfo[0].strides)));

        /* "lurrn/sparsmat.pyx":618
 *                if v>0:
 *                    log2=log(marginals_r[self.mat.rightColumns[i]])
 *                    log_v=log(v)-log2-log1             # <<<<<<<<<<<<<<
 *                    if log_v>0:
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 */
        __pyx_v_log_v = ((log(__pyx_v_v) - __pyx_v_log2) - __pyx_v_log1);

        /* "lurrn/sparsmat.pyx":619
 *                    log2=log(marginals_r[self.mat.rightColumns[i]])
 *                    log_v=log(v)-log2-log1
 *                    if log_v>0:             # <<<<<<<<<<<<<<
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()
 */
        __pyx_t_5 = ((__pyx_v_log_v > 0.0) != 0);
        if (__pyx_t_5) {

          /* "lurrn/sparsmat.pyx":620
 *                    log_v=log(v)-log2-log1
 *                    if log_v>0:
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)             # <<<<<<<<<<<<<<
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_mi_discount(self):
 */
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->mat->rightColumns[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_17 = PyFloat_FromDouble(__pyx_v_log_v); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_18 = NULL;
          __pyx_t_19 = 0;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_18)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_18);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
              __pyx_t_19 = 1;
            }
          }
          __pyx_t_20 = PyTuple_New(3+__pyx_t_19); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_20);
          if (__pyx_t_18) {
            PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); __pyx_t_18 = NULL;
          }
          PyTuple_SET_ITEM(__pyx_t_20, 0+__pyx_t_19, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_20, 1+__pyx_t_19, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_20, 2+__pyx_t_19, __pyx_t_17);
          __Pyx_GIVEREF(__pyx_t_17);
          __pyx_t_3 = 0;
          __pyx_t_4 = 0;
          __pyx_t_17 = 0;
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_20, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          goto __pyx_L9;
        }
        __pyx_L9:;
        goto __pyx_L8;
      }
      __pyx_L8:;
    }
  }

  /* "lurrn/sparsmat.pyx":621
 *                    if log_v>0:
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixD transform_mi_discount(self):
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp->__pyx_vtab)->to_csr(__pyx_v_tmp, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":596
 *         self.cache_maxcol=result
 *         return result
 *     cpdef CSRMatrixD transform_mi(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_r
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_20);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.transform_mi", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_l);
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_r);
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_23transform_mi(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_23transform_mi(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("transform_mi (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_22transform_mi(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_22transform_mi(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_mi", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_transform_mi(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.transform_mi", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":622
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_mi_discount(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_r
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_25transform_mi_discount(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_transform_mi_discount(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_marginals_l = 0;
  PyArrayObject *__pyx_v_marginals_r = 0;
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp = 0;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_i;
  int __pyx_v_off1;
  int __pyx_v_off2;
  double __pyx_v_marg_l;
  double __pyx_v_marg_r;
  double __pyx_v_log_corr1;
  double __pyx_v_log_corr2;
  double __pyx_v_v;
  double __pyx_v_log_v;
  double __pyx_v_log_N;
  double __pyx_v_log1;
  double __pyx_v_log2;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_l;
  __Pyx_Buffer __pyx_pybuffer_marginals_l;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_r;
  __Pyx_Buffer __pyx_pybuffer_marginals_r;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyArrayObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyArrayObject *__pyx_t_11 = NULL;
  double __pyx_t_12;
  coordinate_t __pyx_t_13;
  coordinate_t __pyx_t_14;
  coordinate_t __pyx_t_15;
  int __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  Py_ssize_t __pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_mi_discount", 0);
  __pyx_pybuffer_marginals_l.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_l.refcount = 0;
  __pyx_pybuffernd_marginals_l.data = NULL;
  __pyx_pybuffernd_marginals_l.rcbuffer = &__pyx_pybuffer_marginals_l;
  __pyx_pybuffer_marginals_r.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_r.refcount = 0;
  __pyx_pybuffernd_marginals_r.data = NULL;
  __pyx_pybuffernd_marginals_r.rcbuffer = &__pyx_pybuffer_marginals_r;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transform_mi_discount); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_25transform_mi_discount)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":625
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_r
 *         cdef VecD2 tmp=VecD2()             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, i
 *         cdef int off1, off2
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":630
 *         cdef double marg_l, marg_r, log_corr1, log_corr2
 *         cdef double v, log_v, log_N, log1, log2
 *         if self.mat.num_rows<100000:             # <<<<<<<<<<<<<<
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 */
  __pyx_t_5 = ((__pyx_v_self->mat->num_rows < 100000) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":631
 *         cdef double v, log_v, log_N, log1, log2
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         else:
 *             tmp.vec.reserve(100000)
 */
    __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":633
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 *             tmp.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()
 */
    __pyx_v_tmp->vec.reserve(100000);
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":634
 *         else:
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()             # <<<<<<<<<<<<<<
 *         marginals_r=self.right_marginals()
 *         log_N=log(marginals_l.sum())
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_left_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_l, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_marginals_l.diminfo[0].strides = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_l.diminfo[0].shape = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = 0;
  __pyx_v_marginals_l = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":635
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()             # <<<<<<<<<<<<<<
 *         log_N=log(marginals_l.sum())
 *         for k from 0<=k<self.mat.num_rows:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_right_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_r, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
      }
    }
    __pyx_pybuffernd_marginals_r.diminfo[0].strides = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_r.diminfo[0].shape = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_11 = 0;
  __pyx_v_marginals_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":636
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()
 *         log_N=log(marginals_l.sum())             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.num_rows:
 *             marg_l=marginals_l[k]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_marginals_l), __pyx_n_s_sum); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_log_N = log(__pyx_t_12);

  /* "lurrn/sparsmat.pyx":637
 *         marginals_r=self.right_marginals()
 *         log_N=log(marginals_l.sum())
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             marg_l=marginals_l[k]
 *             log1=log(marg_l)-log_N
 */
  __pyx_t_13 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_13; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":638
 *         log_N=log(marginals_l.sum())
 *         for k from 0<=k<self.mat.num_rows:
 *             marg_l=marginals_l[k]             # <<<<<<<<<<<<<<
 *             log1=log(marg_l)-log_N
 *             off1=self.mat.offsets[k]
 */
    __pyx_t_14 = __pyx_v_k;
    __pyx_t_7 = -1;
    if (unlikely(__pyx_t_14 >= (size_t)__pyx_pybuffernd_marginals_l.diminfo[0].shape)) __pyx_t_7 = 0;
    if (unlikely(__pyx_t_7 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_7);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_marg_l = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_marginals_l.diminfo[0].strides));

    /* "lurrn/sparsmat.pyx":639
 *         for k from 0<=k<self.mat.num_rows:
 *             marg_l=marginals_l[k]
 *             log1=log(marg_l)-log_N             # <<<<<<<<<<<<<<
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 */
    __pyx_v_log1 = (log(__pyx_v_marg_l) - __pyx_v_log_N);

    /* "lurrn/sparsmat.pyx":640
 *             marg_l=marginals_l[k]
 *             log1=log(marg_l)-log_N
 *             off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":641
 *             log1=log(marg_l)-log_N
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":642
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                v=self.mat.values[i]
 *                if v>0:
 */
    __pyx_t_7 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":643
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]             # <<<<<<<<<<<<<<
 *                if v>0:
 *                    marg_r=marginals_r[self.mat.rightColumns[i]]
 */
      __pyx_v_v = (__pyx_v_self->mat->values[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":644
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 *                if v>0:             # <<<<<<<<<<<<<<
 *                    marg_r=marginals_r[self.mat.rightColumns[i]]
 *                    log2=log(marg_r)
 */
      __pyx_t_5 = ((__pyx_v_v > 0.0) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":645
 *                v=self.mat.values[i]
 *                if v>0:
 *                    marg_r=marginals_r[self.mat.rightColumns[i]]             # <<<<<<<<<<<<<<
 *                    log2=log(marg_r)
 *                    log_corr1=log1p(-1.0/(v+1.0))
 */
        __pyx_t_15 = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);
        __pyx_t_16 = -1;
        if (unlikely(__pyx_t_15 >= (size_t)__pyx_pybuffernd_marginals_r.diminfo[0].shape)) __pyx_t_16 = 0;
        if (unlikely(__pyx_t_16 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_16);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_marg_r = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_marginals_r.diminfo[0].strides));

        /* "lurrn/sparsmat.pyx":646
 *                if v>0:
 *                    marg_r=marginals_r[self.mat.rightColumns[i]]
 *                    log2=log(marg_r)             # <<<<<<<<<<<<<<
 *                    log_corr1=log1p(-1.0/(v+1.0))
 *                    if marg_l<marg_r:
 */
        __pyx_v_log2 = log(__pyx_v_marg_r);

        /* "lurrn/sparsmat.pyx":647
 *                    marg_r=marginals_r[self.mat.rightColumns[i]]
 *                    log2=log(marg_r)
 *                    log_corr1=log1p(-1.0/(v+1.0))             # <<<<<<<<<<<<<<
 *                    if marg_l<marg_r:
 *                        log_corr2=log1p(-1.0/(marg_l+1.0))
 */
        __pyx_t_12 = (__pyx_v_v + 1.0);
        if (unlikely(__pyx_t_12 == 0)) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
          #endif
          PyErr_SetString(PyExc_ZeroDivisionError, "float division");
          #ifdef WITH_THREAD
          PyGILState_Release(__pyx_gilstate_save);
          #endif
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_log_corr1 = log1p((-1.0 / __pyx_t_12));

        /* "lurrn/sparsmat.pyx":648
 *                    log2=log(marg_r)
 *                    log_corr1=log1p(-1.0/(v+1.0))
 *                    if marg_l<marg_r:             # <<<<<<<<<<<<<<
 *                        log_corr2=log1p(-1.0/(marg_l+1.0))
 *                    else:
 */
        __pyx_t_5 = ((__pyx_v_marg_l < __pyx_v_marg_r) != 0);
        if (__pyx_t_5) {

          /* "lurrn/sparsmat.pyx":649
 *                    log_corr1=log1p(-1.0/(v+1.0))
 *                    if marg_l<marg_r:
 *                        log_corr2=log1p(-1.0/(marg_l+1.0))             # <<<<<<<<<<<<<<
 *                    else:
 *                        log_corr2=log1p(-1.0/(marg_r+1.0))
 */
          __pyx_t_12 = (__pyx_v_marg_l + 1.0);
          if (unlikely(__pyx_t_12 == 0)) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
            #endif
            PyErr_SetString(PyExc_ZeroDivisionError, "float division");
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_log_corr2 = log1p((-1.0 / __pyx_t_12));
          goto __pyx_L9;
        }
        /*else*/ {

          /* "lurrn/sparsmat.pyx":651
 *                        log_corr2=log1p(-1.0/(marg_l+1.0))
 *                    else:
 *                        log_corr2=log1p(-1.0/(marg_r+1.0))             # <<<<<<<<<<<<<<
 *                    log_v=log(v)-log2-log1+log_corr1+log_corr2
 *                    if log_v>0:
 */
          __pyx_t_12 = (__pyx_v_marg_r + 1.0);
          if (unlikely(__pyx_t_12 == 0)) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
            #endif
            PyErr_SetString(PyExc_ZeroDivisionError, "float division");
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_log_corr2 = log1p((-1.0 / __pyx_t_12));
        }
        __pyx_L9:;

        /* "lurrn/sparsmat.pyx":652
 *                    else:
 *                        log_corr2=log1p(-1.0/(marg_r+1.0))
 *                    log_v=log(v)-log2-log1+log_corr1+log_corr2             # <<<<<<<<<<<<<<
 *                    if log_v>0:
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 */
        __pyx_v_log_v = ((((log(__pyx_v_v) - __pyx_v_log2) - __pyx_v_log1) + __pyx_v_log_corr1) + __pyx_v_log_corr2);

        /* "lurrn/sparsmat.pyx":653
 *                        log_corr2=log1p(-1.0/(marg_r+1.0))
 *                    log_v=log(v)-log2-log1+log_corr1+log_corr2
 *                    if log_v>0:             # <<<<<<<<<<<<<<
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()
 */
        __pyx_t_5 = ((__pyx_v_log_v > 0.0) != 0);
        if (__pyx_t_5) {

          /* "lurrn/sparsmat.pyx":654
 *                    log_v=log(v)-log2-log1+log_corr1+log_corr2
 *                    if log_v>0:
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)             # <<<<<<<<<<<<<<
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_ll(self):
 */
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->mat->rightColumns[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_17 = PyFloat_FromDouble(__pyx_v_log_v); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_18 = NULL;
          __pyx_t_19 = 0;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_18)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_18);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
              __pyx_t_19 = 1;
            }
          }
          __pyx_t_20 = PyTuple_New(3+__pyx_t_19); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_20);
          if (__pyx_t_18) {
            PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); __pyx_t_18 = NULL;
          }
          PyTuple_SET_ITEM(__pyx_t_20, 0+__pyx_t_19, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_20, 1+__pyx_t_19, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_20, 2+__pyx_t_19, __pyx_t_17);
          __Pyx_GIVEREF(__pyx_t_17);
          __pyx_t_3 = 0;
          __pyx_t_4 = 0;
          __pyx_t_17 = 0;
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_20, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          goto __pyx_L10;
        }
        __pyx_L10:;
        goto __pyx_L8;
      }
      __pyx_L8:;
    }
  }

  /* "lurrn/sparsmat.pyx":655
 *                    if log_v>0:
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixD transform_ll(self):
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp->__pyx_vtab)->to_csr(__pyx_v_tmp, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":622
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_mi_discount(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_r
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_20);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.transform_mi_discount", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_l);
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_r);
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_25transform_mi_discount(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_25transform_mi_discount(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("transform_mi_discount (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_24transform_mi_discount(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_24transform_mi_discount(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_mi_discount", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_transform_mi_discount(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.transform_mi_discount", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":656
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_ll(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_r
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_27transform_ll(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_transform_ll(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_marginals_l = 0;
  PyArrayObject *__pyx_v_marginals_r = 0;
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp = 0;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_i;
  int __pyx_v_off1;
  int __pyx_v_off2;
  double __pyx_v_c;
  double __pyx_v_c1;
  double __pyx_v_c2;
  double __pyx_v_p;
  double __pyx_v_p1;
  double __pyx_v_pn1;
  double __pyx_v_ll;
  PyObject *__pyx_v_c12 = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_l;
  __Pyx_Buffer __pyx_pybuffer_marginals_l;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_r;
  __Pyx_Buffer __pyx_pybuffer_marginals_r;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyArrayObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyArrayObject *__pyx_t_11 = NULL;
  double __pyx_t_12;
  coordinate_t __pyx_t_13;
  coordinate_t __pyx_t_14;
  coordinate_t __pyx_t_15;
  int __pyx_t_16;
  double __pyx_t_17;
  double __pyx_t_18;
  double __pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  Py_ssize_t __pyx_t_22;
  PyObject *__pyx_t_23 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_ll", 0);
  __pyx_pybuffer_marginals_l.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_l.refcount = 0;
  __pyx_pybuffernd_marginals_l.data = NULL;
  __pyx_pybuffernd_marginals_l.rcbuffer = &__pyx_pybuffer_marginals_l;
  __pyx_pybuffer_marginals_r.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_r.refcount = 0;
  __pyx_pybuffernd_marginals_r.data = NULL;
  __pyx_pybuffernd_marginals_r.rcbuffer = &__pyx_pybuffer_marginals_r;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transform_ll); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_27transform_ll)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":659
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_r
 *         cdef VecD2 tmp=VecD2()             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, i
 *         cdef int off1, off2
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":664
 *         cdef double marg_l, marg_r, c, c1, c2
 *         cdef double p, p1, pn1, ll
 *         if self.mat.num_rows<100000:             # <<<<<<<<<<<<<<
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 */
  __pyx_t_5 = ((__pyx_v_self->mat->num_rows < 100000) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":665
 *         cdef double p, p1, pn1, ll
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         else:
 *             tmp.vec.reserve(100000)
 */
    __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":667
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 *             tmp.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()
 */
    __pyx_v_tmp->vec.reserve(100000);
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":668
 *         else:
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()             # <<<<<<<<<<<<<<
 *         marginals_r=self.right_marginals()
 *         c=marginals_l.sum()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_left_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_l, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_marginals_l.diminfo[0].strides = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_l.diminfo[0].shape = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = 0;
  __pyx_v_marginals_l = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":669
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()             # <<<<<<<<<<<<<<
 *         c=marginals_l.sum()
 *         for k from 0<=k<self.mat.num_rows:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_right_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_r, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
      }
    }
    __pyx_pybuffernd_marginals_r.diminfo[0].strides = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_r.diminfo[0].shape = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_11 = 0;
  __pyx_v_marginals_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":670
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()
 *         c=marginals_l.sum()             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.num_rows:
 *             c1=marginals_l[k]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_marginals_l), __pyx_n_s_sum); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_c = __pyx_t_12;

  /* "lurrn/sparsmat.pyx":671
 *         marginals_r=self.right_marginals()
 *         c=marginals_l.sum()
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             c1=marginals_l[k]
 *             off1=self.mat.offsets[k]
 */
  __pyx_t_13 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_13; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":672
 *         c=marginals_l.sum()
 *         for k from 0<=k<self.mat.num_rows:
 *             c1=marginals_l[k]             # <<<<<<<<<<<<<<
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 */
    __pyx_t_14 = __pyx_v_k;
    __pyx_t_7 = -1;
    if (unlikely(__pyx_t_14 >= (size_t)__pyx_pybuffernd_marginals_l.diminfo[0].shape)) __pyx_t_7 = 0;
    if (unlikely(__pyx_t_7 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_7);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_c1 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_marginals_l.diminfo[0].strides));

    /* "lurrn/sparsmat.pyx":673
 *         for k from 0<=k<self.mat.num_rows:
 *             c1=marginals_l[k]
 *             off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":674
 *             c1=marginals_l[k]
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                c12=self.mat.values[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":675
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                c12=self.mat.values[i]
 *                if c12>0:
 */
    __pyx_t_7 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":676
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                c12=self.mat.values[i]             # <<<<<<<<<<<<<<
 *                if c12>0:
 *                    c2=marginals_r[self.mat.rightColumns[i]]
 */
      __pyx_t_1 = PyFloat_FromDouble((__pyx_v_self->mat->values[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_c12, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "lurrn/sparsmat.pyx":677
 *             for i from off1<=i<off2:
 *                c12=self.mat.values[i]
 *                if c12>0:             # <<<<<<<<<<<<<<
 *                    c2=marginals_r[self.mat.rightColumns[i]]
 *                    p=c2/c
 */
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_c12, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":678
 *                c12=self.mat.values[i]
 *                if c12>0:
 *                    c2=marginals_r[self.mat.rightColumns[i]]             # <<<<<<<<<<<<<<
 *                    p=c2/c
 *                    p1=c12/c1
 */
        __pyx_t_15 = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);
        __pyx_t_16 = -1;
        if (unlikely(__pyx_t_15 >= (size_t)__pyx_pybuffernd_marginals_r.diminfo[0].shape)) __pyx_t_16 = 0;
        if (unlikely(__pyx_t_16 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_16);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_c2 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_marginals_r.diminfo[0].strides));

        /* "lurrn/sparsmat.pyx":679
 *                if c12>0:
 *                    c2=marginals_r[self.mat.rightColumns[i]]
 *                    p=c2/c             # <<<<<<<<<<<<<<
 *                    p1=c12/c1
 *                    if p1>p:
 */
        if (unlikely(__pyx_v_c == 0)) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
          #endif
          PyErr_SetString(PyExc_ZeroDivisionError, "float division");
          #ifdef WITH_THREAD
          PyGILState_Release(__pyx_gilstate_save);
          #endif
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_p = (__pyx_v_c2 / __pyx_v_c);

        /* "lurrn/sparsmat.pyx":680
 *                    c2=marginals_r[self.mat.rightColumns[i]]
 *                    p=c2/c
 *                    p1=c12/c1             # <<<<<<<<<<<<<<
 *                    if p1>p:
 *                        pn1=(c2-c12)/(c-c1)
 */
        __pyx_t_1 = PyFloat_FromDouble(__pyx_v_c1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_v_c12, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_v_p1 = __pyx_t_12;

        /* "lurrn/sparsmat.pyx":681
 *                    p=c2/c
 *                    p1=c12/c1
 *                    if p1>p:             # <<<<<<<<<<<<<<
 *                        pn1=(c2-c12)/(c-c1)
 *                        ll=(-logB(c1,p,c12)-logB(c-c1,p,c2-c12)
 */
        __pyx_t_5 = ((__pyx_v_p1 > __pyx_v_p) != 0);
        if (__pyx_t_5) {

          /* "lurrn/sparsmat.pyx":682
 *                    p1=c12/c1
 *                    if p1>p:
 *                        pn1=(c2-c12)/(c-c1)             # <<<<<<<<<<<<<<
 *                        ll=(-logB(c1,p,c12)-logB(c-c1,p,c2-c12)
 *                            +logB(c1,p1,c12)+logB(c-c1,pn1,c2-c12))
 */
          __pyx_t_2 = PyFloat_FromDouble(__pyx_v_c2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_1 = PyNumber_Subtract(__pyx_t_2, __pyx_v_c12); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = PyFloat_FromDouble((__pyx_v_c - __pyx_v_c1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_v_pn1 = __pyx_t_12;

          /* "lurrn/sparsmat.pyx":683
 *                    if p1>p:
 *                        pn1=(c2-c12)/(c-c1)
 *                        ll=(-logB(c1,p,c12)-logB(c-c1,p,c2-c12)             # <<<<<<<<<<<<<<
 *                            +logB(c1,p1,c12)+logB(c-c1,pn1,c2-c12))
 *                        tmp.add_count(k,self.mat.rightColumns[i],ll)
 */
          __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_v_c12); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_3 = PyFloat_FromDouble(__pyx_v_c2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_2 = PyNumber_Subtract(__pyx_t_3, __pyx_v_c12); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_17 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_17 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "lurrn/sparsmat.pyx":684
 *                        pn1=(c2-c12)/(c-c1)
 *                        ll=(-logB(c1,p,c12)-logB(c-c1,p,c2-c12)
 *                            +logB(c1,p1,c12)+logB(c-c1,pn1,c2-c12))             # <<<<<<<<<<<<<<
 *                        tmp.add_count(k,self.mat.rightColumns[i],ll)
 *         return tmp.to_csr()
 */
          __pyx_t_18 = __pyx_PyFloat_AsDouble(__pyx_v_c12); if (unlikely((__pyx_t_18 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_2 = PyFloat_FromDouble(__pyx_v_c2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = PyNumber_Subtract(__pyx_t_2, __pyx_v_c12); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_19 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_19 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_v_ll = ((((-__pyx_f_5lurrn_8sparsmat_logB(__pyx_v_c1, __pyx_v_p, __pyx_t_12)) - __pyx_f_5lurrn_8sparsmat_logB((__pyx_v_c - __pyx_v_c1), __pyx_v_p, __pyx_t_17)) + __pyx_f_5lurrn_8sparsmat_logB(__pyx_v_c1, __pyx_v_p1, __pyx_t_18)) + __pyx_f_5lurrn_8sparsmat_logB((__pyx_v_c - __pyx_v_c1), __pyx_v_pn1, __pyx_t_19));

          /* "lurrn/sparsmat.pyx":685
 *                        ll=(-logB(c1,p,c12)-logB(c-c1,p,c2-c12)
 *                            +logB(c1,p1,c12)+logB(c-c1,pn1,c2-c12))
 *                        tmp.add_count(k,self.mat.rightColumns[i],ll)             # <<<<<<<<<<<<<<
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_l1(self):
 */
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_1 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_4 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->mat->rightColumns[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_20 = PyFloat_FromDouble(__pyx_v_ll); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_20);
          __pyx_t_21 = NULL;
          __pyx_t_22 = 0;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_21)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_21);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
              __pyx_t_22 = 1;
            }
          }
          __pyx_t_23 = PyTuple_New(3+__pyx_t_22); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_23);
          if (__pyx_t_21) {
            PyTuple_SET_ITEM(__pyx_t_23, 0, __pyx_t_21); __Pyx_GIVEREF(__pyx_t_21); __pyx_t_21 = NULL;
          }
          PyTuple_SET_ITEM(__pyx_t_23, 0+__pyx_t_22, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_23, 1+__pyx_t_22, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_23, 2+__pyx_t_22, __pyx_t_20);
          __Pyx_GIVEREF(__pyx_t_20);
          __pyx_t_1 = 0;
          __pyx_t_4 = 0;
          __pyx_t_20 = 0;
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_23, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          goto __pyx_L9;
        }
        __pyx_L9:;
        goto __pyx_L8;
      }
      __pyx_L8:;
    }
  }

  /* "lurrn/sparsmat.pyx":686
 *                            +logB(c1,p1,c12)+logB(c-c1,pn1,c2-c12))
 *                        tmp.add_count(k,self.mat.rightColumns[i],ll)
 *         return tmp.to_csr()             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixD transform_l1(self):
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp->__pyx_vtab)->to_csr(__pyx_v_tmp, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":656
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_ll(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_r
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_23);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.transform_ll", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_l);
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_r);
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XDECREF(__pyx_v_c12);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_27transform_ll(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_27transform_ll(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("transform_ll (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_26transform_ll(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_26transform_ll(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_ll", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_transform_ll(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.transform_ll", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":687
 *                        tmp.add_count(k,self.mat.rightColumns[i],ll)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_l1(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 *         cdef VecD2 tmp=VecD2()
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_29transform_l1(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_transform_l1(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_marginals_l = 0;
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp = 0;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_i;
  int __pyx_v_off1;
  int __pyx_v_off2;
  double __pyx_v_v;
  double __pyx_v_marg_l;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_l;
  __Pyx_Buffer __pyx_pybuffer_marginals_l;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyArrayObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  coordinate_t __pyx_t_11;
  coordinate_t __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  Py_ssize_t __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_l1", 0);
  __pyx_pybuffer_marginals_l.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_l.refcount = 0;
  __pyx_pybuffernd_marginals_l.data = NULL;
  __pyx_pybuffernd_marginals_l.rcbuffer = &__pyx_pybuffer_marginals_l;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transform_l1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_29transform_l1)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":689
 *     cpdef CSRMatrixD transform_l1(self):
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 *         cdef VecD2 tmp=VecD2()             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, i
 *         cdef int off1, off2
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":693
 *         cdef int off1, off2
 *         cdef double v, marg_l
 *         if self.mat.num_rows<100000:             # <<<<<<<<<<<<<<
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 */
  __pyx_t_5 = ((__pyx_v_self->mat->num_rows < 100000) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":694
 *         cdef double v, marg_l
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         else:
 *             tmp.vec.reserve(100000)
 */
    __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":696
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 *             tmp.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *         marginals_l=self.left_marginals()
 *         for k from 0<=k<self.mat.num_rows:
 */
    __pyx_v_tmp->vec.reserve(100000);
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":697
 *         else:
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.num_rows:
 *             marg_l=marginals_l[k]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_left_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_l, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_marginals_l.diminfo[0].strides = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_l.diminfo[0].shape = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = 0;
  __pyx_v_marginals_l = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":698
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             marg_l=marginals_l[k]
 *             off1=self.mat.offsets[k]
 */
  __pyx_t_11 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_11; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":699
 *         marginals_l=self.left_marginals()
 *         for k from 0<=k<self.mat.num_rows:
 *             marg_l=marginals_l[k]             # <<<<<<<<<<<<<<
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 */
    __pyx_t_12 = __pyx_v_k;
    __pyx_t_7 = -1;
    if (unlikely(__pyx_t_12 >= (size_t)__pyx_pybuffernd_marginals_l.diminfo[0].shape)) __pyx_t_7 = 0;
    if (unlikely(__pyx_t_7 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_7);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_marg_l = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_marginals_l.diminfo[0].strides));

    /* "lurrn/sparsmat.pyx":700
 *         for k from 0<=k<self.mat.num_rows:
 *             marg_l=marginals_l[k]
 *             off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":701
 *             marg_l=marginals_l[k]
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":702
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                v=self.mat.values[i]
 *                if v>0:
 */
    __pyx_t_7 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":703
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]             # <<<<<<<<<<<<<<
 *                if v>0:
 *                    tmp.add_count(k,self.mat.rightColumns[i],v/marg_l)
 */
      __pyx_v_v = (__pyx_v_self->mat->values[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":704
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 *                if v>0:             # <<<<<<<<<<<<<<
 *                    tmp.add_count(k,self.mat.rightColumns[i],v/marg_l)
 *         return tmp.to_csr()
 */
      __pyx_t_5 = ((__pyx_v_v > 0.0) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":705
 *                v=self.mat.values[i]
 *                if v>0:
 *                    tmp.add_count(k,self.mat.rightColumns[i],v/marg_l)             # <<<<<<<<<<<<<<
 *         return tmp.to_csr()
 *     def thresholds_norm(self, perc):
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->mat->rightColumns[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        if (unlikely(__pyx_v_marg_l == 0)) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
          #endif
          PyErr_SetString(PyExc_ZeroDivisionError, "float division");
          #ifdef WITH_THREAD
          PyGILState_Release(__pyx_gilstate_save);
          #endif
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_13 = PyFloat_FromDouble((__pyx_v_v / __pyx_v_marg_l)); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_14 = NULL;
        __pyx_t_15 = 0;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_14)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_14);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
            __pyx_t_15 = 1;
          }
        }
        __pyx_t_16 = PyTuple_New(3+__pyx_t_15); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_16);
        if (__pyx_t_14) {
          PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); __pyx_t_14 = NULL;
        }
        PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_15, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_15, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_16, 2+__pyx_t_15, __pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_13);
        __pyx_t_3 = 0;
        __pyx_t_4 = 0;
        __pyx_t_13 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_16, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L8;
      }
      __pyx_L8:;
    }
  }

  /* "lurrn/sparsmat.pyx":706
 *                if v>0:
 *                    tmp.add_count(k,self.mat.rightColumns[i],v/marg_l)
 *         return tmp.to_csr()             # <<<<<<<<<<<<<<
 *     def thresholds_norm(self, perc):
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] means
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp->__pyx_vtab)->to_csr(__pyx_v_tmp, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":687
 *                        tmp.add_count(k,self.mat.rightColumns[i],ll)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_l1(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 *         cdef VecD2 tmp=VecD2()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_16);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.transform_l1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_l);
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_29transform_l1(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_29transform_l1(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("transform_l1 (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_28transform_l1(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_28transform_l1(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_l1", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_transform_l1(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.transform_l1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":707
 *                    tmp.add_count(k,self.mat.rightColumns[i],v/marg_l)
 *         return tmp.to_csr()
 *     def thresholds_norm(self, perc):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] means
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] squared_means
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_31thresholds_norm(PyObject *__pyx_v_self, PyObject *__pyx_v_perc); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_31thresholds_norm(PyObject *__pyx_v_self, PyObject *__pyx_v_perc) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("thresholds_norm (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_30thresholds_norm(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self), ((PyObject *)__pyx_v_perc));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_30thresholds_norm(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_perc) {
  PyArrayObject *__pyx_v_means = 0;
  PyArrayObject *__pyx_v_squared_means = 0;
  PyArrayObject *__pyx_v_stddev = 0;
  double __pyx_v_zscore;
  int __pyx_v_count_targets;
  int __pyx_v_count_all;
  double __pyx_v_corr_factor;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_means;
  __Pyx_Buffer __pyx_pybuffer_means;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_squared_means;
  __Pyx_Buffer __pyx_pybuffer_squared_means;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_stddev;
  __Pyx_Buffer __pyx_pybuffer_stddev;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  double __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyArrayObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyArrayObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyArrayObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("thresholds_norm", 0);
  __pyx_pybuffer_means.pybuffer.buf = NULL;
  __pyx_pybuffer_means.refcount = 0;
  __pyx_pybuffernd_means.data = NULL;
  __pyx_pybuffernd_means.rcbuffer = &__pyx_pybuffer_means;
  __pyx_pybuffer_squared_means.pybuffer.buf = NULL;
  __pyx_pybuffer_squared_means.refcount = 0;
  __pyx_pybuffernd_squared_means.data = NULL;
  __pyx_pybuffernd_squared_means.rcbuffer = &__pyx_pybuffer_squared_means;
  __pyx_pybuffer_stddev.pybuffer.buf = NULL;
  __pyx_pybuffer_stddev.refcount = 0;
  __pyx_pybuffernd_stddev.data = NULL;
  __pyx_pybuffernd_stddev.rcbuffer = &__pyx_pybuffer_stddev;

  /* "lurrn/sparsmat.pyx":711
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] squared_means
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] stddev
 *         cdef double zscore=inverse_erf(2.0*perc-1.0)             # <<<<<<<<<<<<<<
 *         cdef int count_targets
 *         cdef int count_all=self.get_maxcol()+1
 */
  __pyx_t_1 = PyNumber_Multiply(__pyx_float_2_0, __pyx_v_perc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_float_1_0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_3 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_zscore = inverse_erf(__pyx_t_3);

  /* "lurrn/sparsmat.pyx":713
 *         cdef double zscore=inverse_erf(2.0*perc-1.0)
 *         cdef int count_targets
 *         cdef int count_all=self.get_maxcol()+1             # <<<<<<<<<<<<<<
 *         cdef double corr_factor = count_all / (count_all - 1.0)
 *         count_targets=len(self)
 */
  __pyx_v_count_all = (((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0) + 1);

  /* "lurrn/sparsmat.pyx":714
 *         cdef int count_targets
 *         cdef int count_all=self.get_maxcol()+1
 *         cdef double corr_factor = count_all / (count_all - 1.0)             # <<<<<<<<<<<<<<
 *         count_targets=len(self)
 *         means=self.right_marginals()
 */
  __pyx_t_3 = (__pyx_v_count_all - 1.0);
  if (unlikely(__pyx_t_3 == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_corr_factor = (__pyx_v_count_all / __pyx_t_3);

  /* "lurrn/sparsmat.pyx":715
 *         cdef int count_all=self.get_maxcol()+1
 *         cdef double corr_factor = count_all / (count_all - 1.0)
 *         count_targets=len(self)             # <<<<<<<<<<<<<<
 *         means=self.right_marginals()
 *         means /= count_targets
 */
  __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_count_targets = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":716
 *         cdef double corr_factor = count_all / (count_all - 1.0)
 *         count_targets=len(self)
 *         means=self.right_marginals()             # <<<<<<<<<<<<<<
 *         means /= count_targets
 *         squared_means = self.right_squared_marginals()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_right_marginals); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_means.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_means.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_means.rcbuffer->pybuffer, (PyObject*)__pyx_v_means, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_means.diminfo[0].strides = __pyx_pybuffernd_means.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_means.diminfo[0].shape = __pyx_pybuffernd_means.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = 0;
  __pyx_v_means = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":717
 *         count_targets=len(self)
 *         means=self.right_marginals()
 *         means /= count_targets             # <<<<<<<<<<<<<<
 *         squared_means = self.right_squared_marginals()
 *         squared_means /= count_targets
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_count_targets); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyNumber_InPlaceDivide(((PyObject *)__pyx_v_means), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_means.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_means.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_means.rcbuffer->pybuffer, (PyObject*)__pyx_v_means, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
      }
    }
    __pyx_pybuffernd_means.diminfo[0].strides = __pyx_pybuffernd_means.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_means.diminfo[0].shape = __pyx_pybuffernd_means.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = 0;
  __Pyx_DECREF_SET(__pyx_v_means, ((PyArrayObject *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":718
 *         means=self.right_marginals()
 *         means /= count_targets
 *         squared_means = self.right_squared_marginals()             # <<<<<<<<<<<<<<
 *         squared_means /= count_targets
 *         stddev=numpy.sqrt(corr_factor * (squared_means - means*means))
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_right_squared_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer, (PyObject*)__pyx_v_squared_means, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_squared_means.diminfo[0].strides = __pyx_pybuffernd_squared_means.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_squared_means.diminfo[0].shape = __pyx_pybuffernd_squared_means.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_11 = 0;
  __pyx_v_squared_means = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":719
 *         means /= count_targets
 *         squared_means = self.right_squared_marginals()
 *         squared_means /= count_targets             # <<<<<<<<<<<<<<
 *         stddev=numpy.sqrt(corr_factor * (squared_means - means*means))
 *         return means + zscore * stddev
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_count_targets); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyNumber_InPlaceDivide(((PyObject *)__pyx_v_squared_means), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer, (PyObject*)__pyx_v_squared_means, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
      }
    }
    __pyx_pybuffernd_squared_means.diminfo[0].strides = __pyx_pybuffernd_squared_means.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_squared_means.diminfo[0].shape = __pyx_pybuffernd_squared_means.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_11 = 0;
  __Pyx_DECREF_SET(__pyx_v_squared_means, ((PyArrayObject *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":720
 *         squared_means = self.right_squared_marginals()
 *         squared_means /= count_targets
 *         stddev=numpy.sqrt(corr_factor * (squared_means - means*means))             # <<<<<<<<<<<<<<
 *         return means + zscore * stddev
 *     def thresholds_quantile(self, perc):
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_corr_factor); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_12 = PyNumber_Multiply(((PyObject *)__pyx_v_means), ((PyObject *)__pyx_v_means)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = PyNumber_Subtract(((PyObject *)__pyx_v_squared_means), __pyx_t_12); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = PyNumber_Multiply(__pyx_t_1, __pyx_t_13); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_13) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_12); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_13); __Pyx_GIVEREF(__pyx_t_13); __pyx_t_13 = NULL;
    PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_stddev.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_stddev.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_stddev.rcbuffer->pybuffer, (PyObject*)__pyx_v_stddev, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_stddev.diminfo[0].strides = __pyx_pybuffernd_stddev.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_stddev.diminfo[0].shape = __pyx_pybuffernd_stddev.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_14 = 0;
  __pyx_v_stddev = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":721
 *         squared_means /= count_targets
 *         stddev=numpy.sqrt(corr_factor * (squared_means - means*means))
 *         return means + zscore * stddev             # <<<<<<<<<<<<<<
 *     def thresholds_quantile(self, perc):
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] results
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_zscore); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = PyNumber_Multiply(__pyx_t_2, ((PyObject *)__pyx_v_stddev)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_v_means), __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":707
 *                    tmp.add_count(k,self.mat.rightColumns[i],v/marg_l)
 *         return tmp.to_csr()
 *     def thresholds_norm(self, perc):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] means
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] squared_means
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_means.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_stddev.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.thresholds_norm", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_means.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_stddev.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_means);
  __Pyx_XDECREF((PyObject *)__pyx_v_squared_means);
  __Pyx_XDECREF((PyObject *)__pyx_v_stddev);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":722
 *         stddev=numpy.sqrt(corr_factor * (squared_means - means*means))
 *         return means + zscore * stddev
 *     def thresholds_quantile(self, perc):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] results
 *         cdef int i, count_nz, offset, abs_offset
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_33thresholds_quantile(PyObject *__pyx_v_self, PyObject *__pyx_v_perc); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_33thresholds_quantile(PyObject *__pyx_v_self, PyObject *__pyx_v_perc) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("thresholds_quantile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_32thresholds_quantile(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self), ((PyObject *)__pyx_v_perc));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_32thresholds_quantile(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_perc) {
  PyArrayObject *__pyx_v_results = 0;
  int __pyx_v_i;
  int __pyx_v_count_nz;
  int __pyx_v_offset;
  int __pyx_v_abs_offset;
  CYTHON_UNUSED int __pyx_v_count_targets;
  CYTHON_UNUSED int __pyx_v_count_all;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_nonzeros = 0;
  PyObject *__pyx_v_count_features = NULL;
  PyObject *__pyx_v_nz_vals = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_v = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_results;
  __Pyx_Buffer __pyx_pybuffer_results;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyArrayObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *__pyx_t_14 = NULL;
  PyObject *(*__pyx_t_15)(PyObject *);
  int __pyx_t_16;
  __pyx_t_5numpy_float32_t __pyx_t_17;
  int __pyx_t_18;
  int __pyx_t_19;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("thresholds_quantile", 0);
  __pyx_pybuffer_results.pybuffer.buf = NULL;
  __pyx_pybuffer_results.refcount = 0;
  __pyx_pybuffernd_results.data = NULL;
  __pyx_pybuffernd_results.rcbuffer = &__pyx_pybuffer_results;

  /* "lurrn/sparsmat.pyx":726
 *         cdef int i, count_nz, offset, abs_offset
 *         cdef int count_targets
 *         cdef int count_all=self.get_maxcol()+1             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixD nonzeros=self.transpose()
 *         count_targets=len(self)
 */
  __pyx_v_count_all = (((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0) + 1);

  /* "lurrn/sparsmat.pyx":727
 *         cdef int count_targets
 *         cdef int count_all=self.get_maxcol()+1
 *         cdef CSRMatrixD nonzeros=self.transpose()             # <<<<<<<<<<<<<<
 *         count_targets=len(self)
 *         count_features=len(nonzeros)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transpose); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_nonzeros = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":728
 *         cdef int count_all=self.get_maxcol()+1
 *         cdef CSRMatrixD nonzeros=self.transpose()
 *         count_targets=len(self)             # <<<<<<<<<<<<<<
 *         count_features=len(nonzeros)
 *         results=numpy.zeros(count_features,numpy.float32)
 */
  __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_count_targets = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":729
 *         cdef CSRMatrixD nonzeros=self.transpose()
 *         count_targets=len(self)
 *         count_features=len(nonzeros)             # <<<<<<<<<<<<<<
 *         results=numpy.zeros(count_features,numpy.float32)
 *         abs_offset=count_features*(1.0-perc)+0.5
 */
  __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_nonzeros)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_count_features = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":730
 *         count_targets=len(self)
 *         count_features=len(nonzeros)
 *         results=numpy.zeros(count_features,numpy.float32)             # <<<<<<<<<<<<<<
 *         abs_offset=count_features*(1.0-perc)+0.5
 *         if abs_offset==0:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_v_count_features);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_4, __pyx_v_count_features);
  __Pyx_GIVEREF(__pyx_v_count_features);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_4, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
    __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_results.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_8 < 0)) {
      PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_results.rcbuffer->pybuffer, (PyObject*)__pyx_v_results, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
    }
    __pyx_pybuffernd_results.diminfo[0].strides = __pyx_pybuffernd_results.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_results.diminfo[0].shape = __pyx_pybuffernd_results.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_7 = 0;
  __pyx_v_results = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":731
 *         count_features=len(nonzeros)
 *         results=numpy.zeros(count_features,numpy.float32)
 *         abs_offset=count_features*(1.0-perc)+0.5             # <<<<<<<<<<<<<<
 *         if abs_offset==0:
 *             abs_offset=1
 */
  __pyx_t_1 = PyNumber_Subtract(__pyx_float_1_0, __pyx_v_perc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyNumber_Multiply(__pyx_v_count_features, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_float_0_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_abs_offset = __pyx_t_8;

  /* "lurrn/sparsmat.pyx":732
 *         results=numpy.zeros(count_features,numpy.float32)
 *         abs_offset=count_features*(1.0-perc)+0.5
 *         if abs_offset==0:             # <<<<<<<<<<<<<<
 *             abs_offset=1
 *         for i from 0<=i<count_features:
 */
  __pyx_t_12 = ((__pyx_v_abs_offset == 0) != 0);
  if (__pyx_t_12) {

    /* "lurrn/sparsmat.pyx":733
 *         abs_offset=count_features*(1.0-perc)+0.5
 *         if abs_offset==0:
 *             abs_offset=1             # <<<<<<<<<<<<<<
 *         for i from 0<=i<count_features:
 *             nz_vals=[v for k,v in nonzeros[i]]
 */
    __pyx_v_abs_offset = 1;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":734
 *         if abs_offset==0:
 *             abs_offset=1
 *         for i from 0<=i<count_features:             # <<<<<<<<<<<<<<
 *             nz_vals=[v for k,v in nonzeros[i]]
 *             nz_vals.sort()
 */
  __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_count_features); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":735
 *             abs_offset=1
 *         for i from 0<=i<count_features:
 *             nz_vals=[v for k,v in nonzeros[i]]             # <<<<<<<<<<<<<<
 *             nz_vals.sort()
 *             count_nz=len(nz_vals)
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_v_nonzeros), __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_6 = __pyx_t_3; __Pyx_INCREF(__pyx_t_6); __pyx_t_4 = 0;
      __pyx_t_13 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_13 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (likely(!__pyx_t_13)) {
        if (likely(PyList_CheckExact(__pyx_t_6))) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_13(__pyx_t_6);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
        PyObject* sequence = __pyx_t_3;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_2);
        #else
        __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_14 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_15 = Py_TYPE(__pyx_t_14)->tp_iternext;
        index = 0; __pyx_t_5 = __pyx_t_15(__pyx_t_14); if (unlikely(!__pyx_t_5)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        index = 1; __pyx_t_2 = __pyx_t_15(__pyx_t_14); if (unlikely(!__pyx_t_2)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_14), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_15 = NULL;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        goto __pyx_L9_unpacking_done;
        __pyx_L8_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_15 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L9_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_5);
      __pyx_t_5 = 0;
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_2);
      __pyx_t_2 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_v_v))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_nz_vals, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":736
 *         for i from 0<=i<count_features:
 *             nz_vals=[v for k,v in nonzeros[i]]
 *             nz_vals.sort()             # <<<<<<<<<<<<<<
 *             count_nz=len(nz_vals)
 *             offset=count_nz-abs_offset
 */
    __pyx_t_16 = PyList_Sort(__pyx_v_nz_vals); if (unlikely(__pyx_t_16 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lurrn/sparsmat.pyx":737
 *             nz_vals=[v for k,v in nonzeros[i]]
 *             nz_vals.sort()
 *             count_nz=len(nz_vals)             # <<<<<<<<<<<<<<
 *             offset=count_nz-abs_offset
 *             if offset<0:
 */
    __pyx_t_4 = PyList_GET_SIZE(__pyx_v_nz_vals); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_count_nz = __pyx_t_4;

    /* "lurrn/sparsmat.pyx":738
 *             nz_vals.sort()
 *             count_nz=len(nz_vals)
 *             offset=count_nz-abs_offset             # <<<<<<<<<<<<<<
 *             if offset<0:
 *                 offset=0
 */
    __pyx_v_offset = (__pyx_v_count_nz - __pyx_v_abs_offset);

    /* "lurrn/sparsmat.pyx":739
 *             count_nz=len(nz_vals)
 *             offset=count_nz-abs_offset
 *             if offset<0:             # <<<<<<<<<<<<<<
 *                 offset=0
 *             results[i] = nz_vals[offset]
 */
    __pyx_t_12 = ((__pyx_v_offset < 0) != 0);
    if (__pyx_t_12) {

      /* "lurrn/sparsmat.pyx":740
 *             offset=count_nz-abs_offset
 *             if offset<0:
 *                 offset=0             # <<<<<<<<<<<<<<
 *             results[i] = nz_vals[offset]
 *         return results
 */
      __pyx_v_offset = 0;
      goto __pyx_L10;
    }
    __pyx_L10:;

    /* "lurrn/sparsmat.pyx":741
 *             if offset<0:
 *                 offset=0
 *             results[i] = nz_vals[offset]             # <<<<<<<<<<<<<<
 *         return results
 *     def thresholds_nonzero(self, perc):
 */
    __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_nz_vals, __pyx_v_offset, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_17 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_17 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_18 = __pyx_v_i;
    __pyx_t_19 = -1;
    if (__pyx_t_18 < 0) {
      __pyx_t_18 += __pyx_pybuffernd_results.diminfo[0].shape;
      if (unlikely(__pyx_t_18 < 0)) __pyx_t_19 = 0;
    } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_results.diminfo[0].shape)) __pyx_t_19 = 0;
    if (unlikely(__pyx_t_19 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_19);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_results.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_results.diminfo[0].strides) = __pyx_t_17;
  }

  /* "lurrn/sparsmat.pyx":742
 *                 offset=0
 *             results[i] = nz_vals[offset]
 *         return results             # <<<<<<<<<<<<<<
 *     def thresholds_nonzero(self, perc):
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] results
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_results));
  __pyx_r = ((PyObject *)__pyx_v_results);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":722
 *         stddev=numpy.sqrt(corr_factor * (squared_means - means*means))
 *         return means + zscore * stddev
 *     def thresholds_quantile(self, perc):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] results
 *         cdef int i, count_nz, offset, abs_offset
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_14);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.thresholds_quantile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_results);
  __Pyx_XDECREF((PyObject *)__pyx_v_nonzeros);
  __Pyx_XDECREF(__pyx_v_count_features);
  __Pyx_XDECREF(__pyx_v_nz_vals);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":743
 *             results[i] = nz_vals[offset]
 *         return results
 *     def thresholds_nonzero(self, perc):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] results
 *         cdef int i
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_35thresholds_nonzero(PyObject *__pyx_v_self, PyObject *__pyx_v_perc); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_35thresholds_nonzero(PyObject *__pyx_v_self, PyObject *__pyx_v_perc) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("thresholds_nonzero (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_34thresholds_nonzero(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self), ((PyObject *)__pyx_v_perc));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_34thresholds_nonzero(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_perc) {
  PyArrayObject *__pyx_v_results = 0;
  int __pyx_v_i;
  int __pyx_v_count_all;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_nonzeros = 0;
  PyObject *__pyx_v_nz_vals = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_v = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_results;
  __Pyx_Buffer __pyx_pybuffer_results;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *(*__pyx_t_14)(PyObject *);
  int __pyx_t_15;
  __pyx_t_5numpy_float32_t __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("thresholds_nonzero", 0);
  __pyx_pybuffer_results.pybuffer.buf = NULL;
  __pyx_pybuffer_results.refcount = 0;
  __pyx_pybuffernd_results.data = NULL;
  __pyx_pybuffernd_results.rcbuffer = &__pyx_pybuffer_results;

  /* "lurrn/sparsmat.pyx":746
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] results
 *         cdef int i
 *         cdef int count_all=self.get_maxcol()+1             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixD nonzeros=self.transpose()
 *         results=numpy.zeros(count_all,numpy.float32)
 */
  __pyx_v_count_all = (((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0) + 1);

  /* "lurrn/sparsmat.pyx":747
 *         cdef int i
 *         cdef int count_all=self.get_maxcol()+1
 *         cdef CSRMatrixD nonzeros=self.transpose()             # <<<<<<<<<<<<<<
 *         results=numpy.zeros(count_all,numpy.float32)
 *         for i from 0<=i<count_all:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transpose); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_nonzeros = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":748
 *         cdef int count_all=self.get_maxcol()+1
 *         cdef CSRMatrixD nonzeros=self.transpose()
 *         results=numpy.zeros(count_all,numpy.float32)             # <<<<<<<<<<<<<<
 *         for i from 0<=i<count_all:
 *             nz_vals=[v for k,v in nonzeros[i]]
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_count_all); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_results.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_results.rcbuffer->pybuffer, (PyObject*)__pyx_v_results, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_results.diminfo[0].strides = __pyx_pybuffernd_results.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_results.diminfo[0].shape = __pyx_pybuffernd_results.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __pyx_v_results = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":749
 *         cdef CSRMatrixD nonzeros=self.transpose()
 *         results=numpy.zeros(count_all,numpy.float32)
 *         for i from 0<=i<count_all:             # <<<<<<<<<<<<<<
 *             nz_vals=[v for k,v in nonzeros[i]]
 *             nz_vals.sort()
 */
  __pyx_t_9 = __pyx_v_count_all;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":750
 *         results=numpy.zeros(count_all,numpy.float32)
 *         for i from 0<=i<count_all:
 *             nz_vals=[v for k,v in nonzeros[i]]             # <<<<<<<<<<<<<<
 *             nz_vals.sort()
 *             results[i] = nz_vals[int(len(nz_vals)*perc)]
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_v_nonzeros), __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_7 = __pyx_t_3; __Pyx_INCREF(__pyx_t_7); __pyx_t_6 = 0;
      __pyx_t_13 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_13 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (likely(!__pyx_t_13)) {
        if (likely(PyList_CheckExact(__pyx_t_7))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_7, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_7, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_13(__pyx_t_7);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
        PyObject* sequence = __pyx_t_3;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_2);
        #else
        __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_14 = Py_TYPE(__pyx_t_4)->tp_iternext;
        index = 0; __pyx_t_5 = __pyx_t_14(__pyx_t_4); if (unlikely(!__pyx_t_5)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        index = 1; __pyx_t_2 = __pyx_t_14(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_14 = NULL;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L8_unpacking_done;
        __pyx_L7_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_14 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L8_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_5);
      __pyx_t_5 = 0;
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_2);
      __pyx_t_2 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_v_v))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF_SET(__pyx_v_nz_vals, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":751
 *         for i from 0<=i<count_all:
 *             nz_vals=[v for k,v in nonzeros[i]]
 *             nz_vals.sort()             # <<<<<<<<<<<<<<
 *             results[i] = nz_vals[int(len(nz_vals)*perc)]
 *         return results
 */
    __pyx_t_15 = PyList_Sort(__pyx_v_nz_vals); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lurrn/sparsmat.pyx":752
 *             nz_vals=[v for k,v in nonzeros[i]]
 *             nz_vals.sort()
 *             results[i] = nz_vals[int(len(nz_vals)*perc)]             # <<<<<<<<<<<<<<
 *         return results
 *     def get_quantiles(self, qs):
 */
    __pyx_t_6 = PyList_GET_SIZE(__pyx_v_nz_vals); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = PyNumber_Multiply(__pyx_t_1, __pyx_v_perc); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Int(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyObject_GetItem(__pyx_v_nz_vals, __pyx_t_1); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_16 = __pyx_PyFloat_AsFloat(__pyx_t_7); if (unlikely((__pyx_t_16 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_17 = __pyx_v_i;
    __pyx_t_18 = -1;
    if (__pyx_t_17 < 0) {
      __pyx_t_17 += __pyx_pybuffernd_results.diminfo[0].shape;
      if (unlikely(__pyx_t_17 < 0)) __pyx_t_18 = 0;
    } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_results.diminfo[0].shape)) __pyx_t_18 = 0;
    if (unlikely(__pyx_t_18 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_18);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_results.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_results.diminfo[0].strides) = __pyx_t_16;
  }

  /* "lurrn/sparsmat.pyx":753
 *             nz_vals.sort()
 *             results[i] = nz_vals[int(len(nz_vals)*perc)]
 *         return results             # <<<<<<<<<<<<<<
 *     def get_quantiles(self, qs):
 *         cdef coordinate_t k, nnz
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_results));
  __pyx_r = ((PyObject *)__pyx_v_results);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":743
 *             results[i] = nz_vals[offset]
 *         return results
 *     def thresholds_nonzero(self, perc):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] results
 *         cdef int i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.thresholds_nonzero", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_results);
  __Pyx_XDECREF((PyObject *)__pyx_v_nonzeros);
  __Pyx_XDECREF(__pyx_v_nz_vals);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":754
 *             results[i] = nz_vals[int(len(nz_vals)*perc)]
 *         return results
 *     def get_quantiles(self, qs):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, nnz
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] allvals
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_37get_quantiles(PyObject *__pyx_v_self, PyObject *__pyx_v_qs); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_37get_quantiles(PyObject *__pyx_v_self, PyObject *__pyx_v_qs) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_quantiles (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_36get_quantiles(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self), ((PyObject *)__pyx_v_qs));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_36get_quantiles(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_qs) {
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_nnz;
  PyArrayObject *__pyx_v_allvals = 0;
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_q = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_allvals;
  __Pyx_Buffer __pyx_pybuffer_allvals;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  coordinate_t __pyx_t_13;
  int __pyx_t_14;
  PyObject *(*__pyx_t_15)(PyObject *);
  coordinate_t __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_quantiles", 0);
  __pyx_pybuffer_allvals.pybuffer.buf = NULL;
  __pyx_pybuffer_allvals.refcount = 0;
  __pyx_pybuffernd_allvals.data = NULL;
  __pyx_pybuffernd_allvals.rcbuffer = &__pyx_pybuffer_allvals;

  /* "lurrn/sparsmat.pyx":757
 *         cdef coordinate_t k, nnz
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] allvals
 *         nnz = self.mat.offsets[self.mat.num_rows]             # <<<<<<<<<<<<<<
 *         allvals = numpy.empty(self.mat.offsets[self.mat.num_rows],
 *                               numpy.float32)
 */
  __pyx_v_nnz = (__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]);

  /* "lurrn/sparsmat.pyx":758
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] allvals
 *         nnz = self.mat.offsets[self.mat.num_rows]
 *         allvals = numpy.empty(self.mat.offsets[self.mat.num_rows],             # <<<<<<<<<<<<<<
 *                               numpy.float32)
 *         for k from 0<=k<self.mat.offsets[self.mat.num_rows]:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "lurrn/sparsmat.pyx":759
 *         nnz = self.mat.offsets[self.mat.num_rows]
 *         allvals = numpy.empty(self.mat.offsets[self.mat.num_rows],
 *                               numpy.float32)             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.offsets[self.mat.num_rows]:
 *             allvals[k] = self.mat.values[k]
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "lurrn/sparsmat.pyx":758
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] allvals
 *         nnz = self.mat.offsets[self.mat.num_rows]
 *         allvals = numpy.empty(self.mat.offsets[self.mat.num_rows],             # <<<<<<<<<<<<<<
 *                               numpy.float32)
 *         for k from 0<=k<self.mat.offsets[self.mat.num_rows]:
 */
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_allvals.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_allvals.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_allvals.rcbuffer->pybuffer, (PyObject*)__pyx_v_allvals, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_allvals.diminfo[0].strides = __pyx_pybuffernd_allvals.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_allvals.diminfo[0].shape = __pyx_pybuffernd_allvals.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __pyx_v_allvals = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":760
 *         allvals = numpy.empty(self.mat.offsets[self.mat.num_rows],
 *                               numpy.float32)
 *         for k from 0<=k<self.mat.offsets[self.mat.num_rows]:             # <<<<<<<<<<<<<<
 *             allvals[k] = self.mat.values[k]
 *         allvals.sort()
 */
  __pyx_t_9 = (__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]);
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_9; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":761
 *                               numpy.float32)
 *         for k from 0<=k<self.mat.offsets[self.mat.num_rows]:
 *             allvals[k] = self.mat.values[k]             # <<<<<<<<<<<<<<
 *         allvals.sort()
 *         result = []
 */
    __pyx_t_13 = __pyx_v_k;
    __pyx_t_14 = -1;
    if (unlikely(__pyx_t_13 >= (size_t)__pyx_pybuffernd_allvals.diminfo[0].shape)) __pyx_t_14 = 0;
    if (unlikely(__pyx_t_14 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_14);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_allvals.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_allvals.diminfo[0].strides) = (__pyx_v_self->mat->values[__pyx_v_k]);
  }

  /* "lurrn/sparsmat.pyx":762
 *         for k from 0<=k<self.mat.offsets[self.mat.num_rows]:
 *             allvals[k] = self.mat.values[k]
 *         allvals.sort()             # <<<<<<<<<<<<<<
 *         result = []
 *         for q in qs:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_allvals), __pyx_n_s_sort); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_7) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":763
 *             allvals[k] = self.mat.values[k]
 *         allvals.sort()
 *         result = []             # <<<<<<<<<<<<<<
 *         for q in qs:
 *             k = nnz*q
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":764
 *         allvals.sort()
 *         result = []
 *         for q in qs:             # <<<<<<<<<<<<<<
 *             k = nnz*q
 *             if k >= nnz:
 */
  if (likely(PyList_CheckExact(__pyx_v_qs)) || PyTuple_CheckExact(__pyx_v_qs)) {
    __pyx_t_1 = __pyx_v_qs; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_15 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_qs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_15 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_15)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_15(__pyx_t_1);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_q, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "lurrn/sparsmat.pyx":765
 *         result = []
 *         for q in qs:
 *             k = nnz*q             # <<<<<<<<<<<<<<
 *             if k >= nnz:
 *                 k = nnz-1
 */
    __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_nnz); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = PyNumber_Multiply(__pyx_t_3, __pyx_v_q); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_16 = __Pyx_PyInt_As_coordinate_t(__pyx_t_7); if (unlikely((__pyx_t_16 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_k = __pyx_t_16;

    /* "lurrn/sparsmat.pyx":766
 *         for q in qs:
 *             k = nnz*q
 *             if k >= nnz:             # <<<<<<<<<<<<<<
 *                 k = nnz-1
 *             result.append(allvals[k])
 */
    __pyx_t_17 = ((__pyx_v_k >= __pyx_v_nnz) != 0);
    if (__pyx_t_17) {

      /* "lurrn/sparsmat.pyx":767
 *             k = nnz*q
 *             if k >= nnz:
 *                 k = nnz-1             # <<<<<<<<<<<<<<
 *             result.append(allvals[k])
 *         return result
 */
      __pyx_v_k = (__pyx_v_nnz - 1);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "lurrn/sparsmat.pyx":768
 *             if k >= nnz:
 *                 k = nnz-1
 *             result.append(allvals[k])             # <<<<<<<<<<<<<<
 *         return result
 *     cpdef CSRMatrixF apply_threshold(self, numpy.ndarray thr):
 */
    __pyx_t_16 = __pyx_v_k;
    __pyx_t_9 = -1;
    if (unlikely(__pyx_t_16 >= (size_t)__pyx_pybuffernd_allvals.diminfo[0].shape)) __pyx_t_9 = 0;
    if (unlikely(__pyx_t_9 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_9);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_7 = PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_allvals.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_allvals.diminfo[0].strides))); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_18 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "lurrn/sparsmat.pyx":764
 *         allvals.sort()
 *         result = []
 *         for q in qs:             # <<<<<<<<<<<<<<
 *             k = nnz*q
 *             if k >= nnz:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":769
 *                 k = nnz-1
 *             result.append(allvals[k])
 *         return result             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixF apply_threshold(self, numpy.ndarray thr):
 *         cdef VecD2 tmp=VecD2()
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":754
 *             results[i] = nz_vals[int(len(nz_vals)*perc)]
 *         return results
 *     def get_quantiles(self, qs):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, nnz
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] allvals
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_allvals.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.get_quantiles", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_allvals.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_allvals);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_q);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":770
 *             result.append(allvals[k])
 *         return result
 *     cpdef CSRMatrixF apply_threshold(self, numpy.ndarray thr):             # <<<<<<<<<<<<<<
 *         cdef VecD2 tmp=VecD2()
 *         cdef coordinate_t k, i, k2
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_39apply_threshold(PyObject *__pyx_v_self, PyObject *__pyx_v_thr); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_apply_threshold(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyArrayObject *__pyx_v_thr, int __pyx_skip_dispatch) {
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp = 0;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_k2;
  int __pyx_v_off1;
  int __pyx_v_off2;
  double __pyx_v_v;
  PyArrayObject *__pyx_v_thresholds = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_thresholds;
  __Pyx_Buffer __pyx_pybuffer_thresholds;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  coordinate_t __pyx_t_7;
  int __pyx_t_8;
  coordinate_t __pyx_t_9;
  int __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("apply_threshold", 0);
  __pyx_pybuffer_thresholds.pybuffer.buf = NULL;
  __pyx_pybuffer_thresholds.refcount = 0;
  __pyx_pybuffernd_thresholds.data = NULL;
  __pyx_pybuffernd_thresholds.rcbuffer = &__pyx_pybuffer_thresholds;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_apply_threshold); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_39apply_threshold)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_thr)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_thr));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_thr));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_thr));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":771
 *         return result
 *     cpdef CSRMatrixF apply_threshold(self, numpy.ndarray thr):
 *         cdef VecD2 tmp=VecD2()             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, i, k2
 *         cdef int off1, off2
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":775
 *         cdef int off1, off2
 *         cdef double v, marg_l
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] thresholds=thr             # <<<<<<<<<<<<<<
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 */
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_thresholds.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_thr), &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_thresholds = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_thresholds.diminfo[0].strides = __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_thresholds.diminfo[0].shape = __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.shape[0];
    }
  }
  __Pyx_INCREF(((PyObject *)__pyx_v_thr));
  __pyx_v_thresholds = ((PyArrayObject *)__pyx_v_thr);

  /* "lurrn/sparsmat.pyx":776
 *         cdef double v, marg_l
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] thresholds=thr
 *         if self.mat.num_rows<100000:             # <<<<<<<<<<<<<<
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 */
  __pyx_t_6 = ((__pyx_v_self->mat->num_rows < 100000) != 0);
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":777
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] thresholds=thr
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         else:
 *             tmp.vec.reserve(100000)
 */
    __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":779
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 *             tmp.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.num_rows:
 *             off1=self.mat.offsets[k]
 */
    __pyx_v_tmp->vec.reserve(100000);
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":780
 *         else:
 *             tmp.vec.reserve(100000)
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 */
  __pyx_t_7 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_7; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":781
 *             tmp.vec.reserve(100000)
 *         for k from 0<=k<self.mat.num_rows:
 *             off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":782
 *         for k from 0<=k<self.mat.num_rows:
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":783
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                v=self.mat.values[i]
 *                k2=self.mat.rightColumns[i]
 */
    __pyx_t_8 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":784
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]             # <<<<<<<<<<<<<<
 *                k2=self.mat.rightColumns[i]
 *                if v>=thresholds[k2]:
 */
      __pyx_v_v = (__pyx_v_self->mat->values[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":785
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 *                k2=self.mat.rightColumns[i]             # <<<<<<<<<<<<<<
 *                if v>=thresholds[k2]:
 *                    tmp.add_count(k,k2,1.0)
 */
      __pyx_v_k2 = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":786
 *                v=self.mat.values[i]
 *                k2=self.mat.rightColumns[i]
 *                if v>=thresholds[k2]:             # <<<<<<<<<<<<<<
 *                    tmp.add_count(k,k2,1.0)
 *         return tmp.to_csr()
 */
      __pyx_t_9 = __pyx_v_k2;
      __pyx_t_10 = -1;
      if (unlikely(__pyx_t_9 >= (size_t)__pyx_pybuffernd_thresholds.diminfo[0].shape)) __pyx_t_10 = 0;
      if (unlikely(__pyx_t_10 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_10);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = ((__pyx_v_v >= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_thresholds.diminfo[0].strides))) != 0);
      if (__pyx_t_6) {

        /* "lurrn/sparsmat.pyx":787
 *                k2=self.mat.rightColumns[i]
 *                if v>=thresholds[k2]:
 *                    tmp.add_count(k,k2,1.0)             # <<<<<<<<<<<<<<
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD apply_scaling(self, numpy.ndarray thr):
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_5 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = NULL;
        __pyx_t_11 = 0;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
            __pyx_t_11 = 1;
          }
        }
        __pyx_t_12 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        if (__pyx_t_4) {
          PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        }
        PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_float_1_0);
        PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_11, __pyx_float_1_0);
        __Pyx_GIVEREF(__pyx_float_1_0);
        __pyx_t_3 = 0;
        __pyx_t_5 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L8;
      }
      __pyx_L8:;
    }
  }

  /* "lurrn/sparsmat.pyx":788
 *                if v>=thresholds[k2]:
 *                    tmp.add_count(k,k2,1.0)
 *         return tmp.to_csr()             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixD apply_scaling(self, numpy.ndarray thr):
 *         cdef VecD2 tmp=VecD2()
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp->__pyx_vtab)->to_csr(__pyx_v_tmp, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":770
 *             result.append(allvals[k])
 *         return result
 *     cpdef CSRMatrixF apply_threshold(self, numpy.ndarray thr):             # <<<<<<<<<<<<<<
 *         cdef VecD2 tmp=VecD2()
 *         cdef coordinate_t k, i, k2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_12);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_thresholds.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.apply_threshold", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_thresholds.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XDECREF((PyObject *)__pyx_v_thresholds);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_39apply_threshold(PyObject *__pyx_v_self, PyObject *__pyx_v_thr); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_39apply_threshold(PyObject *__pyx_v_self, PyObject *__pyx_v_thr) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("apply_threshold (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_thr), __pyx_ptype_5numpy_ndarray, 1, "thr", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_38apply_threshold(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self), ((PyArrayObject *)__pyx_v_thr));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_38apply_threshold(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyArrayObject *__pyx_v_thr) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("apply_threshold", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_apply_threshold(__pyx_v_self, __pyx_v_thr, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.apply_threshold", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":789
 *                    tmp.add_count(k,k2,1.0)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD apply_scaling(self, numpy.ndarray thr):             # <<<<<<<<<<<<<<
 *         cdef VecD2 tmp=VecD2()
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] thresholds=thr
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_41apply_scaling(PyObject *__pyx_v_self, PyObject *__pyx_v_thr); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_apply_scaling(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyArrayObject *__pyx_v_thr, int __pyx_skip_dispatch) {
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp = 0;
  PyArrayObject *__pyx_v_thresholds = 0;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_k2;
  int __pyx_v_off1;
  int __pyx_v_off2;
  double __pyx_v_v;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_thresholds;
  __Pyx_Buffer __pyx_pybuffer_thresholds;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  coordinate_t __pyx_t_7;
  int __pyx_t_8;
  coordinate_t __pyx_t_9;
  int __pyx_t_10;
  __pyx_t_5numpy_float32_t __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("apply_scaling", 0);
  __pyx_pybuffer_thresholds.pybuffer.buf = NULL;
  __pyx_pybuffer_thresholds.refcount = 0;
  __pyx_pybuffernd_thresholds.data = NULL;
  __pyx_pybuffernd_thresholds.rcbuffer = &__pyx_pybuffer_thresholds;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_apply_scaling); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_41apply_scaling)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_thr)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_thr));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_thr));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_thr));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":790
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD apply_scaling(self, numpy.ndarray thr):
 *         cdef VecD2 tmp=VecD2()             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] thresholds=thr
 *         cdef coordinate_t k, i, k2
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":791
 *     cpdef CSRMatrixD apply_scaling(self, numpy.ndarray thr):
 *         cdef VecD2 tmp=VecD2()
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] thresholds=thr             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, i, k2
 *         cdef int off1, off2
 */
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_thresholds.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_thr), &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_thresholds = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_thresholds.diminfo[0].strides = __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_thresholds.diminfo[0].shape = __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.shape[0];
    }
  }
  __Pyx_INCREF(((PyObject *)__pyx_v_thr));
  __pyx_v_thresholds = ((PyArrayObject *)__pyx_v_thr);

  /* "lurrn/sparsmat.pyx":795
 *         cdef int off1, off2
 *         cdef double v, marg_l
 *         if self.mat.num_rows<100000:             # <<<<<<<<<<<<<<
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 */
  __pyx_t_6 = ((__pyx_v_self->mat->num_rows < 100000) != 0);
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":796
 *         cdef double v, marg_l
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         else:
 *             tmp.vec.reserve(100000)
 */
    __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":798
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 *             tmp.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.num_rows:
 *             off1=self.mat.offsets[k]
 */
    __pyx_v_tmp->vec.reserve(100000);
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":799
 *         else:
 *             tmp.vec.reserve(100000)
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 */
  __pyx_t_7 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_7; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":800
 *             tmp.vec.reserve(100000)
 *         for k from 0<=k<self.mat.num_rows:
 *             off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":801
 *         for k from 0<=k<self.mat.num_rows:
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                k2=self.mat.rightColumns[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":802
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                k2=self.mat.rightColumns[i]
 *                v=self.mat.values[i]/thresholds[k2]
 */
    __pyx_t_8 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":803
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                k2=self.mat.rightColumns[i]             # <<<<<<<<<<<<<<
 *                v=self.mat.values[i]/thresholds[k2]
 *                if v>=1.0:
 */
      __pyx_v_k2 = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":804
 *             for i from off1<=i<off2:
 *                k2=self.mat.rightColumns[i]
 *                v=self.mat.values[i]/thresholds[k2]             # <<<<<<<<<<<<<<
 *                if v>=1.0:
 *                    tmp.add_count(k,k2,1.0)
 */
      __pyx_t_9 = __pyx_v_k2;
      __pyx_t_10 = -1;
      if (unlikely(__pyx_t_9 >= (size_t)__pyx_pybuffernd_thresholds.diminfo[0].shape)) __pyx_t_10 = 0;
      if (unlikely(__pyx_t_10 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_10);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_11 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_thresholds.diminfo[0].strides));
      if (unlikely(__pyx_t_11 == 0)) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        #ifdef WITH_THREAD
        PyGILState_Release(__pyx_gilstate_save);
        #endif
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_v_v = ((__pyx_v_self->mat->values[__pyx_v_i]) / __pyx_t_11);

      /* "lurrn/sparsmat.pyx":805
 *                k2=self.mat.rightColumns[i]
 *                v=self.mat.values[i]/thresholds[k2]
 *                if v>=1.0:             # <<<<<<<<<<<<<<
 *                    tmp.add_count(k,k2,1.0)
 *                else:
 */
      __pyx_t_6 = ((__pyx_v_v >= 1.0) != 0);
      if (__pyx_t_6) {

        /* "lurrn/sparsmat.pyx":806
 *                v=self.mat.values[i]/thresholds[k2]
 *                if v>=1.0:
 *                    tmp.add_count(k,k2,1.0)             # <<<<<<<<<<<<<<
 *                else:
 *                    tmp.add_count(k,k2,v)
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_5 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = NULL;
        __pyx_t_12 = 0;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
            __pyx_t_12 = 1;
          }
        }
        __pyx_t_13 = PyTuple_New(3+__pyx_t_12); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_13);
        if (__pyx_t_4) {
          PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        }
        PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_float_1_0);
        PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_12, __pyx_float_1_0);
        __Pyx_GIVEREF(__pyx_float_1_0);
        __pyx_t_3 = 0;
        __pyx_t_5 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_13, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L8;
      }
      /*else*/ {

        /* "lurrn/sparsmat.pyx":808
 *                    tmp.add_count(k,k2,1.0)
 *                else:
 *                    tmp.add_count(k,k2,v)             # <<<<<<<<<<<<<<
 *         return tmp.to_csr()
 *     def scale_columns(self, factors):
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_13 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_5 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = PyFloat_FromDouble(__pyx_v_v); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = NULL;
        __pyx_t_12 = 0;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
            __pyx_t_12 = 1;
          }
        }
        __pyx_t_14 = PyTuple_New(3+__pyx_t_12); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_14);
        if (__pyx_t_4) {
          PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        }
        PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_12, __pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_13);
        PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_12, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_12, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_13 = 0;
        __pyx_t_5 = 0;
        __pyx_t_3 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_14, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __pyx_L8:;
    }
  }

  /* "lurrn/sparsmat.pyx":809
 *                else:
 *                    tmp.add_count(k,k2,v)
 *         return tmp.to_csr()             # <<<<<<<<<<<<<<
 *     def scale_columns(self, factors):
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] factors_l = factors
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp->__pyx_vtab)->to_csr(__pyx_v_tmp, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":789
 *                    tmp.add_count(k,k2,1.0)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD apply_scaling(self, numpy.ndarray thr):             # <<<<<<<<<<<<<<
 *         cdef VecD2 tmp=VecD2()
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] thresholds=thr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_thresholds.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.apply_scaling", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_thresholds.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XDECREF((PyObject *)__pyx_v_thresholds);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_41apply_scaling(PyObject *__pyx_v_self, PyObject *__pyx_v_thr); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_41apply_scaling(PyObject *__pyx_v_self, PyObject *__pyx_v_thr) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("apply_scaling (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_thr), __pyx_ptype_5numpy_ndarray, 1, "thr", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_40apply_scaling(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self), ((PyArrayObject *)__pyx_v_thr));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_40apply_scaling(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyArrayObject *__pyx_v_thr) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("apply_scaling", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_apply_scaling(__pyx_v_self, __pyx_v_thr, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.apply_scaling", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":810
 *                    tmp.add_count(k,k2,v)
 *         return tmp.to_csr()
 *     def scale_columns(self, factors):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] factors_l = factors
 *         cdef coordinate_t k
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_43scale_columns(PyObject *__pyx_v_self, PyObject *__pyx_v_factors); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_43scale_columns(PyObject *__pyx_v_self, PyObject *__pyx_v_factors) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("scale_columns (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_42scale_columns(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self), ((PyObject *)__pyx_v_factors));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_42scale_columns(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_factors) {
  PyArrayObject *__pyx_v_factors_l = 0;
  coordinate_t __pyx_v_k;
  int __pyx_v_off1;
  int __pyx_v_off2;
  int __pyx_v_i;
  coordinate_t __pyx_v_k2;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_factors_l;
  __Pyx_Buffer __pyx_pybuffer_factors_l;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  coordinate_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  coordinate_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("scale_columns", 0);
  __pyx_pybuffer_factors_l.pybuffer.buf = NULL;
  __pyx_pybuffer_factors_l.refcount = 0;
  __pyx_pybuffernd_factors_l.data = NULL;
  __pyx_pybuffernd_factors_l.rcbuffer = &__pyx_pybuffer_factors_l;

  /* "lurrn/sparsmat.pyx":811
 *         return tmp.to_csr()
 *     def scale_columns(self, factors):
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] factors_l = factors             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k
 *         cdef int off1, off2
 */
  if (!(likely(((__pyx_v_factors) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_factors, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_factors;
  __Pyx_INCREF(__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_factors_l.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_factors_l = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_factors_l.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_factors_l.diminfo[0].strides = __pyx_pybuffernd_factors_l.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_factors_l.diminfo[0].shape = __pyx_pybuffernd_factors_l.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_v_factors_l = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":814
 *         cdef coordinate_t k
 *         cdef int off1, off2
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             off1 = self.mat.offsets[k]
 *             off2 = self.mat.offsets[k+1]
 */
  __pyx_t_2 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_2; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":815
 *         cdef int off1, off2
 *         for k from 0<=k<self.mat.num_rows:
 *             off1 = self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2 = self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":816
 *         for k from 0<=k<self.mat.num_rows:
 *             off1 = self.mat.offsets[k]
 *             off2 = self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                 k2 = self.mat.rightColumns[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":817
 *             off1 = self.mat.offsets[k]
 *             off2 = self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                 k2 = self.mat.rightColumns[i]
 *                 self.mat.values[i] *= factors_l[k2]
 */
    __pyx_t_3 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":818
 *             off2 = self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                 k2 = self.mat.rightColumns[i]             # <<<<<<<<<<<<<<
 *                 self.mat.values[i] *= factors_l[k2]
 *     def scale_rows(self, factors):
 */
      __pyx_v_k2 = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":819
 *             for i from off1<=i<off2:
 *                 k2 = self.mat.rightColumns[i]
 *                 self.mat.values[i] *= factors_l[k2]             # <<<<<<<<<<<<<<
 *     def scale_rows(self, factors):
 *         cdef coordinate_t k
 */
      __pyx_t_4 = __pyx_v_i;
      __pyx_t_5 = __pyx_v_k2;
      __pyx_t_6 = -1;
      if (unlikely(__pyx_t_5 >= (size_t)__pyx_pybuffernd_factors_l.diminfo[0].shape)) __pyx_t_6 = 0;
      if (unlikely(__pyx_t_6 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_6);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      (__pyx_v_self->mat->values[__pyx_t_4]) = ((__pyx_v_self->mat->values[__pyx_t_4]) * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_factors_l.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_factors_l.diminfo[0].strides)));
    }
  }

  /* "lurrn/sparsmat.pyx":810
 *                    tmp.add_count(k,k2,v)
 *         return tmp.to_csr()
 *     def scale_columns(self, factors):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] factors_l = factors
 *         cdef coordinate_t k
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_factors_l.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.scale_columns", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_factors_l.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_factors_l);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":820
 *                 k2 = self.mat.rightColumns[i]
 *                 self.mat.values[i] *= factors_l[k2]
 *     def scale_rows(self, factors):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k
 *         cdef float factor
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_45scale_rows(PyObject *__pyx_v_self, PyObject *__pyx_v_factors); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_45scale_rows(PyObject *__pyx_v_self, PyObject *__pyx_v_factors) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("scale_rows (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_44scale_rows(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self), ((PyObject *)__pyx_v_factors));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_44scale_rows(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_factors) {
  coordinate_t __pyx_v_k;
  float __pyx_v_factor;
  int __pyx_v_off1;
  int __pyx_v_off2;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  coordinate_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  float __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("scale_rows", 0);

  /* "lurrn/sparsmat.pyx":824
 *         cdef float factor
 *         cdef int off1, off2
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             off1 = self.mat.offsets[k]
 *             off2 = self.mat.offsets[k+1]
 */
  __pyx_t_1 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":825
 *         cdef int off1, off2
 *         for k from 0<=k<self.mat.num_rows:
 *             off1 = self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2 = self.mat.offsets[k+1]
 *             factor = factors[k]
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":826
 *         for k from 0<=k<self.mat.num_rows:
 *             off1 = self.mat.offsets[k]
 *             off2 = self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             factor = factors[k]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":827
 *             off1 = self.mat.offsets[k]
 *             off2 = self.mat.offsets[k+1]
 *             factor = factors[k]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                 self.mat.values[i] *= factor
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_factors, __pyx_v_k, coordinate_t, 0, __Pyx_PyInt_From_coordinate_t, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_factor = __pyx_t_3;

    /* "lurrn/sparsmat.pyx":828
 *             off2 = self.mat.offsets[k+1]
 *             factor = factors[k]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                 self.mat.values[i] *= factor
 *     def left_marginals(self):
 */
    __pyx_t_4 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":829
 *             factor = factors[k]
 *             for i from off1<=i<off2:
 *                 self.mat.values[i] *= factor             # <<<<<<<<<<<<<<
 *     def left_marginals(self):
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 */
      __pyx_t_5 = __pyx_v_i;
      (__pyx_v_self->mat->values[__pyx_t_5]) = ((__pyx_v_self->mat->values[__pyx_t_5]) * __pyx_v_factor);
    }
  }

  /* "lurrn/sparsmat.pyx":820
 *                 k2 = self.mat.rightColumns[i]
 *                 self.mat.values[i] *= factors_l[k2]
 *     def scale_rows(self, factors):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k
 *         cdef float factor
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.scale_rows", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":830
 *             for i from off1<=i<off2:
 *                 self.mat.values[i] *= factor
 *     def left_marginals(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 *         marginals_l=numpy.zeros(self.mat.num_rows,numpy.float32)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_47left_marginals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_47left_marginals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("left_marginals (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_46left_marginals(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_46left_marginals(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self) {
  PyArrayObject *__pyx_v_marginals_l = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_l;
  __Pyx_Buffer __pyx_pybuffer_marginals_l;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("left_marginals", 0);
  __pyx_pybuffer_marginals_l.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_l.refcount = 0;
  __pyx_pybuffernd_marginals_l.data = NULL;
  __pyx_pybuffernd_marginals_l.rcbuffer = &__pyx_pybuffer_marginals_l;

  /* "lurrn/sparsmat.pyx":832
 *     def left_marginals(self):
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 *         marginals_l=numpy.zeros(self.mat.num_rows,numpy.float32)             # <<<<<<<<<<<<<<
 *         self.mat.compute_left_marginals(<float *> marginals_l.data)
 *         return marginals_l
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_coordinate_t(__pyx_v_self->mat->num_rows); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_l, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_marginals_l.diminfo[0].strides = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_l.diminfo[0].shape = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __pyx_v_marginals_l = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":833
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 *         marginals_l=numpy.zeros(self.mat.num_rows,numpy.float32)
 *         self.mat.compute_left_marginals(<float *> marginals_l.data)             # <<<<<<<<<<<<<<
 *         return marginals_l
 *     def right_marginals(self):
 */
  __pyx_v_self->mat->compute_left_marginals(((float *)__pyx_v_marginals_l->data));

  /* "lurrn/sparsmat.pyx":834
 *         marginals_l=numpy.zeros(self.mat.num_rows,numpy.float32)
 *         self.mat.compute_left_marginals(<float *> marginals_l.data)
 *         return marginals_l             # <<<<<<<<<<<<<<
 *     def right_marginals(self):
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_r
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_marginals_l));
  __pyx_r = ((PyObject *)__pyx_v_marginals_l);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":830
 *             for i from off1<=i<off2:
 *                 self.mat.values[i] *= factor
 *     def left_marginals(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_l
 *         marginals_l=numpy.zeros(self.mat.num_rows,numpy.float32)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.left_marginals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_l);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":835
 *         self.mat.compute_left_marginals(<float *> marginals_l.data)
 *         return marginals_l
 *     def right_marginals(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float32)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_49right_marginals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_49right_marginals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("right_marginals (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_48right_marginals(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_48right_marginals(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self) {
  PyArrayObject *__pyx_v_marginals_r = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_r;
  __Pyx_Buffer __pyx_pybuffer_marginals_r;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("right_marginals", 0);
  __pyx_pybuffer_marginals_r.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_r.refcount = 0;
  __pyx_pybuffernd_marginals_r.data = NULL;
  __pyx_pybuffernd_marginals_r.rcbuffer = &__pyx_pybuffer_marginals_r;

  /* "lurrn/sparsmat.pyx":837
 *     def right_marginals(self):
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float32)             # <<<<<<<<<<<<<<
 *         self.mat.compute_right_marginals(<float *> marginals_r.data)
 *         return marginals_r
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_long((((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0) + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_r, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_marginals_r.diminfo[0].strides = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_r.diminfo[0].shape = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __pyx_v_marginals_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":838
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float32)
 *         self.mat.compute_right_marginals(<float *> marginals_r.data)             # <<<<<<<<<<<<<<
 *         return marginals_r
 *     def right_squared_marginals(self):
 */
  __pyx_v_self->mat->compute_right_marginals(((float *)__pyx_v_marginals_r->data));

  /* "lurrn/sparsmat.pyx":839
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float32)
 *         self.mat.compute_right_marginals(<float *> marginals_r.data)
 *         return marginals_r             # <<<<<<<<<<<<<<
 *     def right_squared_marginals(self):
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_r
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_marginals_r));
  __pyx_r = ((PyObject *)__pyx_v_marginals_r);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":835
 *         self.mat.compute_left_marginals(<float *> marginals_l.data)
 *         return marginals_l
 *     def right_marginals(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float32)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.right_marginals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_r);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":840
 *         self.mat.compute_right_marginals(<float *> marginals_r.data)
 *         return marginals_r
 *     def right_squared_marginals(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float32)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_51right_squared_marginals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_51right_squared_marginals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("right_squared_marginals (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_50right_squared_marginals(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_50right_squared_marginals(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self) {
  PyArrayObject *__pyx_v_marginals_r = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_r;
  __Pyx_Buffer __pyx_pybuffer_marginals_r;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("right_squared_marginals", 0);
  __pyx_pybuffer_marginals_r.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_r.refcount = 0;
  __pyx_pybuffernd_marginals_r.data = NULL;
  __pyx_pybuffernd_marginals_r.rcbuffer = &__pyx_pybuffer_marginals_r;

  /* "lurrn/sparsmat.pyx":842
 *     def right_squared_marginals(self):
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float32)             # <<<<<<<<<<<<<<
 *         self.mat.compute_right_squared_marginals(<float *> marginals_r.data)
 *         return marginals_r
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_long((((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0) + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_r, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_marginals_r.diminfo[0].strides = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_r.diminfo[0].shape = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __pyx_v_marginals_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":843
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float32)
 *         self.mat.compute_right_squared_marginals(<float *> marginals_r.data)             # <<<<<<<<<<<<<<
 *         return marginals_r
 *     cpdef float get_count(self,coordinate_t k, coordinate_t k2):
 */
  __pyx_v_self->mat->compute_right_squared_marginals(((float *)__pyx_v_marginals_r->data));

  /* "lurrn/sparsmat.pyx":844
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float32)
 *         self.mat.compute_right_squared_marginals(<float *> marginals_r.data)
 *         return marginals_r             # <<<<<<<<<<<<<<
 *     cpdef float get_count(self,coordinate_t k, coordinate_t k2):
 *         if k<0 or k>=self.mat.num_rows:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_marginals_r));
  __pyx_r = ((PyObject *)__pyx_v_marginals_r);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":840
 *         self.mat.compute_right_marginals(<float *> marginals_r.data)
 *         return marginals_r
 *     def right_squared_marginals(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float32)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.right_squared_marginals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_r);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":845
 *         self.mat.compute_right_squared_marginals(<float *> marginals_r.data)
 *         return marginals_r
 *     cpdef float get_count(self,coordinate_t k, coordinate_t k2):             # <<<<<<<<<<<<<<
 *         if k<0 or k>=self.mat.num_rows:
 *             return 0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_53get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static float __pyx_f_5lurrn_8sparsmat_10CSRMatrixF_get_count(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, coordinate_t __pyx_v_k, coordinate_t __pyx_v_k2, int __pyx_skip_dispatch) {
  int __pyx_v_lo;
  int __pyx_v_hi;
  int __pyx_v_mi;
  coordinate_t __pyx_v_a_mi;
  float __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  float __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_53get_count)) {
      __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_5 = __pyx_t_1; __pyx_t_6 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_7 = 1;
        }
      }
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_6) {
        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_9;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":846
 *         return marginals_r
 *     cpdef float get_count(self,coordinate_t k, coordinate_t k2):
 *         if k<0 or k>=self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             return 0
 *         assert k<self.mat.num_rows
 */
  __pyx_t_11 = ((__pyx_v_k < 0) != 0);
  if (!__pyx_t_11) {
  } else {
    __pyx_t_10 = __pyx_t_11;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_11 = ((__pyx_v_k >= __pyx_v_self->mat->num_rows) != 0);
  __pyx_t_10 = __pyx_t_11;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_10) {

    /* "lurrn/sparsmat.pyx":847
 *     cpdef float get_count(self,coordinate_t k, coordinate_t k2):
 *         if k<0 or k>=self.mat.num_rows:
 *             return 0             # <<<<<<<<<<<<<<
 *         assert k<self.mat.num_rows
 *         cdef int lo=self.mat.offsets[k]
 */
    __pyx_r = 0.0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":848
 *         if k<0 or k>=self.mat.num_rows:
 *             return 0
 *         assert k<self.mat.num_rows             # <<<<<<<<<<<<<<
 *         cdef int lo=self.mat.offsets[k]
 *         cdef int hi=self.mat.offsets[k+1]
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_k < __pyx_v_self->mat->num_rows) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":849
 *             return 0
 *         assert k<self.mat.num_rows
 *         cdef int lo=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *         cdef int hi=self.mat.offsets[k+1]
 *         cdef int mi
 */
  __pyx_v_lo = (__pyx_v_self->mat->offsets[__pyx_v_k]);

  /* "lurrn/sparsmat.pyx":850
 *         assert k<self.mat.num_rows
 *         cdef int lo=self.mat.offsets[k]
 *         cdef int hi=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *         cdef int mi
 *         cdef coordinate_t a_mi
 */
  __pyx_v_hi = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

  /* "lurrn/sparsmat.pyx":853
 *         cdef int mi
 *         cdef coordinate_t a_mi
 *         if hi==lo: return 0             # <<<<<<<<<<<<<<
 *         while hi-lo>1:
 *             mi=(hi+lo)//2
 */
  __pyx_t_10 = ((__pyx_v_hi == __pyx_v_lo) != 0);
  if (__pyx_t_10) {
    __pyx_r = 0.0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":854
 *         cdef coordinate_t a_mi
 *         if hi==lo: return 0
 *         while hi-lo>1:             # <<<<<<<<<<<<<<
 *             mi=(hi+lo)//2
 *             a_mi=self.mat.rightColumns[mi]
 */
  while (1) {
    __pyx_t_10 = (((__pyx_v_hi - __pyx_v_lo) > 1) != 0);
    if (!__pyx_t_10) break;

    /* "lurrn/sparsmat.pyx":855
 *         if hi==lo: return 0
 *         while hi-lo>1:
 *             mi=(hi+lo)//2             # <<<<<<<<<<<<<<
 *             a_mi=self.mat.rightColumns[mi]
 *             if a_mi>k2:
 */
    __pyx_v_mi = __Pyx_div_long((__pyx_v_hi + __pyx_v_lo), 2);

    /* "lurrn/sparsmat.pyx":856
 *         while hi-lo>1:
 *             mi=(hi+lo)//2
 *             a_mi=self.mat.rightColumns[mi]             # <<<<<<<<<<<<<<
 *             if a_mi>k2:
 *                 hi=mi
 */
    __pyx_v_a_mi = (__pyx_v_self->mat->rightColumns[__pyx_v_mi]);

    /* "lurrn/sparsmat.pyx":857
 *             mi=(hi+lo)//2
 *             a_mi=self.mat.rightColumns[mi]
 *             if a_mi>k2:             # <<<<<<<<<<<<<<
 *                 hi=mi
 *             elif a_mi==k2:
 */
    __pyx_t_10 = ((__pyx_v_a_mi > __pyx_v_k2) != 0);
    if (__pyx_t_10) {

      /* "lurrn/sparsmat.pyx":858
 *             a_mi=self.mat.rightColumns[mi]
 *             if a_mi>k2:
 *                 hi=mi             # <<<<<<<<<<<<<<
 *             elif a_mi==k2:
 *                 return self.mat.values[mi]
 */
      __pyx_v_hi = __pyx_v_mi;
      goto __pyx_L9;
    }

    /* "lurrn/sparsmat.pyx":859
 *             if a_mi>k2:
 *                 hi=mi
 *             elif a_mi==k2:             # <<<<<<<<<<<<<<
 *                 return self.mat.values[mi]
 *             else:
 */
    __pyx_t_10 = ((__pyx_v_a_mi == __pyx_v_k2) != 0);
    if (__pyx_t_10) {

      /* "lurrn/sparsmat.pyx":860
 *                 hi=mi
 *             elif a_mi==k2:
 *                 return self.mat.values[mi]             # <<<<<<<<<<<<<<
 *             else:
 *                 lo=mi+1
 */
      __pyx_r = (__pyx_v_self->mat->values[__pyx_v_mi]);
      goto __pyx_L0;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":862
 *                 return self.mat.values[mi]
 *             else:
 *                 lo=mi+1             # <<<<<<<<<<<<<<
 *         if self.mat.rightColumns[lo]==k2:
 *             return self.mat.values[lo]
 */
      __pyx_v_lo = (__pyx_v_mi + 1);
    }
    __pyx_L9:;
  }

  /* "lurrn/sparsmat.pyx":863
 *             else:
 *                 lo=mi+1
 *         if self.mat.rightColumns[lo]==k2:             # <<<<<<<<<<<<<<
 *             return self.mat.values[lo]
 *         return 0
 */
  __pyx_t_10 = (((__pyx_v_self->mat->rightColumns[__pyx_v_lo]) == __pyx_v_k2) != 0);
  if (__pyx_t_10) {

    /* "lurrn/sparsmat.pyx":864
 *                 lo=mi+1
 *         if self.mat.rightColumns[lo]==k2:
 *             return self.mat.values[lo]             # <<<<<<<<<<<<<<
 *         return 0
 *     def write_binary(self,f):
 */
    __pyx_r = (__pyx_v_self->mat->values[__pyx_v_lo]);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":865
 *         if self.mat.rightColumns[lo]==k2:
 *             return self.mat.values[lo]
 *         return 0             # <<<<<<<<<<<<<<
 *     def write_binary(self,f):
 *         """writes the matrix in binary format"""
 */
  __pyx_r = 0.0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":845
 *         self.mat.compute_right_squared_marginals(<float *> marginals_r.data)
 *         return marginals_r
 *     cpdef float get_count(self,coordinate_t k, coordinate_t k2):             # <<<<<<<<<<<<<<
 *         if k<0 or k>=self.mat.num_rows:
 *             return 0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_WriteUnraisable("lurrn.sparsmat.CSRMatrixF.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_53get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_53get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_k2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_k2,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_count", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k2 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k2 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_count", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_52get_count(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self), __pyx_v_k, __pyx_v_k2);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_52get_count(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, coordinate_t __pyx_v_k, coordinate_t __pyx_v_k2) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_get_count(__pyx_v_self, __pyx_v_k, __pyx_v_k2, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":866
 *             return self.mat.values[lo]
 *         return 0
 *     def write_binary(self,f):             # <<<<<<<<<<<<<<
 *         """writes the matrix in binary format"""
 *         cdef int fileno=f.fileno()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_55write_binary(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static char __pyx_doc_5lurrn_8sparsmat_10CSRMatrixF_54write_binary[] = "writes the matrix in binary format";
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_55write_binary(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_binary (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_54write_binary(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_54write_binary(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, PyObject *__pyx_v_f) {
  int __pyx_v_fileno;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("write_binary", 0);

  /* "lurrn/sparsmat.pyx":868
 *     def write_binary(self,f):
 *         """writes the matrix in binary format"""
 *         cdef int fileno=f.fileno()             # <<<<<<<<<<<<<<
 *         self.mat.write_binary(fileno)
 *     def transpose(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_fileno); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_fileno = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":869
 *         """writes the matrix in binary format"""
 *         cdef int fileno=f.fileno()
 *         self.mat.write_binary(fileno)             # <<<<<<<<<<<<<<
 *     def transpose(self):
 *         cdef c_CSRMatrixF *matC=self.mat.transpose()
 */
  __pyx_v_self->mat->write_binary(__pyx_v_fileno);

  /* "lurrn/sparsmat.pyx":866
 *             return self.mat.values[lo]
 *         return 0
 *     def write_binary(self,f):             # <<<<<<<<<<<<<<
 *         """writes the matrix in binary format"""
 *         cdef int fileno=f.fileno()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.write_binary", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":870
 *         cdef int fileno=f.fileno()
 *         self.mat.write_binary(fileno)
 *     def transpose(self):             # <<<<<<<<<<<<<<
 *         cdef c_CSRMatrixF *matC=self.mat.transpose()
 *         cdef CSRMatrixF mat=CSRMatrixF()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_57transpose(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_57transpose(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("transpose (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_56transpose(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_56transpose(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self) {
  struct CSRMatrix<float> *__pyx_v_matC;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_mat = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transpose", 0);

  /* "lurrn/sparsmat.pyx":871
 *         self.mat.write_binary(fileno)
 *     def transpose(self):
 *         cdef c_CSRMatrixF *matC=self.mat.transpose()             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixF mat=CSRMatrixF()
 *         mat.set_matrix(matC)
 */
  __pyx_v_matC = __pyx_v_self->mat->transpose();

  /* "lurrn/sparsmat.pyx":872
 *     def transpose(self):
 *         cdef c_CSRMatrixF *matC=self.mat.transpose()
 *         cdef CSRMatrixF mat=CSRMatrixF()             # <<<<<<<<<<<<<<
 *         mat.set_matrix(matC)
 *         return mat
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixF)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_mat = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":873
 *         cdef c_CSRMatrixF *matC=self.mat.transpose()
 *         cdef CSRMatrixF mat=CSRMatrixF()
 *         mat.set_matrix(matC)             # <<<<<<<<<<<<<<
 *         return mat
 *     def __add__(self,other):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_mat->__pyx_vtab)->set_matrix(__pyx_v_mat, __pyx_v_matC);

  /* "lurrn/sparsmat.pyx":874
 *         cdef CSRMatrixF mat=CSRMatrixF()
 *         mat.set_matrix(matC)
 *         return mat             # <<<<<<<<<<<<<<
 *     def __add__(self,other):
 *         cdef CSRMatrixF mat1
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_mat));
  __pyx_r = ((PyObject *)__pyx_v_mat);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":870
 *         cdef int fileno=f.fileno()
 *         self.mat.write_binary(fileno)
 *     def transpose(self):             # <<<<<<<<<<<<<<
 *         cdef c_CSRMatrixF *matC=self.mat.transpose()
 *         cdef CSRMatrixF mat=CSRMatrixF()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.transpose", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mat);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":875
 *         mat.set_matrix(matC)
 *         return mat
 *     def __add__(self,other):             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixF mat1
 *         cdef CSRMatrixF mat2
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_59__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_59__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_58__add__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_58__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_mat1 = 0;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_mat2 = 0;
  struct CSRMatrix<float> *__pyx_v_matC;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_mat = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":879
 *         cdef CSRMatrixF mat2
 *         cdef c_CSRMatrixF *matC
 *         mat1=self             # <<<<<<<<<<<<<<
 *         mat2=other
 *         matC=add_csrF(mat1.mat,mat2.mat)
 */
  if (!(likely(((__pyx_v_self) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_self, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_self;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_mat1 = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":880
 *         cdef c_CSRMatrixF *matC
 *         mat1=self
 *         mat2=other             # <<<<<<<<<<<<<<
 *         matC=add_csrF(mat1.mat,mat2.mat)
 *         cdef CSRMatrixF mat=CSRMatrixF()
 */
  if (!(likely(((__pyx_v_other) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_other, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_other;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_mat2 = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":881
 *         mat1=self
 *         mat2=other
 *         matC=add_csrF(mat1.mat,mat2.mat)             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixF mat=CSRMatrixF()
 *         mat.set_matrix(matC)
 */
  __pyx_v_matC = add_csr(__pyx_v_mat1->mat, __pyx_v_mat2->mat);

  /* "lurrn/sparsmat.pyx":882
 *         mat2=other
 *         matC=add_csrF(mat1.mat,mat2.mat)
 *         cdef CSRMatrixF mat=CSRMatrixF()             # <<<<<<<<<<<<<<
 *         mat.set_matrix(matC)
 *         return mat
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixF)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_mat = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":883
 *         matC=add_csrF(mat1.mat,mat2.mat)
 *         cdef CSRMatrixF mat=CSRMatrixF()
 *         mat.set_matrix(matC)             # <<<<<<<<<<<<<<
 *         return mat
 *     def __dealloc__(self):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_mat->__pyx_vtab)->set_matrix(__pyx_v_mat, __pyx_v_matC);

  /* "lurrn/sparsmat.pyx":884
 *         cdef CSRMatrixF mat=CSRMatrixF()
 *         mat.set_matrix(matC)
 *         return mat             # <<<<<<<<<<<<<<
 *     def __dealloc__(self):
 *         if self.mat!=NULL:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_mat));
  __pyx_r = ((PyObject *)__pyx_v_mat);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":875
 *         mat.set_matrix(matC)
 *         return mat
 *     def __add__(self,other):             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixF mat1
 *         cdef CSRMatrixF mat2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mat1);
  __Pyx_XDECREF((PyObject *)__pyx_v_mat2);
  __Pyx_XDECREF((PyObject *)__pyx_v_mat);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":885
 *         mat.set_matrix(matC)
 *         return mat
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.mat!=NULL:
 *             if self.buf is not None:
 */

/* Python wrapper */
static void __pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_61__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_61__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_60__dealloc__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_60__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lurrn/sparsmat.pyx":886
 *         return mat
 *     def __dealloc__(self):
 *         if self.mat!=NULL:             # <<<<<<<<<<<<<<
 *             if self.buf is not None:
 *                 self.buf=None
 */
  __pyx_t_1 = ((__pyx_v_self->mat != NULL) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":887
 *     def __dealloc__(self):
 *         if self.mat!=NULL:
 *             if self.buf is not None:             # <<<<<<<<<<<<<<
 *                 self.buf=None
 *             else:
 */
    __pyx_t_1 = (__pyx_v_self->buf != Py_None);
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":888
 *         if self.mat!=NULL:
 *             if self.buf is not None:
 *                 self.buf=None             # <<<<<<<<<<<<<<
 *             else:
 *                 cxx_deleteA(self.mat.offsets)
 */
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      __Pyx_GOTREF(__pyx_v_self->buf);
      __Pyx_DECREF(__pyx_v_self->buf);
      __pyx_v_self->buf = Py_None;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":890
 *                 self.buf=None
 *             else:
 *                 cxx_deleteA(self.mat.offsets)             # <<<<<<<<<<<<<<
 *                 if (self.mat.rightColumns!=NULL):
 *                     cxx_deleteA(self.mat.rightColumns)
 */
      delete [](__pyx_v_self->mat->offsets);

      /* "lurrn/sparsmat.pyx":891
 *             else:
 *                 cxx_deleteA(self.mat.offsets)
 *                 if (self.mat.rightColumns!=NULL):             # <<<<<<<<<<<<<<
 *                     cxx_deleteA(self.mat.rightColumns)
 *                     cxx_deleteA(self.mat.values)
 */
      __pyx_t_2 = ((__pyx_v_self->mat->rightColumns != NULL) != 0);
      if (__pyx_t_2) {

        /* "lurrn/sparsmat.pyx":892
 *                 cxx_deleteA(self.mat.offsets)
 *                 if (self.mat.rightColumns!=NULL):
 *                     cxx_deleteA(self.mat.rightColumns)             # <<<<<<<<<<<<<<
 *                     cxx_deleteA(self.mat.values)
 *             cxx_delete(self.mat)
 */
        delete [](__pyx_v_self->mat->rightColumns);

        /* "lurrn/sparsmat.pyx":893
 *                 if (self.mat.rightColumns!=NULL):
 *                     cxx_deleteA(self.mat.rightColumns)
 *                     cxx_deleteA(self.mat.values)             # <<<<<<<<<<<<<<
 *             cxx_delete(self.mat)
 *     def __reduce__(self):
 */
        delete [](__pyx_v_self->mat->values);
        goto __pyx_L5;
      }
      __pyx_L5:;
    }
    __pyx_L4:;

    /* "lurrn/sparsmat.pyx":894
 *                     cxx_deleteA(self.mat.rightColumns)
 *                     cxx_deleteA(self.mat.values)
 *             cxx_delete(self.mat)             # <<<<<<<<<<<<<<
 *     def __reduce__(self):
 *         # choose compatibility over performance.
 */
    delete(__pyx_v_self->mat);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":885
 *         mat.set_matrix(matC)
 *         return mat
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.mat!=NULL:
 *             if self.buf is not None:
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":895
 *                     cxx_deleteA(self.mat.values)
 *             cxx_delete(self.mat)
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         # choose compatibility over performance.
 *         cdef VecF2 tmp=VecF2()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_63__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_63__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_62__reduce__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_62__reduce__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self) {
  struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_tmp = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "lurrn/sparsmat.pyx":897
 *     def __reduce__(self):
 *         # choose compatibility over performance.
 *         cdef VecF2 tmp=VecF2()             # <<<<<<<<<<<<<<
 *         tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         tmp.extend(self.item_iter())
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":898
 *         # choose compatibility over performance.
 *         cdef VecF2 tmp=VecF2()
 *         tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         tmp.extend(self.item_iter())
 *         return (CSRMatrixF,(),tmp)
 */
  __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));

  /* "lurrn/sparsmat.pyx":899
 *         cdef VecF2 tmp=VecF2()
 *         tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         tmp.extend(self.item_iter())             # <<<<<<<<<<<<<<
 *         return (CSRMatrixF,(),tmp)
 *     def __setstate__(self,VecF2 tmp):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_extend); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":900
 *         tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         tmp.extend(self.item_iter())
 *         return (CSRMatrixF,(),tmp)             # <<<<<<<<<<<<<<
 *     def __setstate__(self,VecF2 tmp):
 *         tmp.ensure_compact()
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixF)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixF)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixF)));
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  __Pyx_INCREF(((PyObject *)__pyx_v_tmp));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_tmp));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_tmp));
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":895
 *                     cxx_deleteA(self.mat.values)
 *             cxx_delete(self.mat)
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         # choose compatibility over performance.
 *         cdef VecF2 tmp=VecF2()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":901
 *         tmp.extend(self.item_iter())
 *         return (CSRMatrixF,(),tmp)
 *     def __setstate__(self,VecF2 tmp):             # <<<<<<<<<<<<<<
 *         tmp.ensure_compact()
 *         self.set_matrix(vec2csrF(&tmp.vec))
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_65__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_tmp); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_65__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_tmp) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tmp), __pyx_ptype_5lurrn_8sparsmat_VecF2, 1, "tmp", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_64__setstate__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_tmp));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixF_64__setstate__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_tmp) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* "lurrn/sparsmat.pyx":902
 *         return (CSRMatrixF,(),tmp)
 *     def __setstate__(self,VecF2 tmp):
 *         tmp.ensure_compact()             # <<<<<<<<<<<<<<
 *         self.set_matrix(vec2csrF(&tmp.vec))
 * 
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF2 *)__pyx_v_tmp->__pyx_vtab)->ensure_compact(__pyx_v_tmp);

  /* "lurrn/sparsmat.pyx":903
 *     def __setstate__(self,VecF2 tmp):
 *         tmp.ensure_compact()
 *         self.set_matrix(vec2csrF(&tmp.vec))             # <<<<<<<<<<<<<<
 * 
 * cdef class CSRMatrixF_item_iter:
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_self->__pyx_vtab)->set_matrix(__pyx_v_self, vec2csr((&__pyx_v_tmp->vec)));

  /* "lurrn/sparsmat.pyx":901
 *         tmp.extend(self.item_iter())
 *         return (CSRMatrixF,(),tmp)
 *     def __setstate__(self,VecF2 tmp):             # <<<<<<<<<<<<<<
 *         tmp.ensure_compact()
 *         self.set_matrix(vec2csrF(&tmp.vec))
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":910
 *     cdef coordinate_t k
 *     cdef int off
 *     def __init__(self, mat):             # <<<<<<<<<<<<<<
 *         self.mat=mat
 *         self.matC=self.mat.mat
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_20CSRMatrixF_item_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_20CSRMatrixF_item_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_mat = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mat,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mat)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_mat = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF_item_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_20CSRMatrixF_item_iter___init__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter *)__pyx_v_self), __pyx_v_mat);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_20CSRMatrixF_item_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter *__pyx_v_self, PyObject *__pyx_v_mat) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct CSRMatrix<float> *__pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":911
 *     cdef int off
 *     def __init__(self, mat):
 *         self.mat=mat             # <<<<<<<<<<<<<<
 *         self.matC=self.mat.mat
 *         self.k=0
 */
  if (!(likely(((__pyx_v_mat) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_mat, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_mat;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->mat);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->mat));
  __pyx_v_self->mat = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":912
 *     def __init__(self, mat):
 *         self.mat=mat
 *         self.matC=self.mat.mat             # <<<<<<<<<<<<<<
 *         self.k=0
 *         self.off=0
 */
  __pyx_t_2 = __pyx_v_self->mat->mat;
  __pyx_v_self->matC = __pyx_t_2;

  /* "lurrn/sparsmat.pyx":913
 *         self.mat=mat
 *         self.matC=self.mat.mat
 *         self.k=0             # <<<<<<<<<<<<<<
 *         self.off=0
 *     def __iter__(self):
 */
  __pyx_v_self->k = 0;

  /* "lurrn/sparsmat.pyx":914
 *         self.matC=self.mat.mat
 *         self.k=0
 *         self.off=0             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self
 */
  __pyx_v_self->off = 0;

  /* "lurrn/sparsmat.pyx":910
 *     cdef coordinate_t k
 *     cdef int off
 *     def __init__(self, mat):             # <<<<<<<<<<<<<<
 *         self.mat=mat
 *         self.matC=self.mat.mat
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF_item_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":915
 *         self.k=0
 *         self.off=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_20CSRMatrixF_item_iter_3__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_20CSRMatrixF_item_iter_3__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_20CSRMatrixF_item_iter_2__iter__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_20CSRMatrixF_item_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":916
 *         self.off=0
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 *     def __next__(self):
 *         while self.off==self.matC.offsets[self.k+1]:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":915
 *         self.k=0
 *         self.off=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":917
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         while self.off==self.matC.offsets[self.k+1]:
 *             self.k+=1
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_20CSRMatrixF_item_iter_5__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_20CSRMatrixF_item_iter_5__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_20CSRMatrixF_item_iter_4__next__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_20CSRMatrixF_item_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter *__pyx_v_self) {
  PyObject *__pyx_v_res = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "lurrn/sparsmat.pyx":918
 *         return self
 *     def __next__(self):
 *         while self.off==self.matC.offsets[self.k+1]:             # <<<<<<<<<<<<<<
 *             self.k+=1
 *             if self.k>=self.matC.num_rows:
 */
  while (1) {
    __pyx_t_1 = ((__pyx_v_self->off == (__pyx_v_self->matC->offsets[(__pyx_v_self->k + 1)])) != 0);
    if (!__pyx_t_1) break;

    /* "lurrn/sparsmat.pyx":919
 *     def __next__(self):
 *         while self.off==self.matC.offsets[self.k+1]:
 *             self.k+=1             # <<<<<<<<<<<<<<
 *             if self.k>=self.matC.num_rows:
 *                 raise StopIteration
 */
    __pyx_v_self->k = (__pyx_v_self->k + 1);

    /* "lurrn/sparsmat.pyx":920
 *         while self.off==self.matC.offsets[self.k+1]:
 *             self.k+=1
 *             if self.k>=self.matC.num_rows:             # <<<<<<<<<<<<<<
 *                 raise StopIteration
 *         res=(self.k,
 */
    __pyx_t_1 = ((__pyx_v_self->k >= __pyx_v_self->matC->num_rows) != 0);
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":921
 *             self.k+=1
 *             if self.k>=self.matC.num_rows:
 *                 raise StopIteration             # <<<<<<<<<<<<<<
 *         res=(self.k,
 *              self.matC.rightColumns[self.off],
 */
      __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }

  /* "lurrn/sparsmat.pyx":922
 *             if self.k>=self.matC.num_rows:
 *                 raise StopIteration
 *         res=(self.k,             # <<<<<<<<<<<<<<
 *              self.matC.rightColumns[self.off],
 *              self.matC.values[self.off])
 */
  __pyx_t_2 = __Pyx_PyInt_From_coordinate_t(__pyx_v_self->k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "lurrn/sparsmat.pyx":923
 *                 raise StopIteration
 *         res=(self.k,
 *              self.matC.rightColumns[self.off],             # <<<<<<<<<<<<<<
 *              self.matC.values[self.off])
 *         self.off+=1
 */
  __pyx_t_3 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->matC->rightColumns[__pyx_v_self->off])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "lurrn/sparsmat.pyx":924
 *         res=(self.k,
 *              self.matC.rightColumns[self.off],
 *              self.matC.values[self.off])             # <<<<<<<<<<<<<<
 *         self.off+=1
 *         return res
 */
  __pyx_t_4 = PyFloat_FromDouble((__pyx_v_self->matC->values[__pyx_v_self->off])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":922
 *             if self.k>=self.matC.num_rows:
 *                 raise StopIteration
 *         res=(self.k,             # <<<<<<<<<<<<<<
 *              self.matC.rightColumns[self.off],
 *              self.matC.values[self.off])
 */
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_v_res = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "lurrn/sparsmat.pyx":925
 *              self.matC.rightColumns[self.off],
 *              self.matC.values[self.off])
 *         self.off+=1             # <<<<<<<<<<<<<<
 *         return res
 * ## D -> double, float64
 */
  __pyx_v_self->off = (__pyx_v_self->off + 1);

  /* "lurrn/sparsmat.pyx":926
 *              self.matC.values[self.off])
 *         self.off+=1
 *         return res             # <<<<<<<<<<<<<<
 * ## D -> double, float64
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_res);
  __pyx_r = __pyx_v_res;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":917
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         while self.off==self.matC.offsets[self.k+1]:
 *             self.k+=1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixF_item_iter.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_res);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":935
 * 
 * cdef class CSRMatrixD:
 *     def __cinit__(self, vecs=None):             # <<<<<<<<<<<<<<
 *         self.mat=NULL
 *         self.cache_maxcol=-1
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_vecs = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_vecs,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vecs);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_vecs = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD___cinit__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self), __pyx_v_vecs);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD___cinit__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_vecs) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "lurrn/sparsmat.pyx":936
 * cdef class CSRMatrixD:
 *     def __cinit__(self, vecs=None):
 *         self.mat=NULL             # <<<<<<<<<<<<<<
 *         self.cache_maxcol=-1
 *         if vecs is not None:
 */
  __pyx_v_self->mat = NULL;

  /* "lurrn/sparsmat.pyx":937
 *     def __cinit__(self, vecs=None):
 *         self.mat=NULL
 *         self.cache_maxcol=-1             # <<<<<<<<<<<<<<
 *         if vecs is not None:
 *             self.fromVectors(vecs)
 */
  __pyx_v_self->cache_maxcol = -1;

  /* "lurrn/sparsmat.pyx":938
 *         self.mat=NULL
 *         self.cache_maxcol=-1
 *         if vecs is not None:             # <<<<<<<<<<<<<<
 *             self.fromVectors(vecs)
 *     cdef void set_matrix(self,c_CSRMatrixD *mat_new):
 */
  __pyx_t_1 = (__pyx_v_vecs != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lurrn/sparsmat.pyx":939
 *         self.cache_maxcol=-1
 *         if vecs is not None:
 *             self.fromVectors(vecs)             # <<<<<<<<<<<<<<
 *     cdef void set_matrix(self,c_CSRMatrixD *mat_new):
 *         self.mat=mat_new
 */
    __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self->__pyx_vtab)->fromVectors(__pyx_v_self, __pyx_v_vecs, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":935
 * 
 * cdef class CSRMatrixD:
 *     def __cinit__(self, vecs=None):             # <<<<<<<<<<<<<<
 *         self.mat=NULL
 *         self.cache_maxcol=-1
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":940
 *         if vecs is not None:
 *             self.fromVectors(vecs)
 *     cdef void set_matrix(self,c_CSRMatrixD *mat_new):             # <<<<<<<<<<<<<<
 *         self.mat=mat_new
 *         self.cache_maxcol=-1
 */

static void __pyx_f_5lurrn_8sparsmat_10CSRMatrixD_set_matrix(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, struct CSRMatrix<double> *__pyx_v_mat_new) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_matrix", 0);

  /* "lurrn/sparsmat.pyx":941
 *             self.fromVectors(vecs)
 *     cdef void set_matrix(self,c_CSRMatrixD *mat_new):
 *         self.mat=mat_new             # <<<<<<<<<<<<<<
 *         self.cache_maxcol=-1
 *     cpdef CSRMatrixD fromVectors(self, vectors):
 */
  __pyx_v_self->mat = __pyx_v_mat_new;

  /* "lurrn/sparsmat.pyx":942
 *     cdef void set_matrix(self,c_CSRMatrixD *mat_new):
 *         self.mat=mat_new
 *         self.cache_maxcol=-1             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixD fromVectors(self, vectors):
 *         cdef int spaceNeeded=0
 */
  __pyx_v_self->cache_maxcol = -1;

  /* "lurrn/sparsmat.pyx":940
 *         if vecs is not None:
 *             self.fromVectors(vecs)
 *     cdef void set_matrix(self,c_CSRMatrixD *mat_new):             # <<<<<<<<<<<<<<
 *         self.mat=mat_new
 *         self.cache_maxcol=-1
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":943
 *         self.mat=mat_new
 *         self.cache_maxcol=-1
 *     cpdef CSRMatrixD fromVectors(self, vectors):             # <<<<<<<<<<<<<<
 *         cdef int spaceNeeded=0
 *         cdef int i=0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_3fromVectors(PyObject *__pyx_v_self, PyObject *__pyx_v_vectors); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_fromVectors(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_vectors, int __pyx_skip_dispatch) {
  int __pyx_v_spaceNeeded;
  int __pyx_v_i;
  int __pyx_v_j;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_vec = 0;
  struct CSRMatrix<double> *__pyx_v_c_result;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  unsigned int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromVectors", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_fromVectors); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_3fromVectors)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_vectors); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(__pyx_v_vectors);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_vectors);
        __Pyx_GIVEREF(__pyx_v_vectors);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":944
 *         self.cache_maxcol=-1
 *     cpdef CSRMatrixD fromVectors(self, vectors):
 *         cdef int spaceNeeded=0             # <<<<<<<<<<<<<<
 *         cdef int i=0
 *         cdef int j=0
 */
  __pyx_v_spaceNeeded = 0;

  /* "lurrn/sparsmat.pyx":945
 *     cpdef CSRMatrixD fromVectors(self, vectors):
 *         cdef int spaceNeeded=0
 *         cdef int i=0             # <<<<<<<<<<<<<<
 *         cdef int j=0
 *         cdef SparseVectorD vec
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":946
 *         cdef int spaceNeeded=0
 *         cdef int i=0
 *         cdef int j=0             # <<<<<<<<<<<<<<
 *         cdef SparseVectorD vec
 *         cdef c_CSRMatrixD *c_result
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":950
 *         cdef c_CSRMatrixD *c_result
 *         cdef CSRMatrixD result
 *         for vec in vectors:             # <<<<<<<<<<<<<<
 *             spaceNeeded+=vec.my_len
 *             i+=1
 */
  if (likely(PyList_CheckExact(__pyx_v_vectors)) || PyTuple_CheckExact(__pyx_v_vectors)) {
    __pyx_t_1 = __pyx_v_vectors; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_vectors); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_SparseVectorD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":951
 *         cdef CSRMatrixD result
 *         for vec in vectors:
 *             spaceNeeded+=vec.my_len             # <<<<<<<<<<<<<<
 *             i+=1
 *         c_result=new_csrD(i,spaceNeeded)
 */
    __pyx_v_spaceNeeded = (__pyx_v_spaceNeeded + __pyx_v_vec->my_len);

    /* "lurrn/sparsmat.pyx":952
 *         for vec in vectors:
 *             spaceNeeded+=vec.my_len
 *             i+=1             # <<<<<<<<<<<<<<
 *         c_result=new_csrD(i,spaceNeeded)
 *         i=0
 */
    __pyx_v_i = (__pyx_v_i + 1);

    /* "lurrn/sparsmat.pyx":950
 *         cdef c_CSRMatrixD *c_result
 *         cdef CSRMatrixD result
 *         for vec in vectors:             # <<<<<<<<<<<<<<
 *             spaceNeeded+=vec.my_len
 *             i+=1
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":953
 *             spaceNeeded+=vec.my_len
 *             i+=1
 *         c_result=new_csrD(i,spaceNeeded)             # <<<<<<<<<<<<<<
 *         i=0
 *         spaceNeeded=0
 */
  __pyx_v_c_result = new_csr<double>(__pyx_v_i, __pyx_v_spaceNeeded);

  /* "lurrn/sparsmat.pyx":954
 *             i+=1
 *         c_result=new_csrD(i,spaceNeeded)
 *         i=0             # <<<<<<<<<<<<<<
 *         spaceNeeded=0
 *         for vec in vectors:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":955
 *         c_result=new_csrD(i,spaceNeeded)
 *         i=0
 *         spaceNeeded=0             # <<<<<<<<<<<<<<
 *         for vec in vectors:
 *             c_result.offsets[i]=spaceNeeded
 */
  __pyx_v_spaceNeeded = 0;

  /* "lurrn/sparsmat.pyx":956
 *         i=0
 *         spaceNeeded=0
 *         for vec in vectors:             # <<<<<<<<<<<<<<
 *             c_result.offsets[i]=spaceNeeded
 *             for j from 0<=j<vec.my_len:
 */
  if (likely(PyList_CheckExact(__pyx_v_vectors)) || PyTuple_CheckExact(__pyx_v_vectors)) {
    __pyx_t_1 = __pyx_v_vectors; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_vectors); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_SparseVectorD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":957
 *         spaceNeeded=0
 *         for vec in vectors:
 *             c_result.offsets[i]=spaceNeeded             # <<<<<<<<<<<<<<
 *             for j from 0<=j<vec.my_len:
 *                  c_result.rightColumns[spaceNeeded]=vec.idx_ptr[j]
 */
    (__pyx_v_c_result->offsets[__pyx_v_i]) = __pyx_v_spaceNeeded;

    /* "lurrn/sparsmat.pyx":958
 *         for vec in vectors:
 *             c_result.offsets[i]=spaceNeeded
 *             for j from 0<=j<vec.my_len:             # <<<<<<<<<<<<<<
 *                  c_result.rightColumns[spaceNeeded]=vec.idx_ptr[j]
 *                  c_result.values[spaceNeeded]=vec.vals_ptr[j]
 */
    __pyx_t_8 = __pyx_v_vec->my_len;
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_8; __pyx_v_j++) {

      /* "lurrn/sparsmat.pyx":959
 *             c_result.offsets[i]=spaceNeeded
 *             for j from 0<=j<vec.my_len:
 *                  c_result.rightColumns[spaceNeeded]=vec.idx_ptr[j]             # <<<<<<<<<<<<<<
 *                  c_result.values[spaceNeeded]=vec.vals_ptr[j]
 *                  spaceNeeded+=1
 */
      (__pyx_v_c_result->rightColumns[__pyx_v_spaceNeeded]) = (__pyx_v_vec->idx_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":960
 *             for j from 0<=j<vec.my_len:
 *                  c_result.rightColumns[spaceNeeded]=vec.idx_ptr[j]
 *                  c_result.values[spaceNeeded]=vec.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                  spaceNeeded+=1
 *             i+=1
 */
      (__pyx_v_c_result->values[__pyx_v_spaceNeeded]) = (__pyx_v_vec->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":961
 *                  c_result.rightColumns[spaceNeeded]=vec.idx_ptr[j]
 *                  c_result.values[spaceNeeded]=vec.vals_ptr[j]
 *                  spaceNeeded+=1             # <<<<<<<<<<<<<<
 *             i+=1
 *         c_result.offsets[i]=spaceNeeded
 */
      __pyx_v_spaceNeeded = (__pyx_v_spaceNeeded + 1);
    }

    /* "lurrn/sparsmat.pyx":962
 *                  c_result.values[spaceNeeded]=vec.vals_ptr[j]
 *                  spaceNeeded+=1
 *             i+=1             # <<<<<<<<<<<<<<
 *         c_result.offsets[i]=spaceNeeded
 *         self.set_matrix(c_result)
 */
    __pyx_v_i = (__pyx_v_i + 1);

    /* "lurrn/sparsmat.pyx":956
 *         i=0
 *         spaceNeeded=0
 *         for vec in vectors:             # <<<<<<<<<<<<<<
 *             c_result.offsets[i]=spaceNeeded
 *             for j from 0<=j<vec.my_len:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":963
 *                  spaceNeeded+=1
 *             i+=1
 *         c_result.offsets[i]=spaceNeeded             # <<<<<<<<<<<<<<
 *         self.set_matrix(c_result)
 *         return self
 */
  (__pyx_v_c_result->offsets[__pyx_v_i]) = __pyx_v_spaceNeeded;

  /* "lurrn/sparsmat.pyx":964
 *             i+=1
 *         c_result.offsets[i]=spaceNeeded
 *         self.set_matrix(c_result)             # <<<<<<<<<<<<<<
 *         return self
 *     def __lshift__(CSRMatrixD self,int k):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self->__pyx_vtab)->set_matrix(__pyx_v_self, __pyx_v_c_result);

  /* "lurrn/sparsmat.pyx":965
 *         c_result.offsets[i]=spaceNeeded
 *         self.set_matrix(c_result)
 *         return self             # <<<<<<<<<<<<<<
 *     def __lshift__(CSRMatrixD self,int k):
 *         cdef CSRMatrixD result
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":943
 *         self.mat=mat_new
 *         self.cache_maxcol=-1
 *     cpdef CSRMatrixD fromVectors(self, vectors):             # <<<<<<<<<<<<<<
 *         cdef int spaceNeeded=0
 *         cdef int i=0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.fromVectors", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_vec);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_3fromVectors(PyObject *__pyx_v_self, PyObject *__pyx_v_vectors); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_3fromVectors(PyObject *__pyx_v_self, PyObject *__pyx_v_vectors) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fromVectors (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_2fromVectors(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self), ((PyObject *)__pyx_v_vectors));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_2fromVectors(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_vectors) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromVectors", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_fromVectors(__pyx_v_self, __pyx_v_vectors, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.fromVectors", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":966
 *         self.set_matrix(c_result)
 *         return self
 *     def __lshift__(CSRMatrixD self,int k):             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixD result
 *         cdef c_CSRMatrixD *c_mat
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_5__lshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_5__lshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__lshift__ (wrapper)", 0);
  assert(__pyx_arg_k); {
    __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.__lshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_4__lshift__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self), ((int)__pyx_v_k));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_4__lshift__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, int __pyx_v_k) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_result = 0;
  struct CSRMatrix<double> *__pyx_v_c_mat;
  struct CSRMatrix<double> *__pyx_v_c_result;
  int __pyx_v_i;
  int __pyx_v_nnz;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct CSRMatrix<double> *__pyx_t_1;
  coordinate_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__lshift__", 0);

  /* "lurrn/sparsmat.pyx":971
 *         cdef c_CSRMatrixD *c_result
 *         cdef int i, nnz
 *         c_mat=self.mat             # <<<<<<<<<<<<<<
 *         nnz=c_mat.offsets[c_mat.num_rows]
 *         c_result=new_csrD(c_mat.num_rows, nnz)
 */
  __pyx_t_1 = __pyx_v_self->mat;
  __pyx_v_c_mat = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":972
 *         cdef int i, nnz
 *         c_mat=self.mat
 *         nnz=c_mat.offsets[c_mat.num_rows]             # <<<<<<<<<<<<<<
 *         c_result=new_csrD(c_mat.num_rows, nnz)
 *         for i from 0<=i<=c_mat.num_rows:
 */
  __pyx_v_nnz = (__pyx_v_c_mat->offsets[__pyx_v_c_mat->num_rows]);

  /* "lurrn/sparsmat.pyx":973
 *         c_mat=self.mat
 *         nnz=c_mat.offsets[c_mat.num_rows]
 *         c_result=new_csrD(c_mat.num_rows, nnz)             # <<<<<<<<<<<<<<
 *         for i from 0<=i<=c_mat.num_rows:
 *             c_result.offsets[i]=c_mat.offsets[i]
 */
  __pyx_v_c_result = new_csr<double>(__pyx_v_c_mat->num_rows, __pyx_v_nnz);

  /* "lurrn/sparsmat.pyx":974
 *         nnz=c_mat.offsets[c_mat.num_rows]
 *         c_result=new_csrD(c_mat.num_rows, nnz)
 *         for i from 0<=i<=c_mat.num_rows:             # <<<<<<<<<<<<<<
 *             c_result.offsets[i]=c_mat.offsets[i]
 *         for i from 0<=i<nnz:
 */
  __pyx_t_2 = __pyx_v_c_mat->num_rows;
  for (__pyx_v_i = 0; __pyx_v_i <= __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":975
 *         c_result=new_csrD(c_mat.num_rows, nnz)
 *         for i from 0<=i<=c_mat.num_rows:
 *             c_result.offsets[i]=c_mat.offsets[i]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<nnz:
 *             c_result.rightColumns[i]=c_mat.rightColumns[i]+k
 */
    (__pyx_v_c_result->offsets[__pyx_v_i]) = (__pyx_v_c_mat->offsets[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":976
 *         for i from 0<=i<=c_mat.num_rows:
 *             c_result.offsets[i]=c_mat.offsets[i]
 *         for i from 0<=i<nnz:             # <<<<<<<<<<<<<<
 *             c_result.rightColumns[i]=c_mat.rightColumns[i]+k
 *         for i from 0<=i<nnz:
 */
  __pyx_t_3 = __pyx_v_nnz;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":977
 *             c_result.offsets[i]=c_mat.offsets[i]
 *         for i from 0<=i<nnz:
 *             c_result.rightColumns[i]=c_mat.rightColumns[i]+k             # <<<<<<<<<<<<<<
 *         for i from 0<=i<nnz:
 *             c_result.values[i]=c_mat.values[i]
 */
    (__pyx_v_c_result->rightColumns[__pyx_v_i]) = ((__pyx_v_c_mat->rightColumns[__pyx_v_i]) + __pyx_v_k);
  }

  /* "lurrn/sparsmat.pyx":978
 *         for i from 0<=i<nnz:
 *             c_result.rightColumns[i]=c_mat.rightColumns[i]+k
 *         for i from 0<=i<nnz:             # <<<<<<<<<<<<<<
 *             c_result.values[i]=c_mat.values[i]
 *         result=CSRMatrixD()
 */
  __pyx_t_3 = __pyx_v_nnz;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":979
 *             c_result.rightColumns[i]=c_mat.rightColumns[i]+k
 *         for i from 0<=i<nnz:
 *             c_result.values[i]=c_mat.values[i]             # <<<<<<<<<<<<<<
 *         result=CSRMatrixD()
 *         result.set_matrix(c_result)
 */
    (__pyx_v_c_result->values[__pyx_v_i]) = (__pyx_v_c_mat->values[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":980
 *         for i from 0<=i<nnz:
 *             c_result.values[i]=c_mat.values[i]
 *         result=CSRMatrixD()             # <<<<<<<<<<<<<<
 *         result.set_matrix(c_result)
 *         return result
 */
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixD)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "lurrn/sparsmat.pyx":981
 *             c_result.values[i]=c_mat.values[i]
 *         result=CSRMatrixD()
 *         result.set_matrix(c_result)             # <<<<<<<<<<<<<<
 *         return result
 *     def __ilshift__(CSRMatrixD self, int k):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_result->__pyx_vtab)->set_matrix(__pyx_v_result, __pyx_v_c_result);

  /* "lurrn/sparsmat.pyx":982
 *         result=CSRMatrixD()
 *         result.set_matrix(c_result)
 *         return result             # <<<<<<<<<<<<<<
 *     def __ilshift__(CSRMatrixD self, int k):
 *         cdef c_CSRMatrixD *c_mat
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":966
 *         self.set_matrix(c_result)
 *         return self
 *     def __lshift__(CSRMatrixD self,int k):             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixD result
 *         cdef c_CSRMatrixD *c_mat
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.__lshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":983
 *         result.set_matrix(c_result)
 *         return result
 *     def __ilshift__(CSRMatrixD self, int k):             # <<<<<<<<<<<<<<
 *         cdef c_CSRMatrixD *c_mat
 *         cdef int i, nnz
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_7__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_7__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ilshift__ (wrapper)", 0);
  assert(__pyx_arg_k); {
    __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.__ilshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_6__ilshift__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self), ((int)__pyx_v_k));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_6__ilshift__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, int __pyx_v_k) {
  struct CSRMatrix<double> *__pyx_v_c_mat;
  int __pyx_v_i;
  int __pyx_v_nnz;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct CSRMatrix<double> *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("__ilshift__", 0);

  /* "lurrn/sparsmat.pyx":986
 *         cdef c_CSRMatrixD *c_mat
 *         cdef int i, nnz
 *         c_mat=self.mat             # <<<<<<<<<<<<<<
 *         nnz=c_mat.offsets[c_mat.num_rows]
 *         for i from 0<=i<nnz:
 */
  __pyx_t_1 = __pyx_v_self->mat;
  __pyx_v_c_mat = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":987
 *         cdef int i, nnz
 *         c_mat=self.mat
 *         nnz=c_mat.offsets[c_mat.num_rows]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<nnz:
 *             c_mat.rightColumns[i]+=k
 */
  __pyx_v_nnz = (__pyx_v_c_mat->offsets[__pyx_v_c_mat->num_rows]);

  /* "lurrn/sparsmat.pyx":988
 *         c_mat=self.mat
 *         nnz=c_mat.offsets[c_mat.num_rows]
 *         for i from 0<=i<nnz:             # <<<<<<<<<<<<<<
 *             c_mat.rightColumns[i]+=k
 *         return self
 */
  __pyx_t_2 = __pyx_v_nnz;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":989
 *         nnz=c_mat.offsets[c_mat.num_rows]
 *         for i from 0<=i<nnz:
 *             c_mat.rightColumns[i]+=k             # <<<<<<<<<<<<<<
 *         return self
 *     def print_csr(self):
 */
    __pyx_t_3 = __pyx_v_i;
    (__pyx_v_c_mat->rightColumns[__pyx_t_3]) = ((__pyx_v_c_mat->rightColumns[__pyx_t_3]) + __pyx_v_k);
  }

  /* "lurrn/sparsmat.pyx":990
 *         for i from 0<=i<nnz:
 *             c_mat.rightColumns[i]+=k
 *         return self             # <<<<<<<<<<<<<<
 *     def print_csr(self):
 *         print_csrD(self.mat)
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":983
 *         result.set_matrix(c_result)
 *         return result
 *     def __ilshift__(CSRMatrixD self, int k):             # <<<<<<<<<<<<<<
 *         cdef c_CSRMatrixD *c_mat
 *         cdef int i, nnz
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":991
 *             c_mat.rightColumns[i]+=k
 *         return self
 *     def print_csr(self):             # <<<<<<<<<<<<<<
 *         print_csrD(self.mat)
 *     def get_size(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_9print_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_9print_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("print_csr (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_8print_csr(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_8print_csr(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("print_csr", 0);

  /* "lurrn/sparsmat.pyx":992
 *         return self
 *     def print_csr(self):
 *         print_csrD(self.mat)             # <<<<<<<<<<<<<<
 *     def get_size(self):
 *         return self.mat.offsets[self.mat.num_rows]
 */
  print_csr<double>(__pyx_v_self->mat);

  /* "lurrn/sparsmat.pyx":991
 *             c_mat.rightColumns[i]+=k
 *         return self
 *     def print_csr(self):             # <<<<<<<<<<<<<<
 *         print_csrD(self.mat)
 *     def get_size(self):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":993
 *     def print_csr(self):
 *         print_csrD(self.mat)
 *     def get_size(self):             # <<<<<<<<<<<<<<
 *         return self.mat.offsets[self.mat.num_rows]
 *     def __len__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_11get_size(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_11get_size(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_10get_size(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_10get_size(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":994
 *         print_csrD(self.mat)
 *     def get_size(self):
 *         return self.mat.offsets[self.mat.num_rows]             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return self.mat.num_rows
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":993
 *     def print_csr(self):
 *         print_csrD(self.mat)
 *     def get_size(self):             # <<<<<<<<<<<<<<
 *         return self.mat.offsets[self.mat.num_rows]
 *     def __len__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":995
 *     def get_size(self):
 *         return self.mat.offsets[self.mat.num_rows]
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.mat.num_rows
 *     def __getitem__(self,k):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_13__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_13__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_12__len__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_12__len__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":996
 *         return self.mat.offsets[self.mat.num_rows]
 *     def __len__(self):
 *         return self.mat.num_rows             # <<<<<<<<<<<<<<
 *     def __getitem__(self,k):
 *         cdef int off1, off2
 */
  __pyx_r = __pyx_v_self->mat->num_rows;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":995
 *     def get_size(self):
 *         return self.mat.offsets[self.mat.num_rows]
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.mat.num_rows
 *     def __getitem__(self,k):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":997
 *     def __len__(self):
 *         return self.mat.num_rows
 *     def __getitem__(self,k):             # <<<<<<<<<<<<<<
 *         cdef int off1, off2
 *         cdef SparseVectorD res
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_15__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_k); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_15__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_14__getitem__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self), ((PyObject *)__pyx_v_k));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_14__getitem__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_k) {
  int __pyx_v_off1;
  int __pyx_v_off2;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_res = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "lurrn/sparsmat.pyx":1000
 *         cdef int off1, off2
 *         cdef SparseVectorD res
 *         if not (k>=0 and k<self.mat.num_rows):             # <<<<<<<<<<<<<<
 *             raise IndexError
 *         off1=self.mat.offsets[k]
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_k, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = __Pyx_PyInt_From_coordinate_t(__pyx_v_self->mat->num_rows); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  __pyx_t_3 = ((!__pyx_t_1) != 0);
  if (__pyx_t_3) {

    /* "lurrn/sparsmat.pyx":1001
 *         cdef SparseVectorD res
 *         if not (k>=0 and k<self.mat.num_rows):
 *             raise IndexError             # <<<<<<<<<<<<<<
 *         off1=self.mat.offsets[k]
 *         off2=self.mat.offsets[k+1]
 */
    __Pyx_Raise(__pyx_builtin_IndexError, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lurrn/sparsmat.pyx":1002
 *         if not (k>=0 and k<self.mat.num_rows):
 *             raise IndexError
 *         off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *         off2=self.mat.offsets[k+1]
 *         if off1==off2:
 */
  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_k); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_t_5]);

  /* "lurrn/sparsmat.pyx":1003
 *             raise IndexError
 *         off1=self.mat.offsets[k]
 *         off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *         if off1==off2:
 *             return emptyvec_D
 */
  __pyx_t_4 = PyNumber_Add(__pyx_v_k, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_off2 = (__pyx_v_self->mat->offsets[__pyx_t_5]);

  /* "lurrn/sparsmat.pyx":1004
 *         off1=self.mat.offsets[k]
 *         off2=self.mat.offsets[k+1]
 *         if off1==off2:             # <<<<<<<<<<<<<<
 *             return emptyvec_D
 *         res=SparseVectorD()
 */
  __pyx_t_3 = ((__pyx_v_off1 == __pyx_v_off2) != 0);
  if (__pyx_t_3) {

    /* "lurrn/sparsmat.pyx":1005
 *         off2=self.mat.offsets[k+1]
 *         if off1==off2:
 *             return emptyvec_D             # <<<<<<<<<<<<<<
 *         res=SparseVectorD()
 *         res.buf=self
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_5lurrn_8sparsmat_emptyvec_D));
    __pyx_r = ((PyObject *)__pyx_v_5lurrn_8sparsmat_emptyvec_D);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1006
 *         if off1==off2:
 *             return emptyvec_D
 *         res=SparseVectorD()             # <<<<<<<<<<<<<<
 *         res.buf=self
 *         res.my_len=off2-off1
 */
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorD)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_res = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "lurrn/sparsmat.pyx":1007
 *             return emptyvec_D
 *         res=SparseVectorD()
 *         res.buf=self             # <<<<<<<<<<<<<<
 *         res.my_len=off2-off1
 *         res.vals_ptr=&self.mat.values[off1]
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __Pyx_GOTREF(__pyx_v_res->buf);
  __Pyx_DECREF(__pyx_v_res->buf);
  __pyx_v_res->buf = ((PyObject *)__pyx_v_self);

  /* "lurrn/sparsmat.pyx":1008
 *         res=SparseVectorD()
 *         res.buf=self
 *         res.my_len=off2-off1             # <<<<<<<<<<<<<<
 *         res.vals_ptr=&self.mat.values[off1]
 *         res.idx_ptr=&self.mat.rightColumns[off1]
 */
  __pyx_v_res->my_len = (__pyx_v_off2 - __pyx_v_off1);

  /* "lurrn/sparsmat.pyx":1009
 *         res.buf=self
 *         res.my_len=off2-off1
 *         res.vals_ptr=&self.mat.values[off1]             # <<<<<<<<<<<<<<
 *         res.idx_ptr=&self.mat.rightColumns[off1]
 *         return res
 */
  __pyx_v_res->vals_ptr = (&(__pyx_v_self->mat->values[__pyx_v_off1]));

  /* "lurrn/sparsmat.pyx":1010
 *         res.my_len=off2-off1
 *         res.vals_ptr=&self.mat.values[off1]
 *         res.idx_ptr=&self.mat.rightColumns[off1]             # <<<<<<<<<<<<<<
 *         return res
 *     def item_iter(self):
 */
  __pyx_v_res->idx_ptr = (&(__pyx_v_self->mat->rightColumns[__pyx_v_off1]));

  /* "lurrn/sparsmat.pyx":1011
 *         res.vals_ptr=&self.mat.values[off1]
 *         res.idx_ptr=&self.mat.rightColumns[off1]
 *         return res             # <<<<<<<<<<<<<<
 *     def item_iter(self):
 *         if self.mat.num_rows>0:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_res));
  __pyx_r = ((PyObject *)__pyx_v_res);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":997
 *     def __len__(self):
 *         return self.mat.num_rows
 *     def __getitem__(self,k):             # <<<<<<<<<<<<<<
 *         cdef int off1, off2
 *         cdef SparseVectorD res
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_res);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1012
 *         res.idx_ptr=&self.mat.rightColumns[off1]
 *         return res
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         if self.mat.num_rows>0:
 *             return CSRMatrixD_item_iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_17item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_17item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("item_iter (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_16item_iter(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_16item_iter(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("item_iter", 0);

  /* "lurrn/sparsmat.pyx":1013
 *         return res
 *     def item_iter(self):
 *         if self.mat.num_rows>0:             # <<<<<<<<<<<<<<
 *             return CSRMatrixD_item_iter(self)
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_self->mat->num_rows > 0) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":1014
 *     def item_iter(self):
 *         if self.mat.num_rows>0:
 *             return CSRMatrixD_item_iter(self)             # <<<<<<<<<<<<<<
 *         else:
 *             return ()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixD_item_iter)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":1016
 *             return CSRMatrixD_item_iter(self)
 *         else:
 *             return ()             # <<<<<<<<<<<<<<
 *     def to_scipy(self):
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] data
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_r = __pyx_empty_tuple;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1012
 *         res.idx_ptr=&self.mat.rightColumns[off1]
 *         return res
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         if self.mat.num_rows>0:
 *             return CSRMatrixD_item_iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.item_iter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1017
 *         else:
 *             return ()
 *     def to_scipy(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] data
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indices
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_19to_scipy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_19to_scipy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_scipy (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_18to_scipy(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_18to_scipy(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self) {
  PyArrayObject *__pyx_v_data = 0;
  PyArrayObject *__pyx_v_indices = 0;
  PyArrayObject *__pyx_v_indptr = 0;
  int __pyx_v_num_rows;
  int __pyx_v_max_offset;
  int __pyx_v_i;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_data;
  __Pyx_Buffer __pyx_pybuffer_data;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indices;
  __Pyx_Buffer __pyx_pybuffer_indices;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indptr;
  __Pyx_Buffer __pyx_pybuffer_indptr;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  coordinate_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyArrayObject *__pyx_t_14 = NULL;
  PyArrayObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_t_19;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_scipy", 0);
  __pyx_pybuffer_data.pybuffer.buf = NULL;
  __pyx_pybuffer_data.refcount = 0;
  __pyx_pybuffernd_data.data = NULL;
  __pyx_pybuffernd_data.rcbuffer = &__pyx_pybuffer_data;
  __pyx_pybuffer_indices.pybuffer.buf = NULL;
  __pyx_pybuffer_indices.refcount = 0;
  __pyx_pybuffernd_indices.data = NULL;
  __pyx_pybuffernd_indices.rcbuffer = &__pyx_pybuffer_indices;
  __pyx_pybuffer_indptr.pybuffer.buf = NULL;
  __pyx_pybuffer_indptr.refcount = 0;
  __pyx_pybuffernd_indptr.data = NULL;
  __pyx_pybuffernd_indptr.rcbuffer = &__pyx_pybuffer_indptr;

  /* "lurrn/sparsmat.pyx":1021
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indices
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indptr
 *         cdef int num_rows=self.mat.num_rows             # <<<<<<<<<<<<<<
 *         cdef int max_offset=self.mat.offsets[num_rows]
 *         cdef int i,j
 */
  __pyx_t_1 = __pyx_v_self->mat->num_rows;
  __pyx_v_num_rows = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":1022
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indptr
 *         cdef int num_rows=self.mat.num_rows
 *         cdef int max_offset=self.mat.offsets[num_rows]             # <<<<<<<<<<<<<<
 *         cdef int i,j
 *         indptr=numpy.zeros(num_rows+1, numpy.int32)
 */
  __pyx_v_max_offset = (__pyx_v_self->mat->offsets[__pyx_v_num_rows]);

  /* "lurrn/sparsmat.pyx":1024
 *         cdef int max_offset=self.mat.offsets[num_rows]
 *         cdef int i,j
 *         indptr=numpy.zeros(num_rows+1, numpy.int32)             # <<<<<<<<<<<<<<
 *         indices=numpy.zeros(max_offset, numpy.int32)
 *         data=numpy.zeros(max_offset, numpy.float64)
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_long((__pyx_v_num_rows + 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_int32); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_7 = 1;
    }
  }
  __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (__pyx_t_5) {
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_3 = 0;
  __pyx_t_6 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer, (PyObject*)__pyx_v_indptr, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
    }
    __pyx_pybuffernd_indptr.diminfo[0].strides = __pyx_pybuffernd_indptr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indptr.diminfo[0].shape = __pyx_pybuffernd_indptr.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_9 = 0;
  __pyx_v_indptr = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":1025
 *         cdef int i,j
 *         indptr=numpy.zeros(num_rows+1, numpy.int32)
 *         indices=numpy.zeros(max_offset, numpy.int32)             # <<<<<<<<<<<<<<
 *         data=numpy.zeros(max_offset, numpy.float64)
 *         for i from 0<=i<=num_rows:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_max_offset); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int32); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
      __pyx_t_7 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_6) {
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_7, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_7, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_4 = 0;
  __pyx_t_3 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indices.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indices.rcbuffer->pybuffer, (PyObject*)__pyx_v_indices, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
      }
    }
    __pyx_pybuffernd_indices.diminfo[0].strides = __pyx_pybuffernd_indices.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indices.diminfo[0].shape = __pyx_pybuffernd_indices.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_14 = 0;
  __pyx_v_indices = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":1026
 *         indptr=numpy.zeros(num_rows+1, numpy.int32)
 *         indices=numpy.zeros(max_offset, numpy.int32)
 *         data=numpy.zeros(max_offset, numpy.float64)             # <<<<<<<<<<<<<<
 *         for i from 0<=i<=num_rows:
 *             indptr[i]=self.mat.offsets[i]
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_max_offset); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float64); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_7 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_3) {
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_8 = 0;
  __pyx_t_4 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_15 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data.rcbuffer->pybuffer, (PyObject*)__pyx_v_data, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
    }
    __pyx_pybuffernd_data.diminfo[0].strides = __pyx_pybuffernd_data.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_data.diminfo[0].shape = __pyx_pybuffernd_data.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_15 = 0;
  __pyx_v_data = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":1027
 *         indices=numpy.zeros(max_offset, numpy.int32)
 *         data=numpy.zeros(max_offset, numpy.float64)
 *         for i from 0<=i<=num_rows:             # <<<<<<<<<<<<<<
 *             indptr[i]=self.mat.offsets[i]
 *         for i from 0<=i<max_offset:
 */
  __pyx_t_10 = __pyx_v_num_rows;
  for (__pyx_v_i = 0; __pyx_v_i <= __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":1028
 *         data=numpy.zeros(max_offset, numpy.float64)
 *         for i from 0<=i<=num_rows:
 *             indptr[i]=self.mat.offsets[i]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<max_offset:
 *             indices[i]=self.mat.rightColumns[i]
 */
    __pyx_t_16 = __pyx_v_i;
    __pyx_t_17 = -1;
    if (__pyx_t_16 < 0) {
      __pyx_t_16 += __pyx_pybuffernd_indptr.diminfo[0].shape;
      if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 0;
    } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_indptr.diminfo[0].shape)) __pyx_t_17 = 0;
    if (unlikely(__pyx_t_17 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_17);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_indptr.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_indptr.diminfo[0].strides) = (__pyx_v_self->mat->offsets[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":1029
 *         for i from 0<=i<=num_rows:
 *             indptr[i]=self.mat.offsets[i]
 *         for i from 0<=i<max_offset:             # <<<<<<<<<<<<<<
 *             indices[i]=self.mat.rightColumns[i]
 *         for i from 0<=i<max_offset:
 */
  __pyx_t_10 = __pyx_v_max_offset;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":1030
 *             indptr[i]=self.mat.offsets[i]
 *         for i from 0<=i<max_offset:
 *             indices[i]=self.mat.rightColumns[i]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<max_offset:
 *             data[i]=self.mat.values[i]
 */
    __pyx_t_17 = __pyx_v_i;
    __pyx_t_18 = -1;
    if (__pyx_t_17 < 0) {
      __pyx_t_17 += __pyx_pybuffernd_indices.diminfo[0].shape;
      if (unlikely(__pyx_t_17 < 0)) __pyx_t_18 = 0;
    } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_indices.diminfo[0].shape)) __pyx_t_18 = 0;
    if (unlikely(__pyx_t_18 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_18);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_indices.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_indices.diminfo[0].strides) = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":1031
 *         for i from 0<=i<max_offset:
 *             indices[i]=self.mat.rightColumns[i]
 *         for i from 0<=i<max_offset:             # <<<<<<<<<<<<<<
 *             data[i]=self.mat.values[i]
 *         return (data,indices,indptr)
 */
  __pyx_t_10 = __pyx_v_max_offset;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":1032
 *             indices[i]=self.mat.rightColumns[i]
 *         for i from 0<=i<max_offset:
 *             data[i]=self.mat.values[i]             # <<<<<<<<<<<<<<
 *         return (data,indices,indptr)
 *     cpdef int get_maxcol(self):
 */
    __pyx_t_18 = __pyx_v_i;
    __pyx_t_19 = -1;
    if (__pyx_t_18 < 0) {
      __pyx_t_18 += __pyx_pybuffernd_data.diminfo[0].shape;
      if (unlikely(__pyx_t_18 < 0)) __pyx_t_19 = 0;
    } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_data.diminfo[0].shape)) __pyx_t_19 = 0;
    if (unlikely(__pyx_t_19 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_19);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_data.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_data.diminfo[0].strides) = (__pyx_v_self->mat->values[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":1033
 *         for i from 0<=i<max_offset:
 *             data[i]=self.mat.values[i]
 *         return (data,indices,indptr)             # <<<<<<<<<<<<<<
 *     cpdef int get_maxcol(self):
 *         cdef int result=0
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_data));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_data));
  __Pyx_INCREF(((PyObject *)__pyx_v_indices));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_indices));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_indices));
  __Pyx_INCREF(((PyObject *)__pyx_v_indptr));
  PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_indptr));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_indptr));
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1017
 *         else:
 *             return ()
 *     def to_scipy(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] data
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indices
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.to_scipy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_data);
  __Pyx_XDECREF((PyObject *)__pyx_v_indices);
  __Pyx_XDECREF((PyObject *)__pyx_v_indptr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1034
 *             data[i]=self.mat.values[i]
 *         return (data,indices,indptr)
 *     cpdef int get_maxcol(self):             # <<<<<<<<<<<<<<
 *         cdef int result=0
 *         cdef int col_max
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_21get_maxcol(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_10CSRMatrixD_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, int __pyx_skip_dispatch) {
  int __pyx_v_result;
  int __pyx_v_col_max;
  coordinate_t __pyx_v_i;
  int __pyx_v_off1;
  int __pyx_v_off2;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  coordinate_t __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_maxcol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_21get_maxcol)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_5;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1035
 *         return (data,indices,indptr)
 *     cpdef int get_maxcol(self):
 *         cdef int result=0             # <<<<<<<<<<<<<<
 *         cdef int col_max
 *         cdef coordinate_t i
 */
  __pyx_v_result = 0;

  /* "lurrn/sparsmat.pyx":1039
 *         cdef coordinate_t i
 *         cdef int off1, off2
 *         if self.cache_maxcol>=0:             # <<<<<<<<<<<<<<
 *             return self.cache_maxcol
 *         for i from 0<=i<self.mat.num_rows:
 */
  __pyx_t_6 = ((__pyx_v_self->cache_maxcol >= 0) != 0);
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":1040
 *         cdef int off1, off2
 *         if self.cache_maxcol>=0:
 *             return self.cache_maxcol             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.mat.num_rows:
 *            off1=self.mat.offsets[i]
 */
    __pyx_r = __pyx_v_self->cache_maxcol;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1041
 *         if self.cache_maxcol>=0:
 *             return self.cache_maxcol
 *         for i from 0<=i<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *            off1=self.mat.offsets[i]
 *            off2=self.mat.offsets[i+1]
 */
  __pyx_t_7 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":1042
 *             return self.cache_maxcol
 *         for i from 0<=i<self.mat.num_rows:
 *            off1=self.mat.offsets[i]             # <<<<<<<<<<<<<<
 *            off2=self.mat.offsets[i+1]
 *            if off2>off1:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":1043
 *         for i from 0<=i<self.mat.num_rows:
 *            off1=self.mat.offsets[i]
 *            off2=self.mat.offsets[i+1]             # <<<<<<<<<<<<<<
 *            if off2>off1:
 *               col_max=self.mat.rightColumns[off2-1]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_i + 1)]);

    /* "lurrn/sparsmat.pyx":1044
 *            off1=self.mat.offsets[i]
 *            off2=self.mat.offsets[i+1]
 *            if off2>off1:             # <<<<<<<<<<<<<<
 *               col_max=self.mat.rightColumns[off2-1]
 *               if result<col_max:
 */
    __pyx_t_6 = ((__pyx_v_off2 > __pyx_v_off1) != 0);
    if (__pyx_t_6) {

      /* "lurrn/sparsmat.pyx":1045
 *            off2=self.mat.offsets[i+1]
 *            if off2>off1:
 *               col_max=self.mat.rightColumns[off2-1]             # <<<<<<<<<<<<<<
 *               if result<col_max:
 *                  result=col_max
 */
      __pyx_v_col_max = (__pyx_v_self->mat->rightColumns[(__pyx_v_off2 - 1)]);

      /* "lurrn/sparsmat.pyx":1046
 *            if off2>off1:
 *               col_max=self.mat.rightColumns[off2-1]
 *               if result<col_max:             # <<<<<<<<<<<<<<
 *                  result=col_max
 *         self.cache_maxcol=result
 */
      __pyx_t_6 = ((__pyx_v_result < __pyx_v_col_max) != 0);
      if (__pyx_t_6) {

        /* "lurrn/sparsmat.pyx":1047
 *               col_max=self.mat.rightColumns[off2-1]
 *               if result<col_max:
 *                  result=col_max             # <<<<<<<<<<<<<<
 *         self.cache_maxcol=result
 *         return result
 */
        __pyx_v_result = __pyx_v_col_max;
        goto __pyx_L7;
      }
      __pyx_L7:;
      goto __pyx_L6;
    }
    __pyx_L6:;
  }

  /* "lurrn/sparsmat.pyx":1048
 *               if result<col_max:
 *                  result=col_max
 *         self.cache_maxcol=result             # <<<<<<<<<<<<<<
 *         return result
 *     cpdef CSRMatrixD transform_mi(self):
 */
  __pyx_v_self->cache_maxcol = __pyx_v_result;

  /* "lurrn/sparsmat.pyx":1049
 *                  result=col_max
 *         self.cache_maxcol=result
 *         return result             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixD transform_mi(self):
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1034
 *             data[i]=self.mat.values[i]
 *         return (data,indices,indptr)
 *     cpdef int get_maxcol(self):             # <<<<<<<<<<<<<<
 *         cdef int result=0
 *         cdef int col_max
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_WriteUnraisable("lurrn.sparsmat.CSRMatrixD.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_21get_maxcol(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_21get_maxcol(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_maxcol (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_20get_maxcol(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_20get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_get_maxcol(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1050
 *         self.cache_maxcol=result
 *         return result
 *     cpdef CSRMatrixD transform_mi(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_r
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_23transform_mi(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_transform_mi(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_marginals_l = 0;
  PyArrayObject *__pyx_v_marginals_r = 0;
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp = 0;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_i;
  int __pyx_v_off1;
  int __pyx_v_off2;
  double __pyx_v_v;
  double __pyx_v_log_v;
  double __pyx_v_log_N;
  double __pyx_v_log1;
  double __pyx_v_log2;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_l;
  __Pyx_Buffer __pyx_pybuffer_marginals_l;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_r;
  __Pyx_Buffer __pyx_pybuffer_marginals_r;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyArrayObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyArrayObject *__pyx_t_11 = NULL;
  double __pyx_t_12;
  coordinate_t __pyx_t_13;
  coordinate_t __pyx_t_14;
  coordinate_t __pyx_t_15;
  int __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  Py_ssize_t __pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_mi", 0);
  __pyx_pybuffer_marginals_l.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_l.refcount = 0;
  __pyx_pybuffernd_marginals_l.data = NULL;
  __pyx_pybuffernd_marginals_l.rcbuffer = &__pyx_pybuffer_marginals_l;
  __pyx_pybuffer_marginals_r.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_r.refcount = 0;
  __pyx_pybuffernd_marginals_r.data = NULL;
  __pyx_pybuffernd_marginals_r.rcbuffer = &__pyx_pybuffer_marginals_r;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transform_mi); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_23transform_mi)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1053
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_r
 *         cdef VecD2 tmp=VecD2()             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, i
 *         cdef int off1, off2
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1057
 *         cdef int off1, off2
 *         cdef double v, log_v, log_N, log1, log2
 *         if self.mat.num_rows<100000:             # <<<<<<<<<<<<<<
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 */
  __pyx_t_5 = ((__pyx_v_self->mat->num_rows < 100000) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":1058
 *         cdef double v, log_v, log_N, log1, log2
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         else:
 *             tmp.vec.reserve(100000)
 */
    __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":1060
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 *             tmp.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()
 */
    __pyx_v_tmp->vec.reserve(100000);
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":1061
 *         else:
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()             # <<<<<<<<<<<<<<
 *         marginals_r=self.right_marginals()
 *         log_N=log(marginals_l.sum())
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_left_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_l, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_marginals_l.diminfo[0].strides = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_l.diminfo[0].shape = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = 0;
  __pyx_v_marginals_l = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1062
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()             # <<<<<<<<<<<<<<
 *         log_N=log(marginals_l.sum())
 *         for k from 0<=k<self.mat.num_rows:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_right_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_r, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
      }
    }
    __pyx_pybuffernd_marginals_r.diminfo[0].strides = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_r.diminfo[0].shape = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_11 = 0;
  __pyx_v_marginals_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1063
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()
 *         log_N=log(marginals_l.sum())             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.num_rows:
 *             log1=log(marginals_l[k])-log_N
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_marginals_l), __pyx_n_s_sum); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_log_N = log(__pyx_t_12);

  /* "lurrn/sparsmat.pyx":1064
 *         marginals_r=self.right_marginals()
 *         log_N=log(marginals_l.sum())
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             log1=log(marginals_l[k])-log_N
 *             off1=self.mat.offsets[k]
 */
  __pyx_t_13 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_13; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":1065
 *         log_N=log(marginals_l.sum())
 *         for k from 0<=k<self.mat.num_rows:
 *             log1=log(marginals_l[k])-log_N             # <<<<<<<<<<<<<<
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 */
    __pyx_t_14 = __pyx_v_k;
    __pyx_t_7 = -1;
    if (unlikely(__pyx_t_14 >= (size_t)__pyx_pybuffernd_marginals_l.diminfo[0].shape)) __pyx_t_7 = 0;
    if (unlikely(__pyx_t_7 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_7);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_log1 = (log((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_marginals_l.diminfo[0].strides))) - __pyx_v_log_N);

    /* "lurrn/sparsmat.pyx":1066
 *         for k from 0<=k<self.mat.num_rows:
 *             log1=log(marginals_l[k])-log_N
 *             off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":1067
 *             log1=log(marginals_l[k])-log_N
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":1068
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                v=self.mat.values[i]
 *                if v>0:
 */
    __pyx_t_7 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":1069
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]             # <<<<<<<<<<<<<<
 *                if v>0:
 *                    log2=log(marginals_r[self.mat.rightColumns[i]])
 */
      __pyx_v_v = (__pyx_v_self->mat->values[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":1070
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 *                if v>0:             # <<<<<<<<<<<<<<
 *                    log2=log(marginals_r[self.mat.rightColumns[i]])
 *                    log_v=log(v)-log2-log1
 */
      __pyx_t_5 = ((__pyx_v_v > 0.0) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":1071
 *                v=self.mat.values[i]
 *                if v>0:
 *                    log2=log(marginals_r[self.mat.rightColumns[i]])             # <<<<<<<<<<<<<<
 *                    log_v=log(v)-log2-log1
 *                    if log_v>0:
 */
        __pyx_t_15 = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);
        __pyx_t_16 = -1;
        if (unlikely(__pyx_t_15 >= (size_t)__pyx_pybuffernd_marginals_r.diminfo[0].shape)) __pyx_t_16 = 0;
        if (unlikely(__pyx_t_16 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_16);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_log2 = log((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_marginals_r.diminfo[0].strides)));

        /* "lurrn/sparsmat.pyx":1072
 *                if v>0:
 *                    log2=log(marginals_r[self.mat.rightColumns[i]])
 *                    log_v=log(v)-log2-log1             # <<<<<<<<<<<<<<
 *                    if log_v>0:
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 */
        __pyx_v_log_v = ((log(__pyx_v_v) - __pyx_v_log2) - __pyx_v_log1);

        /* "lurrn/sparsmat.pyx":1073
 *                    log2=log(marginals_r[self.mat.rightColumns[i]])
 *                    log_v=log(v)-log2-log1
 *                    if log_v>0:             # <<<<<<<<<<<<<<
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()
 */
        __pyx_t_5 = ((__pyx_v_log_v > 0.0) != 0);
        if (__pyx_t_5) {

          /* "lurrn/sparsmat.pyx":1074
 *                    log_v=log(v)-log2-log1
 *                    if log_v>0:
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)             # <<<<<<<<<<<<<<
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_mi_discount(self):
 */
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->mat->rightColumns[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_17 = PyFloat_FromDouble(__pyx_v_log_v); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_18 = NULL;
          __pyx_t_19 = 0;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_18)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_18);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
              __pyx_t_19 = 1;
            }
          }
          __pyx_t_20 = PyTuple_New(3+__pyx_t_19); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_20);
          if (__pyx_t_18) {
            PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); __pyx_t_18 = NULL;
          }
          PyTuple_SET_ITEM(__pyx_t_20, 0+__pyx_t_19, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_20, 1+__pyx_t_19, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_20, 2+__pyx_t_19, __pyx_t_17);
          __Pyx_GIVEREF(__pyx_t_17);
          __pyx_t_3 = 0;
          __pyx_t_4 = 0;
          __pyx_t_17 = 0;
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_20, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          goto __pyx_L9;
        }
        __pyx_L9:;
        goto __pyx_L8;
      }
      __pyx_L8:;
    }
  }

  /* "lurrn/sparsmat.pyx":1075
 *                    if log_v>0:
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixD transform_mi_discount(self):
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp->__pyx_vtab)->to_csr(__pyx_v_tmp, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1050
 *         self.cache_maxcol=result
 *         return result
 *     cpdef CSRMatrixD transform_mi(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_r
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_20);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.transform_mi", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_l);
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_r);
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_23transform_mi(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_23transform_mi(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("transform_mi (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_22transform_mi(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_22transform_mi(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_mi", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_transform_mi(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.transform_mi", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1076
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_mi_discount(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_r
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_25transform_mi_discount(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_transform_mi_discount(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_marginals_l = 0;
  PyArrayObject *__pyx_v_marginals_r = 0;
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp = 0;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_i;
  int __pyx_v_off1;
  int __pyx_v_off2;
  double __pyx_v_marg_l;
  double __pyx_v_marg_r;
  double __pyx_v_log_corr1;
  double __pyx_v_log_corr2;
  double __pyx_v_v;
  double __pyx_v_log_v;
  double __pyx_v_log_N;
  double __pyx_v_log1;
  double __pyx_v_log2;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_l;
  __Pyx_Buffer __pyx_pybuffer_marginals_l;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_r;
  __Pyx_Buffer __pyx_pybuffer_marginals_r;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyArrayObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyArrayObject *__pyx_t_11 = NULL;
  double __pyx_t_12;
  coordinate_t __pyx_t_13;
  coordinate_t __pyx_t_14;
  coordinate_t __pyx_t_15;
  int __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  Py_ssize_t __pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_mi_discount", 0);
  __pyx_pybuffer_marginals_l.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_l.refcount = 0;
  __pyx_pybuffernd_marginals_l.data = NULL;
  __pyx_pybuffernd_marginals_l.rcbuffer = &__pyx_pybuffer_marginals_l;
  __pyx_pybuffer_marginals_r.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_r.refcount = 0;
  __pyx_pybuffernd_marginals_r.data = NULL;
  __pyx_pybuffernd_marginals_r.rcbuffer = &__pyx_pybuffer_marginals_r;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transform_mi_discount); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_25transform_mi_discount)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1079
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_r
 *         cdef VecD2 tmp=VecD2()             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, i
 *         cdef int off1, off2
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1084
 *         cdef double marg_l, marg_r, log_corr1, log_corr2
 *         cdef double v, log_v, log_N, log1, log2
 *         if self.mat.num_rows<100000:             # <<<<<<<<<<<<<<
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 */
  __pyx_t_5 = ((__pyx_v_self->mat->num_rows < 100000) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":1085
 *         cdef double v, log_v, log_N, log1, log2
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         else:
 *             tmp.vec.reserve(100000)
 */
    __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":1087
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 *             tmp.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()
 */
    __pyx_v_tmp->vec.reserve(100000);
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":1088
 *         else:
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()             # <<<<<<<<<<<<<<
 *         marginals_r=self.right_marginals()
 *         log_N=log(marginals_l.sum())
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_left_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_l, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_marginals_l.diminfo[0].strides = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_l.diminfo[0].shape = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = 0;
  __pyx_v_marginals_l = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1089
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()             # <<<<<<<<<<<<<<
 *         log_N=log(marginals_l.sum())
 *         for k from 0<=k<self.mat.num_rows:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_right_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_r, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
      }
    }
    __pyx_pybuffernd_marginals_r.diminfo[0].strides = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_r.diminfo[0].shape = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_11 = 0;
  __pyx_v_marginals_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1090
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()
 *         log_N=log(marginals_l.sum())             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.num_rows:
 *             marg_l=marginals_l[k]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_marginals_l), __pyx_n_s_sum); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1090; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1090; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1090; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1090; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_log_N = log(__pyx_t_12);

  /* "lurrn/sparsmat.pyx":1091
 *         marginals_r=self.right_marginals()
 *         log_N=log(marginals_l.sum())
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             marg_l=marginals_l[k]
 *             log1=log(marg_l)-log_N
 */
  __pyx_t_13 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_13; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":1092
 *         log_N=log(marginals_l.sum())
 *         for k from 0<=k<self.mat.num_rows:
 *             marg_l=marginals_l[k]             # <<<<<<<<<<<<<<
 *             log1=log(marg_l)-log_N
 *             off1=self.mat.offsets[k]
 */
    __pyx_t_14 = __pyx_v_k;
    __pyx_t_7 = -1;
    if (unlikely(__pyx_t_14 >= (size_t)__pyx_pybuffernd_marginals_l.diminfo[0].shape)) __pyx_t_7 = 0;
    if (unlikely(__pyx_t_7 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_7);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_marg_l = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_marginals_l.diminfo[0].strides));

    /* "lurrn/sparsmat.pyx":1093
 *         for k from 0<=k<self.mat.num_rows:
 *             marg_l=marginals_l[k]
 *             log1=log(marg_l)-log_N             # <<<<<<<<<<<<<<
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 */
    __pyx_v_log1 = (log(__pyx_v_marg_l) - __pyx_v_log_N);

    /* "lurrn/sparsmat.pyx":1094
 *             marg_l=marginals_l[k]
 *             log1=log(marg_l)-log_N
 *             off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":1095
 *             log1=log(marg_l)-log_N
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":1096
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                v=self.mat.values[i]
 *                if v>0:
 */
    __pyx_t_7 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":1097
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]             # <<<<<<<<<<<<<<
 *                if v>0:
 *                    marg_r=marginals_r[self.mat.rightColumns[i]]
 */
      __pyx_v_v = (__pyx_v_self->mat->values[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":1098
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 *                if v>0:             # <<<<<<<<<<<<<<
 *                    marg_r=marginals_r[self.mat.rightColumns[i]]
 *                    log2=log(marg_r)
 */
      __pyx_t_5 = ((__pyx_v_v > 0.0) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":1099
 *                v=self.mat.values[i]
 *                if v>0:
 *                    marg_r=marginals_r[self.mat.rightColumns[i]]             # <<<<<<<<<<<<<<
 *                    log2=log(marg_r)
 *                    log_corr1=log1p(-1.0/(v+1.0))
 */
        __pyx_t_15 = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);
        __pyx_t_16 = -1;
        if (unlikely(__pyx_t_15 >= (size_t)__pyx_pybuffernd_marginals_r.diminfo[0].shape)) __pyx_t_16 = 0;
        if (unlikely(__pyx_t_16 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_16);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_marg_r = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_marginals_r.diminfo[0].strides));

        /* "lurrn/sparsmat.pyx":1100
 *                if v>0:
 *                    marg_r=marginals_r[self.mat.rightColumns[i]]
 *                    log2=log(marg_r)             # <<<<<<<<<<<<<<
 *                    log_corr1=log1p(-1.0/(v+1.0))
 *                    if marg_l<marg_r:
 */
        __pyx_v_log2 = log(__pyx_v_marg_r);

        /* "lurrn/sparsmat.pyx":1101
 *                    marg_r=marginals_r[self.mat.rightColumns[i]]
 *                    log2=log(marg_r)
 *                    log_corr1=log1p(-1.0/(v+1.0))             # <<<<<<<<<<<<<<
 *                    if marg_l<marg_r:
 *                        log_corr2=log1p(-1.0/(marg_l+1.0))
 */
        __pyx_t_12 = (__pyx_v_v + 1.0);
        if (unlikely(__pyx_t_12 == 0)) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
          #endif
          PyErr_SetString(PyExc_ZeroDivisionError, "float division");
          #ifdef WITH_THREAD
          PyGILState_Release(__pyx_gilstate_save);
          #endif
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_log_corr1 = log1p((-1.0 / __pyx_t_12));

        /* "lurrn/sparsmat.pyx":1102
 *                    log2=log(marg_r)
 *                    log_corr1=log1p(-1.0/(v+1.0))
 *                    if marg_l<marg_r:             # <<<<<<<<<<<<<<
 *                        log_corr2=log1p(-1.0/(marg_l+1.0))
 *                    else:
 */
        __pyx_t_5 = ((__pyx_v_marg_l < __pyx_v_marg_r) != 0);
        if (__pyx_t_5) {

          /* "lurrn/sparsmat.pyx":1103
 *                    log_corr1=log1p(-1.0/(v+1.0))
 *                    if marg_l<marg_r:
 *                        log_corr2=log1p(-1.0/(marg_l+1.0))             # <<<<<<<<<<<<<<
 *                    else:
 *                        log_corr2=log1p(-1.0/(marg_r+1.0))
 */
          __pyx_t_12 = (__pyx_v_marg_l + 1.0);
          if (unlikely(__pyx_t_12 == 0)) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
            #endif
            PyErr_SetString(PyExc_ZeroDivisionError, "float division");
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_log_corr2 = log1p((-1.0 / __pyx_t_12));
          goto __pyx_L9;
        }
        /*else*/ {

          /* "lurrn/sparsmat.pyx":1105
 *                        log_corr2=log1p(-1.0/(marg_l+1.0))
 *                    else:
 *                        log_corr2=log1p(-1.0/(marg_r+1.0))             # <<<<<<<<<<<<<<
 *                    log_v=log(v)-log2-log1+log_corr1+log_corr2
 *                    if log_v>0:
 */
          __pyx_t_12 = (__pyx_v_marg_r + 1.0);
          if (unlikely(__pyx_t_12 == 0)) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
            #endif
            PyErr_SetString(PyExc_ZeroDivisionError, "float division");
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_log_corr2 = log1p((-1.0 / __pyx_t_12));
        }
        __pyx_L9:;

        /* "lurrn/sparsmat.pyx":1106
 *                    else:
 *                        log_corr2=log1p(-1.0/(marg_r+1.0))
 *                    log_v=log(v)-log2-log1+log_corr1+log_corr2             # <<<<<<<<<<<<<<
 *                    if log_v>0:
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 */
        __pyx_v_log_v = ((((log(__pyx_v_v) - __pyx_v_log2) - __pyx_v_log1) + __pyx_v_log_corr1) + __pyx_v_log_corr2);

        /* "lurrn/sparsmat.pyx":1107
 *                        log_corr2=log1p(-1.0/(marg_r+1.0))
 *                    log_v=log(v)-log2-log1+log_corr1+log_corr2
 *                    if log_v>0:             # <<<<<<<<<<<<<<
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()
 */
        __pyx_t_5 = ((__pyx_v_log_v > 0.0) != 0);
        if (__pyx_t_5) {

          /* "lurrn/sparsmat.pyx":1108
 *                    log_v=log(v)-log2-log1+log_corr1+log_corr2
 *                    if log_v>0:
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)             # <<<<<<<<<<<<<<
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_ll(self):
 */
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->mat->rightColumns[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_17 = PyFloat_FromDouble(__pyx_v_log_v); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_18 = NULL;
          __pyx_t_19 = 0;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_18)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_18);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
              __pyx_t_19 = 1;
            }
          }
          __pyx_t_20 = PyTuple_New(3+__pyx_t_19); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_20);
          if (__pyx_t_18) {
            PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); __pyx_t_18 = NULL;
          }
          PyTuple_SET_ITEM(__pyx_t_20, 0+__pyx_t_19, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_20, 1+__pyx_t_19, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_20, 2+__pyx_t_19, __pyx_t_17);
          __Pyx_GIVEREF(__pyx_t_17);
          __pyx_t_3 = 0;
          __pyx_t_4 = 0;
          __pyx_t_17 = 0;
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_20, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          goto __pyx_L10;
        }
        __pyx_L10:;
        goto __pyx_L8;
      }
      __pyx_L8:;
    }
  }

  /* "lurrn/sparsmat.pyx":1109
 *                    if log_v>0:
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixD transform_ll(self):
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp->__pyx_vtab)->to_csr(__pyx_v_tmp, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1076
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_mi_discount(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_r
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_20);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.transform_mi_discount", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_l);
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_r);
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_25transform_mi_discount(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_25transform_mi_discount(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("transform_mi_discount (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_24transform_mi_discount(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_24transform_mi_discount(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_mi_discount", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_transform_mi_discount(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.transform_mi_discount", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1110
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_ll(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_r
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_27transform_ll(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_transform_ll(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_marginals_l = 0;
  PyArrayObject *__pyx_v_marginals_r = 0;
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp = 0;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_i;
  int __pyx_v_off1;
  int __pyx_v_off2;
  double __pyx_v_c;
  double __pyx_v_c1;
  double __pyx_v_c2;
  double __pyx_v_p;
  double __pyx_v_p1;
  double __pyx_v_pn1;
  double __pyx_v_ll;
  double __pyx_v_c12;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_l;
  __Pyx_Buffer __pyx_pybuffer_marginals_l;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_r;
  __Pyx_Buffer __pyx_pybuffer_marginals_r;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyArrayObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyArrayObject *__pyx_t_11 = NULL;
  double __pyx_t_12;
  coordinate_t __pyx_t_13;
  coordinate_t __pyx_t_14;
  coordinate_t __pyx_t_15;
  int __pyx_t_16;
  double __pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  Py_ssize_t __pyx_t_20;
  PyObject *__pyx_t_21 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_ll", 0);
  __pyx_pybuffer_marginals_l.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_l.refcount = 0;
  __pyx_pybuffernd_marginals_l.data = NULL;
  __pyx_pybuffernd_marginals_l.rcbuffer = &__pyx_pybuffer_marginals_l;
  __pyx_pybuffer_marginals_r.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_r.refcount = 0;
  __pyx_pybuffernd_marginals_r.data = NULL;
  __pyx_pybuffernd_marginals_r.rcbuffer = &__pyx_pybuffer_marginals_r;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transform_ll); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_27transform_ll)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1113
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_r
 *         cdef VecD2 tmp=VecD2()             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, i
 *         cdef int off1, off2
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1118
 *         cdef double marg_l, marg_r, c, c1, c2
 *         cdef double p, p1, pn1, ll
 *         if self.mat.num_rows<100000:             # <<<<<<<<<<<<<<
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 */
  __pyx_t_5 = ((__pyx_v_self->mat->num_rows < 100000) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":1119
 *         cdef double p, p1, pn1, ll
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         else:
 *             tmp.vec.reserve(100000)
 */
    __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":1121
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 *             tmp.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()
 */
    __pyx_v_tmp->vec.reserve(100000);
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":1122
 *         else:
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()             # <<<<<<<<<<<<<<
 *         marginals_r=self.right_marginals()
 *         c=marginals_l.sum()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_left_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_l, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_marginals_l.diminfo[0].strides = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_l.diminfo[0].shape = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = 0;
  __pyx_v_marginals_l = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1123
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()             # <<<<<<<<<<<<<<
 *         c=marginals_l.sum()
 *         for k from 0<=k<self.mat.num_rows:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_right_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_r, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
      }
    }
    __pyx_pybuffernd_marginals_r.diminfo[0].strides = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_r.diminfo[0].shape = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_11 = 0;
  __pyx_v_marginals_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1124
 *         marginals_l=self.left_marginals()
 *         marginals_r=self.right_marginals()
 *         c=marginals_l.sum()             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.num_rows:
 *             c1=marginals_l[k]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_marginals_l), __pyx_n_s_sum); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_c = __pyx_t_12;

  /* "lurrn/sparsmat.pyx":1125
 *         marginals_r=self.right_marginals()
 *         c=marginals_l.sum()
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             c1=marginals_l[k]
 *             off1=self.mat.offsets[k]
 */
  __pyx_t_13 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_13; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":1126
 *         c=marginals_l.sum()
 *         for k from 0<=k<self.mat.num_rows:
 *             c1=marginals_l[k]             # <<<<<<<<<<<<<<
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 */
    __pyx_t_14 = __pyx_v_k;
    __pyx_t_7 = -1;
    if (unlikely(__pyx_t_14 >= (size_t)__pyx_pybuffernd_marginals_l.diminfo[0].shape)) __pyx_t_7 = 0;
    if (unlikely(__pyx_t_7 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_7);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_c1 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_marginals_l.diminfo[0].strides));

    /* "lurrn/sparsmat.pyx":1127
 *         for k from 0<=k<self.mat.num_rows:
 *             c1=marginals_l[k]
 *             off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":1128
 *             c1=marginals_l[k]
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                c12=self.mat.values[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":1129
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                c12=self.mat.values[i]
 *                if c12>0:
 */
    __pyx_t_7 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":1130
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                c12=self.mat.values[i]             # <<<<<<<<<<<<<<
 *                if c12>0:
 *                    c2=marginals_r[self.mat.rightColumns[i]]
 */
      __pyx_v_c12 = (__pyx_v_self->mat->values[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":1131
 *             for i from off1<=i<off2:
 *                c12=self.mat.values[i]
 *                if c12>0:             # <<<<<<<<<<<<<<
 *                    c2=marginals_r[self.mat.rightColumns[i]]
 *                    p=c2/c
 */
      __pyx_t_5 = ((__pyx_v_c12 > 0.0) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":1132
 *                c12=self.mat.values[i]
 *                if c12>0:
 *                    c2=marginals_r[self.mat.rightColumns[i]]             # <<<<<<<<<<<<<<
 *                    p=c2/c
 *                    p1=c12/c1
 */
        __pyx_t_15 = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);
        __pyx_t_16 = -1;
        if (unlikely(__pyx_t_15 >= (size_t)__pyx_pybuffernd_marginals_r.diminfo[0].shape)) __pyx_t_16 = 0;
        if (unlikely(__pyx_t_16 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_16);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_c2 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_marginals_r.diminfo[0].strides));

        /* "lurrn/sparsmat.pyx":1133
 *                if c12>0:
 *                    c2=marginals_r[self.mat.rightColumns[i]]
 *                    p=c2/c             # <<<<<<<<<<<<<<
 *                    p1=c12/c1
 *                    if p1>p:
 */
        if (unlikely(__pyx_v_c == 0)) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
          #endif
          PyErr_SetString(PyExc_ZeroDivisionError, "float division");
          #ifdef WITH_THREAD
          PyGILState_Release(__pyx_gilstate_save);
          #endif
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_p = (__pyx_v_c2 / __pyx_v_c);

        /* "lurrn/sparsmat.pyx":1134
 *                    c2=marginals_r[self.mat.rightColumns[i]]
 *                    p=c2/c
 *                    p1=c12/c1             # <<<<<<<<<<<<<<
 *                    if p1>p:
 *                        pn1=(c2-c12)/(c-c1)
 */
        if (unlikely(__pyx_v_c1 == 0)) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
          #endif
          PyErr_SetString(PyExc_ZeroDivisionError, "float division");
          #ifdef WITH_THREAD
          PyGILState_Release(__pyx_gilstate_save);
          #endif
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_p1 = (__pyx_v_c12 / __pyx_v_c1);

        /* "lurrn/sparsmat.pyx":1135
 *                    p=c2/c
 *                    p1=c12/c1
 *                    if p1>p:             # <<<<<<<<<<<<<<
 *                        pn1=(c2-c12)/(c-c1)
 *                        ll=(-logB(c1,p,c12)-logB(c-c1,p,c2-c12)
 */
        __pyx_t_5 = ((__pyx_v_p1 > __pyx_v_p) != 0);
        if (__pyx_t_5) {

          /* "lurrn/sparsmat.pyx":1136
 *                    p1=c12/c1
 *                    if p1>p:
 *                        pn1=(c2-c12)/(c-c1)             # <<<<<<<<<<<<<<
 *                        ll=(-logB(c1,p,c12)-logB(c-c1,p,c2-c12)
 *                            +logB(c1,p1,c12)+logB(c-c1,pn1,c2-c12))
 */
          __pyx_t_12 = (__pyx_v_c2 - __pyx_v_c12);
          __pyx_t_17 = (__pyx_v_c - __pyx_v_c1);
          if (unlikely(__pyx_t_17 == 0)) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
            #endif
            PyErr_SetString(PyExc_ZeroDivisionError, "float division");
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_v_pn1 = (__pyx_t_12 / __pyx_t_17);

          /* "lurrn/sparsmat.pyx":1138
 *                        pn1=(c2-c12)/(c-c1)
 *                        ll=(-logB(c1,p,c12)-logB(c-c1,p,c2-c12)
 *                            +logB(c1,p1,c12)+logB(c-c1,pn1,c2-c12))             # <<<<<<<<<<<<<<
 *                        tmp.add_count(k,self.mat.rightColumns[i],ll)
 *         return tmp.to_csr()
 */
          __pyx_v_ll = ((((-__pyx_f_5lurrn_8sparsmat_logB(__pyx_v_c1, __pyx_v_p, __pyx_v_c12)) - __pyx_f_5lurrn_8sparsmat_logB((__pyx_v_c - __pyx_v_c1), __pyx_v_p, (__pyx_v_c2 - __pyx_v_c12))) + __pyx_f_5lurrn_8sparsmat_logB(__pyx_v_c1, __pyx_v_p1, __pyx_v_c12)) + __pyx_f_5lurrn_8sparsmat_logB((__pyx_v_c - __pyx_v_c1), __pyx_v_pn1, (__pyx_v_c2 - __pyx_v_c12)));

          /* "lurrn/sparsmat.pyx":1139
 *                        ll=(-logB(c1,p,c12)-logB(c-c1,p,c2-c12)
 *                            +logB(c1,p1,c12)+logB(c-c1,pn1,c2-c12))
 *                        tmp.add_count(k,self.mat.rightColumns[i],ll)             # <<<<<<<<<<<<<<
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_l1(self):
 */
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->mat->rightColumns[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_18 = PyFloat_FromDouble(__pyx_v_ll); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          __pyx_t_19 = NULL;
          __pyx_t_20 = 0;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_19)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_19);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
              __pyx_t_20 = 1;
            }
          }
          __pyx_t_21 = PyTuple_New(3+__pyx_t_20); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_21);
          if (__pyx_t_19) {
            PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_19); __Pyx_GIVEREF(__pyx_t_19); __pyx_t_19 = NULL;
          }
          PyTuple_SET_ITEM(__pyx_t_21, 0+__pyx_t_20, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_21, 1+__pyx_t_20, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_21, 2+__pyx_t_20, __pyx_t_18);
          __Pyx_GIVEREF(__pyx_t_18);
          __pyx_t_3 = 0;
          __pyx_t_4 = 0;
          __pyx_t_18 = 0;
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_21, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          goto __pyx_L9;
        }
        __pyx_L9:;
        goto __pyx_L8;
      }
      __pyx_L8:;
    }
  }

  /* "lurrn/sparsmat.pyx":1140
 *                            +logB(c1,p1,c12)+logB(c-c1,pn1,c2-c12))
 *                        tmp.add_count(k,self.mat.rightColumns[i],ll)
 *         return tmp.to_csr()             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixD transform_l1(self):
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp->__pyx_vtab)->to_csr(__pyx_v_tmp, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1110
 *                       tmp.add_count(k,self.mat.rightColumns[i],log_v)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_ll(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_r
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_21);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.transform_ll", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_l);
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_r);
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_27transform_ll(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_27transform_ll(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("transform_ll (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_26transform_ll(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_26transform_ll(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_ll", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_transform_ll(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.transform_ll", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1141
 *                        tmp.add_count(k,self.mat.rightColumns[i],ll)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_l1(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 *         cdef VecD2 tmp=VecD2()
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_29transform_l1(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_transform_l1(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_marginals_l = 0;
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp = 0;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_i;
  int __pyx_v_off1;
  int __pyx_v_off2;
  double __pyx_v_v;
  double __pyx_v_marg_l;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_l;
  __Pyx_Buffer __pyx_pybuffer_marginals_l;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyArrayObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  coordinate_t __pyx_t_11;
  coordinate_t __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  Py_ssize_t __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_l1", 0);
  __pyx_pybuffer_marginals_l.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_l.refcount = 0;
  __pyx_pybuffernd_marginals_l.data = NULL;
  __pyx_pybuffernd_marginals_l.rcbuffer = &__pyx_pybuffer_marginals_l;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transform_l1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_29transform_l1)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1143
 *     cpdef CSRMatrixD transform_l1(self):
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 *         cdef VecD2 tmp=VecD2()             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, i
 *         cdef int off1, off2
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1147
 *         cdef int off1, off2
 *         cdef double v, marg_l
 *         if self.mat.num_rows<100000:             # <<<<<<<<<<<<<<
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 */
  __pyx_t_5 = ((__pyx_v_self->mat->num_rows < 100000) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":1148
 *         cdef double v, marg_l
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         else:
 *             tmp.vec.reserve(100000)
 */
    __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":1150
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 *             tmp.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *         marginals_l=self.left_marginals()
 *         for k from 0<=k<self.mat.num_rows:
 */
    __pyx_v_tmp->vec.reserve(100000);
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":1151
 *         else:
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.num_rows:
 *             marg_l=marginals_l[k]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_left_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_l, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_marginals_l.diminfo[0].strides = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_l.diminfo[0].shape = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = 0;
  __pyx_v_marginals_l = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1152
 *             tmp.vec.reserve(100000)
 *         marginals_l=self.left_marginals()
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             marg_l=marginals_l[k]
 *             off1=self.mat.offsets[k]
 */
  __pyx_t_11 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_11; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":1153
 *         marginals_l=self.left_marginals()
 *         for k from 0<=k<self.mat.num_rows:
 *             marg_l=marginals_l[k]             # <<<<<<<<<<<<<<
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 */
    __pyx_t_12 = __pyx_v_k;
    __pyx_t_7 = -1;
    if (unlikely(__pyx_t_12 >= (size_t)__pyx_pybuffernd_marginals_l.diminfo[0].shape)) __pyx_t_7 = 0;
    if (unlikely(__pyx_t_7 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_7);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_marg_l = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_marginals_l.diminfo[0].strides));

    /* "lurrn/sparsmat.pyx":1154
 *         for k from 0<=k<self.mat.num_rows:
 *             marg_l=marginals_l[k]
 *             off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":1155
 *             marg_l=marginals_l[k]
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":1156
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                v=self.mat.values[i]
 *                if v>0:
 */
    __pyx_t_7 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":1157
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]             # <<<<<<<<<<<<<<
 *                if v>0:
 *                    tmp.add_count(k,self.mat.rightColumns[i],v/marg_l)
 */
      __pyx_v_v = (__pyx_v_self->mat->values[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":1158
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 *                if v>0:             # <<<<<<<<<<<<<<
 *                    tmp.add_count(k,self.mat.rightColumns[i],v/marg_l)
 *         return tmp.to_csr()
 */
      __pyx_t_5 = ((__pyx_v_v > 0.0) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":1159
 *                v=self.mat.values[i]
 *                if v>0:
 *                    tmp.add_count(k,self.mat.rightColumns[i],v/marg_l)             # <<<<<<<<<<<<<<
 *         return tmp.to_csr()
 *     def thresholds_norm(self, perc):
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->mat->rightColumns[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        if (unlikely(__pyx_v_marg_l == 0)) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
          #endif
          PyErr_SetString(PyExc_ZeroDivisionError, "float division");
          #ifdef WITH_THREAD
          PyGILState_Release(__pyx_gilstate_save);
          #endif
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_13 = PyFloat_FromDouble((__pyx_v_v / __pyx_v_marg_l)); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_14 = NULL;
        __pyx_t_15 = 0;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_14)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_14);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
            __pyx_t_15 = 1;
          }
        }
        __pyx_t_16 = PyTuple_New(3+__pyx_t_15); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_16);
        if (__pyx_t_14) {
          PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); __pyx_t_14 = NULL;
        }
        PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_15, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_15, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_16, 2+__pyx_t_15, __pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_13);
        __pyx_t_3 = 0;
        __pyx_t_4 = 0;
        __pyx_t_13 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_16, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L8;
      }
      __pyx_L8:;
    }
  }

  /* "lurrn/sparsmat.pyx":1160
 *                if v>0:
 *                    tmp.add_count(k,self.mat.rightColumns[i],v/marg_l)
 *         return tmp.to_csr()             # <<<<<<<<<<<<<<
 *     def thresholds_norm(self, perc):
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] means
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp->__pyx_vtab)->to_csr(__pyx_v_tmp, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1141
 *                        tmp.add_count(k,self.mat.rightColumns[i],ll)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD transform_l1(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 *         cdef VecD2 tmp=VecD2()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_16);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.transform_l1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_l);
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_29transform_l1(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_29transform_l1(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("transform_l1 (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_28transform_l1(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_28transform_l1(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_l1", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_transform_l1(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.transform_l1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1161
 *                    tmp.add_count(k,self.mat.rightColumns[i],v/marg_l)
 *         return tmp.to_csr()
 *     def thresholds_norm(self, perc):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] means
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] squared_means
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_31thresholds_norm(PyObject *__pyx_v_self, PyObject *__pyx_v_perc); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_31thresholds_norm(PyObject *__pyx_v_self, PyObject *__pyx_v_perc) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("thresholds_norm (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_30thresholds_norm(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self), ((PyObject *)__pyx_v_perc));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_30thresholds_norm(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_perc) {
  PyArrayObject *__pyx_v_means = 0;
  PyArrayObject *__pyx_v_squared_means = 0;
  PyArrayObject *__pyx_v_stddev = 0;
  double __pyx_v_zscore;
  int __pyx_v_count_targets;
  int __pyx_v_count_all;
  double __pyx_v_corr_factor;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_means;
  __Pyx_Buffer __pyx_pybuffer_means;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_squared_means;
  __Pyx_Buffer __pyx_pybuffer_squared_means;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_stddev;
  __Pyx_Buffer __pyx_pybuffer_stddev;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  double __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyArrayObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyArrayObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyArrayObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("thresholds_norm", 0);
  __pyx_pybuffer_means.pybuffer.buf = NULL;
  __pyx_pybuffer_means.refcount = 0;
  __pyx_pybuffernd_means.data = NULL;
  __pyx_pybuffernd_means.rcbuffer = &__pyx_pybuffer_means;
  __pyx_pybuffer_squared_means.pybuffer.buf = NULL;
  __pyx_pybuffer_squared_means.refcount = 0;
  __pyx_pybuffernd_squared_means.data = NULL;
  __pyx_pybuffernd_squared_means.rcbuffer = &__pyx_pybuffer_squared_means;
  __pyx_pybuffer_stddev.pybuffer.buf = NULL;
  __pyx_pybuffer_stddev.refcount = 0;
  __pyx_pybuffernd_stddev.data = NULL;
  __pyx_pybuffernd_stddev.rcbuffer = &__pyx_pybuffer_stddev;

  /* "lurrn/sparsmat.pyx":1165
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] squared_means
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] stddev
 *         cdef double zscore=inverse_erf(2.0*perc-1.0)             # <<<<<<<<<<<<<<
 *         cdef int count_targets
 *         cdef int count_all=self.get_maxcol()+1
 */
  __pyx_t_1 = PyNumber_Multiply(__pyx_float_2_0, __pyx_v_perc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_float_1_0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_3 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_zscore = inverse_erf(__pyx_t_3);

  /* "lurrn/sparsmat.pyx":1167
 *         cdef double zscore=inverse_erf(2.0*perc-1.0)
 *         cdef int count_targets
 *         cdef int count_all=self.get_maxcol()+1             # <<<<<<<<<<<<<<
 *         cdef double corr_factor = count_all / (count_all - 1.0)
 *         count_targets=len(self)
 */
  __pyx_v_count_all = (((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0) + 1);

  /* "lurrn/sparsmat.pyx":1168
 *         cdef int count_targets
 *         cdef int count_all=self.get_maxcol()+1
 *         cdef double corr_factor = count_all / (count_all - 1.0)             # <<<<<<<<<<<<<<
 *         count_targets=len(self)
 *         means=self.right_marginals()
 */
  __pyx_t_3 = (__pyx_v_count_all - 1.0);
  if (unlikely(__pyx_t_3 == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_corr_factor = (__pyx_v_count_all / __pyx_t_3);

  /* "lurrn/sparsmat.pyx":1169
 *         cdef int count_all=self.get_maxcol()+1
 *         cdef double corr_factor = count_all / (count_all - 1.0)
 *         count_targets=len(self)             # <<<<<<<<<<<<<<
 *         means=self.right_marginals()
 *         means /= count_targets
 */
  __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_count_targets = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":1170
 *         cdef double corr_factor = count_all / (count_all - 1.0)
 *         count_targets=len(self)
 *         means=self.right_marginals()             # <<<<<<<<<<<<<<
 *         means /= count_targets
 *         squared_means = self.right_squared_marginals()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_right_marginals); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_means.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_means.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_means.rcbuffer->pybuffer, (PyObject*)__pyx_v_means, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_means.diminfo[0].strides = __pyx_pybuffernd_means.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_means.diminfo[0].shape = __pyx_pybuffernd_means.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = 0;
  __pyx_v_means = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":1171
 *         count_targets=len(self)
 *         means=self.right_marginals()
 *         means /= count_targets             # <<<<<<<<<<<<<<
 *         squared_means = self.right_squared_marginals()
 *         squared_means /= count_targets
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_count_targets); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyNumber_InPlaceDivide(((PyObject *)__pyx_v_means), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_means.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_means.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_means.rcbuffer->pybuffer, (PyObject*)__pyx_v_means, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
      }
    }
    __pyx_pybuffernd_means.diminfo[0].strides = __pyx_pybuffernd_means.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_means.diminfo[0].shape = __pyx_pybuffernd_means.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = 0;
  __Pyx_DECREF_SET(__pyx_v_means, ((PyArrayObject *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1172
 *         means=self.right_marginals()
 *         means /= count_targets
 *         squared_means = self.right_squared_marginals()             # <<<<<<<<<<<<<<
 *         squared_means /= count_targets
 *         stddev=numpy.sqrt(corr_factor * (squared_means - means*means))
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_right_squared_marginals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer, (PyObject*)__pyx_v_squared_means, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_squared_means.diminfo[0].strides = __pyx_pybuffernd_squared_means.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_squared_means.diminfo[0].shape = __pyx_pybuffernd_squared_means.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_11 = 0;
  __pyx_v_squared_means = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1173
 *         means /= count_targets
 *         squared_means = self.right_squared_marginals()
 *         squared_means /= count_targets             # <<<<<<<<<<<<<<
 *         stddev=numpy.sqrt(corr_factor * (squared_means - means*means))
 *         return means + zscore * stddev
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_count_targets); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyNumber_InPlaceDivide(((PyObject *)__pyx_v_squared_means), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer, (PyObject*)__pyx_v_squared_means, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
      }
    }
    __pyx_pybuffernd_squared_means.diminfo[0].strides = __pyx_pybuffernd_squared_means.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_squared_means.diminfo[0].shape = __pyx_pybuffernd_squared_means.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_11 = 0;
  __Pyx_DECREF_SET(__pyx_v_squared_means, ((PyArrayObject *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":1174
 *         squared_means = self.right_squared_marginals()
 *         squared_means /= count_targets
 *         stddev=numpy.sqrt(corr_factor * (squared_means - means*means))             # <<<<<<<<<<<<<<
 *         return means + zscore * stddev
 *     def thresholds_quantile(self, perc):
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_corr_factor); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_12 = PyNumber_Multiply(((PyObject *)__pyx_v_means), ((PyObject *)__pyx_v_means)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = PyNumber_Subtract(((PyObject *)__pyx_v_squared_means), __pyx_t_12); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = PyNumber_Multiply(__pyx_t_1, __pyx_t_13); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_13) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_12); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_13); __Pyx_GIVEREF(__pyx_t_13); __pyx_t_13 = NULL;
    PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_stddev.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_stddev.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_stddev.rcbuffer->pybuffer, (PyObject*)__pyx_v_stddev, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_stddev.diminfo[0].strides = __pyx_pybuffernd_stddev.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_stddev.diminfo[0].shape = __pyx_pybuffernd_stddev.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_14 = 0;
  __pyx_v_stddev = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":1175
 *         squared_means /= count_targets
 *         stddev=numpy.sqrt(corr_factor * (squared_means - means*means))
 *         return means + zscore * stddev             # <<<<<<<<<<<<<<
 *     def thresholds_quantile(self, perc):
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] results
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_zscore); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = PyNumber_Multiply(__pyx_t_2, ((PyObject *)__pyx_v_stddev)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_v_means), __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1161
 *                    tmp.add_count(k,self.mat.rightColumns[i],v/marg_l)
 *         return tmp.to_csr()
 *     def thresholds_norm(self, perc):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] means
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] squared_means
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_means.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_stddev.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.thresholds_norm", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_means.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_squared_means.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_stddev.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_means);
  __Pyx_XDECREF((PyObject *)__pyx_v_squared_means);
  __Pyx_XDECREF((PyObject *)__pyx_v_stddev);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1176
 *         stddev=numpy.sqrt(corr_factor * (squared_means - means*means))
 *         return means + zscore * stddev
 *     def thresholds_quantile(self, perc):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] results
 *         cdef int i, count_nz, offset, abs_offset
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_33thresholds_quantile(PyObject *__pyx_v_self, PyObject *__pyx_v_perc); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_33thresholds_quantile(PyObject *__pyx_v_self, PyObject *__pyx_v_perc) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("thresholds_quantile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_32thresholds_quantile(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self), ((PyObject *)__pyx_v_perc));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_32thresholds_quantile(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_perc) {
  PyArrayObject *__pyx_v_results = 0;
  int __pyx_v_i;
  int __pyx_v_count_nz;
  int __pyx_v_offset;
  int __pyx_v_abs_offset;
  CYTHON_UNUSED int __pyx_v_count_targets;
  CYTHON_UNUSED int __pyx_v_count_all;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_nonzeros = 0;
  PyObject *__pyx_v_count_features = NULL;
  PyObject *__pyx_v_nz_vals = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_v = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_results;
  __Pyx_Buffer __pyx_pybuffer_results;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyArrayObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *__pyx_t_14 = NULL;
  PyObject *(*__pyx_t_15)(PyObject *);
  int __pyx_t_16;
  __pyx_t_5numpy_float64_t __pyx_t_17;
  int __pyx_t_18;
  int __pyx_t_19;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("thresholds_quantile", 0);
  __pyx_pybuffer_results.pybuffer.buf = NULL;
  __pyx_pybuffer_results.refcount = 0;
  __pyx_pybuffernd_results.data = NULL;
  __pyx_pybuffernd_results.rcbuffer = &__pyx_pybuffer_results;

  /* "lurrn/sparsmat.pyx":1180
 *         cdef int i, count_nz, offset, abs_offset
 *         cdef int count_targets
 *         cdef int count_all=self.get_maxcol()+1             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixD nonzeros=self.transpose()
 *         count_targets=len(self)
 */
  __pyx_v_count_all = (((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0) + 1);

  /* "lurrn/sparsmat.pyx":1181
 *         cdef int count_targets
 *         cdef int count_all=self.get_maxcol()+1
 *         cdef CSRMatrixD nonzeros=self.transpose()             # <<<<<<<<<<<<<<
 *         count_targets=len(self)
 *         count_features=len(nonzeros)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transpose); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_nonzeros = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1182
 *         cdef int count_all=self.get_maxcol()+1
 *         cdef CSRMatrixD nonzeros=self.transpose()
 *         count_targets=len(self)             # <<<<<<<<<<<<<<
 *         count_features=len(nonzeros)
 *         results=numpy.zeros(count_features,numpy.float64)
 */
  __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_count_targets = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":1183
 *         cdef CSRMatrixD nonzeros=self.transpose()
 *         count_targets=len(self)
 *         count_features=len(nonzeros)             # <<<<<<<<<<<<<<
 *         results=numpy.zeros(count_features,numpy.float64)
 *         abs_offset=count_features*(1.0-perc)+0.5
 */
  __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_nonzeros)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_count_features = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1184
 *         count_targets=len(self)
 *         count_features=len(nonzeros)
 *         results=numpy.zeros(count_features,numpy.float64)             # <<<<<<<<<<<<<<
 *         abs_offset=count_features*(1.0-perc)+0.5
 *         if abs_offset==0:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_v_count_features);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_4, __pyx_v_count_features);
  __Pyx_GIVEREF(__pyx_v_count_features);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_4, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
    __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_results.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_8 < 0)) {
      PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_results.rcbuffer->pybuffer, (PyObject*)__pyx_v_results, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
    }
    __pyx_pybuffernd_results.diminfo[0].strides = __pyx_pybuffernd_results.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_results.diminfo[0].shape = __pyx_pybuffernd_results.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_7 = 0;
  __pyx_v_results = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1185
 *         count_features=len(nonzeros)
 *         results=numpy.zeros(count_features,numpy.float64)
 *         abs_offset=count_features*(1.0-perc)+0.5             # <<<<<<<<<<<<<<
 *         if abs_offset==0:
 *             abs_offset=1
 */
  __pyx_t_1 = PyNumber_Subtract(__pyx_float_1_0, __pyx_v_perc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyNumber_Multiply(__pyx_v_count_features, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_float_0_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_abs_offset = __pyx_t_8;

  /* "lurrn/sparsmat.pyx":1186
 *         results=numpy.zeros(count_features,numpy.float64)
 *         abs_offset=count_features*(1.0-perc)+0.5
 *         if abs_offset==0:             # <<<<<<<<<<<<<<
 *             abs_offset=1
 *         for i from 0<=i<count_features:
 */
  __pyx_t_12 = ((__pyx_v_abs_offset == 0) != 0);
  if (__pyx_t_12) {

    /* "lurrn/sparsmat.pyx":1187
 *         abs_offset=count_features*(1.0-perc)+0.5
 *         if abs_offset==0:
 *             abs_offset=1             # <<<<<<<<<<<<<<
 *         for i from 0<=i<count_features:
 *             nz_vals=[v for k,v in nonzeros[i]]
 */
    __pyx_v_abs_offset = 1;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":1188
 *         if abs_offset==0:
 *             abs_offset=1
 *         for i from 0<=i<count_features:             # <<<<<<<<<<<<<<
 *             nz_vals=[v for k,v in nonzeros[i]]
 *             nz_vals.sort()
 */
  __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_count_features); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":1189
 *             abs_offset=1
 *         for i from 0<=i<count_features:
 *             nz_vals=[v for k,v in nonzeros[i]]             # <<<<<<<<<<<<<<
 *             nz_vals.sort()
 *             count_nz=len(nz_vals)
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_v_nonzeros), __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_6 = __pyx_t_3; __Pyx_INCREF(__pyx_t_6); __pyx_t_4 = 0;
      __pyx_t_13 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_13 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (likely(!__pyx_t_13)) {
        if (likely(PyList_CheckExact(__pyx_t_6))) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_13(__pyx_t_6);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
        PyObject* sequence = __pyx_t_3;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_2);
        #else
        __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_14 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_15 = Py_TYPE(__pyx_t_14)->tp_iternext;
        index = 0; __pyx_t_5 = __pyx_t_15(__pyx_t_14); if (unlikely(!__pyx_t_5)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        index = 1; __pyx_t_2 = __pyx_t_15(__pyx_t_14); if (unlikely(!__pyx_t_2)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_14), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_15 = NULL;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        goto __pyx_L9_unpacking_done;
        __pyx_L8_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_15 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L9_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_5);
      __pyx_t_5 = 0;
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_2);
      __pyx_t_2 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_v_v))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_nz_vals, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":1190
 *         for i from 0<=i<count_features:
 *             nz_vals=[v for k,v in nonzeros[i]]
 *             nz_vals.sort()             # <<<<<<<<<<<<<<
 *             count_nz=len(nz_vals)
 *             offset=count_nz-abs_offset
 */
    __pyx_t_16 = PyList_Sort(__pyx_v_nz_vals); if (unlikely(__pyx_t_16 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lurrn/sparsmat.pyx":1191
 *             nz_vals=[v for k,v in nonzeros[i]]
 *             nz_vals.sort()
 *             count_nz=len(nz_vals)             # <<<<<<<<<<<<<<
 *             offset=count_nz-abs_offset
 *             if offset<0:
 */
    __pyx_t_4 = PyList_GET_SIZE(__pyx_v_nz_vals); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_count_nz = __pyx_t_4;

    /* "lurrn/sparsmat.pyx":1192
 *             nz_vals.sort()
 *             count_nz=len(nz_vals)
 *             offset=count_nz-abs_offset             # <<<<<<<<<<<<<<
 *             if offset<0:
 *                 offset=0
 */
    __pyx_v_offset = (__pyx_v_count_nz - __pyx_v_abs_offset);

    /* "lurrn/sparsmat.pyx":1193
 *             count_nz=len(nz_vals)
 *             offset=count_nz-abs_offset
 *             if offset<0:             # <<<<<<<<<<<<<<
 *                 offset=0
 *             results[i] = nz_vals[offset]
 */
    __pyx_t_12 = ((__pyx_v_offset < 0) != 0);
    if (__pyx_t_12) {

      /* "lurrn/sparsmat.pyx":1194
 *             offset=count_nz-abs_offset
 *             if offset<0:
 *                 offset=0             # <<<<<<<<<<<<<<
 *             results[i] = nz_vals[offset]
 *         return results
 */
      __pyx_v_offset = 0;
      goto __pyx_L10;
    }
    __pyx_L10:;

    /* "lurrn/sparsmat.pyx":1195
 *             if offset<0:
 *                 offset=0
 *             results[i] = nz_vals[offset]             # <<<<<<<<<<<<<<
 *         return results
 *     def thresholds_nonzero(self, perc):
 */
    __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_nz_vals, __pyx_v_offset, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1195; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_17 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_17 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_18 = __pyx_v_i;
    __pyx_t_19 = -1;
    if (__pyx_t_18 < 0) {
      __pyx_t_18 += __pyx_pybuffernd_results.diminfo[0].shape;
      if (unlikely(__pyx_t_18 < 0)) __pyx_t_19 = 0;
    } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_results.diminfo[0].shape)) __pyx_t_19 = 0;
    if (unlikely(__pyx_t_19 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_19);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_results.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_results.diminfo[0].strides) = __pyx_t_17;
  }

  /* "lurrn/sparsmat.pyx":1196
 *                 offset=0
 *             results[i] = nz_vals[offset]
 *         return results             # <<<<<<<<<<<<<<
 *     def thresholds_nonzero(self, perc):
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] results
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_results));
  __pyx_r = ((PyObject *)__pyx_v_results);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1176
 *         stddev=numpy.sqrt(corr_factor * (squared_means - means*means))
 *         return means + zscore * stddev
 *     def thresholds_quantile(self, perc):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] results
 *         cdef int i, count_nz, offset, abs_offset
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_14);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.thresholds_quantile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_results);
  __Pyx_XDECREF((PyObject *)__pyx_v_nonzeros);
  __Pyx_XDECREF(__pyx_v_count_features);
  __Pyx_XDECREF(__pyx_v_nz_vals);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1197
 *             results[i] = nz_vals[offset]
 *         return results
 *     def thresholds_nonzero(self, perc):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] results
 *         cdef int i
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_35thresholds_nonzero(PyObject *__pyx_v_self, PyObject *__pyx_v_perc); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_35thresholds_nonzero(PyObject *__pyx_v_self, PyObject *__pyx_v_perc) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("thresholds_nonzero (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_34thresholds_nonzero(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self), ((PyObject *)__pyx_v_perc));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_34thresholds_nonzero(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_perc) {
  PyArrayObject *__pyx_v_results = 0;
  int __pyx_v_i;
  int __pyx_v_count_all;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_nonzeros = 0;
  PyObject *__pyx_v_nz_vals = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_v = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_results;
  __Pyx_Buffer __pyx_pybuffer_results;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *(*__pyx_t_14)(PyObject *);
  int __pyx_t_15;
  __pyx_t_5numpy_float64_t __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("thresholds_nonzero", 0);
  __pyx_pybuffer_results.pybuffer.buf = NULL;
  __pyx_pybuffer_results.refcount = 0;
  __pyx_pybuffernd_results.data = NULL;
  __pyx_pybuffernd_results.rcbuffer = &__pyx_pybuffer_results;

  /* "lurrn/sparsmat.pyx":1200
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] results
 *         cdef int i
 *         cdef int count_all=self.get_maxcol()+1             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixD nonzeros=self.transpose()
 *         results=numpy.zeros(count_all,numpy.float64)
 */
  __pyx_v_count_all = (((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0) + 1);

  /* "lurrn/sparsmat.pyx":1201
 *         cdef int i
 *         cdef int count_all=self.get_maxcol()+1
 *         cdef CSRMatrixD nonzeros=self.transpose()             # <<<<<<<<<<<<<<
 *         results=numpy.zeros(count_all,numpy.float64)
 *         for i from 0<=i<count_all:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transpose); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_nonzeros = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1202
 *         cdef int count_all=self.get_maxcol()+1
 *         cdef CSRMatrixD nonzeros=self.transpose()
 *         results=numpy.zeros(count_all,numpy.float64)             # <<<<<<<<<<<<<<
 *         for i from 0<=i<count_all:
 *             nz_vals=[v for k,v in nonzeros[i]]
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_count_all); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_results.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_results.rcbuffer->pybuffer, (PyObject*)__pyx_v_results, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_results.diminfo[0].strides = __pyx_pybuffernd_results.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_results.diminfo[0].shape = __pyx_pybuffernd_results.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __pyx_v_results = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1203
 *         cdef CSRMatrixD nonzeros=self.transpose()
 *         results=numpy.zeros(count_all,numpy.float64)
 *         for i from 0<=i<count_all:             # <<<<<<<<<<<<<<
 *             nz_vals=[v for k,v in nonzeros[i]]
 *             nz_vals.sort()
 */
  __pyx_t_9 = __pyx_v_count_all;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":1204
 *         results=numpy.zeros(count_all,numpy.float64)
 *         for i from 0<=i<count_all:
 *             nz_vals=[v for k,v in nonzeros[i]]             # <<<<<<<<<<<<<<
 *             nz_vals.sort()
 *             results[i] = nz_vals[int(len(nz_vals)*perc)]
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_v_nonzeros), __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_7 = __pyx_t_3; __Pyx_INCREF(__pyx_t_7); __pyx_t_6 = 0;
      __pyx_t_13 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_13 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (likely(!__pyx_t_13)) {
        if (likely(PyList_CheckExact(__pyx_t_7))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_7, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_7, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_13(__pyx_t_7);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
        PyObject* sequence = __pyx_t_3;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_2);
        #else
        __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_14 = Py_TYPE(__pyx_t_4)->tp_iternext;
        index = 0; __pyx_t_5 = __pyx_t_14(__pyx_t_4); if (unlikely(!__pyx_t_5)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        index = 1; __pyx_t_2 = __pyx_t_14(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_14 = NULL;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L8_unpacking_done;
        __pyx_L7_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_14 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L8_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_5);
      __pyx_t_5 = 0;
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_2);
      __pyx_t_2 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_v_v))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF_SET(__pyx_v_nz_vals, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":1205
 *         for i from 0<=i<count_all:
 *             nz_vals=[v for k,v in nonzeros[i]]
 *             nz_vals.sort()             # <<<<<<<<<<<<<<
 *             results[i] = nz_vals[int(len(nz_vals)*perc)]
 *         return results
 */
    __pyx_t_15 = PyList_Sort(__pyx_v_nz_vals); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lurrn/sparsmat.pyx":1206
 *             nz_vals=[v for k,v in nonzeros[i]]
 *             nz_vals.sort()
 *             results[i] = nz_vals[int(len(nz_vals)*perc)]             # <<<<<<<<<<<<<<
 *         return results
 *     def get_quantiles(self, qs):
 */
    __pyx_t_6 = PyList_GET_SIZE(__pyx_v_nz_vals); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = PyNumber_Multiply(__pyx_t_1, __pyx_v_perc); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Int(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyObject_GetItem(__pyx_v_nz_vals, __pyx_t_1); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_16 = __pyx_PyFloat_AsDouble(__pyx_t_7); if (unlikely((__pyx_t_16 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_17 = __pyx_v_i;
    __pyx_t_18 = -1;
    if (__pyx_t_17 < 0) {
      __pyx_t_17 += __pyx_pybuffernd_results.diminfo[0].shape;
      if (unlikely(__pyx_t_17 < 0)) __pyx_t_18 = 0;
    } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_results.diminfo[0].shape)) __pyx_t_18 = 0;
    if (unlikely(__pyx_t_18 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_18);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_results.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_results.diminfo[0].strides) = __pyx_t_16;
  }

  /* "lurrn/sparsmat.pyx":1207
 *             nz_vals.sort()
 *             results[i] = nz_vals[int(len(nz_vals)*perc)]
 *         return results             # <<<<<<<<<<<<<<
 *     def get_quantiles(self, qs):
 *         cdef coordinate_t k, nnz
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_results));
  __pyx_r = ((PyObject *)__pyx_v_results);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1197
 *             results[i] = nz_vals[offset]
 *         return results
 *     def thresholds_nonzero(self, perc):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] results
 *         cdef int i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.thresholds_nonzero", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_results);
  __Pyx_XDECREF((PyObject *)__pyx_v_nonzeros);
  __Pyx_XDECREF(__pyx_v_nz_vals);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1208
 *             results[i] = nz_vals[int(len(nz_vals)*perc)]
 *         return results
 *     def get_quantiles(self, qs):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, nnz
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] allvals
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_37get_quantiles(PyObject *__pyx_v_self, PyObject *__pyx_v_qs); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_37get_quantiles(PyObject *__pyx_v_self, PyObject *__pyx_v_qs) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_quantiles (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_36get_quantiles(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self), ((PyObject *)__pyx_v_qs));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_36get_quantiles(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_qs) {
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_nnz;
  PyArrayObject *__pyx_v_allvals = 0;
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_q = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_allvals;
  __Pyx_Buffer __pyx_pybuffer_allvals;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  coordinate_t __pyx_t_13;
  int __pyx_t_14;
  PyObject *(*__pyx_t_15)(PyObject *);
  coordinate_t __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_quantiles", 0);
  __pyx_pybuffer_allvals.pybuffer.buf = NULL;
  __pyx_pybuffer_allvals.refcount = 0;
  __pyx_pybuffernd_allvals.data = NULL;
  __pyx_pybuffernd_allvals.rcbuffer = &__pyx_pybuffer_allvals;

  /* "lurrn/sparsmat.pyx":1211
 *         cdef coordinate_t k, nnz
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] allvals
 *         nnz = self.mat.offsets[self.mat.num_rows]             # <<<<<<<<<<<<<<
 *         allvals = numpy.empty(self.mat.offsets[self.mat.num_rows],
 *                               numpy.float64)
 */
  __pyx_v_nnz = (__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]);

  /* "lurrn/sparsmat.pyx":1212
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] allvals
 *         nnz = self.mat.offsets[self.mat.num_rows]
 *         allvals = numpy.empty(self.mat.offsets[self.mat.num_rows],             # <<<<<<<<<<<<<<
 *                               numpy.float64)
 *         for k from 0<=k<self.mat.offsets[self.mat.num_rows]:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "lurrn/sparsmat.pyx":1213
 *         nnz = self.mat.offsets[self.mat.num_rows]
 *         allvals = numpy.empty(self.mat.offsets[self.mat.num_rows],
 *                               numpy.float64)             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.offsets[self.mat.num_rows]:
 *             allvals[k] = self.mat.values[k]
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "lurrn/sparsmat.pyx":1212
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] allvals
 *         nnz = self.mat.offsets[self.mat.num_rows]
 *         allvals = numpy.empty(self.mat.offsets[self.mat.num_rows],             # <<<<<<<<<<<<<<
 *                               numpy.float64)
 *         for k from 0<=k<self.mat.offsets[self.mat.num_rows]:
 */
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_allvals.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_allvals.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_allvals.rcbuffer->pybuffer, (PyObject*)__pyx_v_allvals, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_allvals.diminfo[0].strides = __pyx_pybuffernd_allvals.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_allvals.diminfo[0].shape = __pyx_pybuffernd_allvals.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __pyx_v_allvals = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1214
 *         allvals = numpy.empty(self.mat.offsets[self.mat.num_rows],
 *                               numpy.float64)
 *         for k from 0<=k<self.mat.offsets[self.mat.num_rows]:             # <<<<<<<<<<<<<<
 *             allvals[k] = self.mat.values[k]
 *         allvals.sort()
 */
  __pyx_t_9 = (__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]);
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_9; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":1215
 *                               numpy.float64)
 *         for k from 0<=k<self.mat.offsets[self.mat.num_rows]:
 *             allvals[k] = self.mat.values[k]             # <<<<<<<<<<<<<<
 *         allvals.sort()
 *         result = []
 */
    __pyx_t_13 = __pyx_v_k;
    __pyx_t_14 = -1;
    if (unlikely(__pyx_t_13 >= (size_t)__pyx_pybuffernd_allvals.diminfo[0].shape)) __pyx_t_14 = 0;
    if (unlikely(__pyx_t_14 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_14);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_allvals.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_allvals.diminfo[0].strides) = (__pyx_v_self->mat->values[__pyx_v_k]);
  }

  /* "lurrn/sparsmat.pyx":1216
 *         for k from 0<=k<self.mat.offsets[self.mat.num_rows]:
 *             allvals[k] = self.mat.values[k]
 *         allvals.sort()             # <<<<<<<<<<<<<<
 *         result = []
 *         for q in qs:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_allvals), __pyx_n_s_sort); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_7) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1217
 *             allvals[k] = self.mat.values[k]
 *         allvals.sort()
 *         result = []             # <<<<<<<<<<<<<<
 *         for q in qs:
 *             k = nnz*q
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1218
 *         allvals.sort()
 *         result = []
 *         for q in qs:             # <<<<<<<<<<<<<<
 *             k = nnz*q
 *             if k >= nnz:
 */
  if (likely(PyList_CheckExact(__pyx_v_qs)) || PyTuple_CheckExact(__pyx_v_qs)) {
    __pyx_t_1 = __pyx_v_qs; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_15 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_qs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_15 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_15)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_15(__pyx_t_1);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_q, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "lurrn/sparsmat.pyx":1219
 *         result = []
 *         for q in qs:
 *             k = nnz*q             # <<<<<<<<<<<<<<
 *             if k >= nnz:
 *                 k = nnz-1
 */
    __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_nnz); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = PyNumber_Multiply(__pyx_t_3, __pyx_v_q); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_16 = __Pyx_PyInt_As_coordinate_t(__pyx_t_7); if (unlikely((__pyx_t_16 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_k = __pyx_t_16;

    /* "lurrn/sparsmat.pyx":1220
 *         for q in qs:
 *             k = nnz*q
 *             if k >= nnz:             # <<<<<<<<<<<<<<
 *                 k = nnz-1
 *             result.append(allvals[k])
 */
    __pyx_t_17 = ((__pyx_v_k >= __pyx_v_nnz) != 0);
    if (__pyx_t_17) {

      /* "lurrn/sparsmat.pyx":1221
 *             k = nnz*q
 *             if k >= nnz:
 *                 k = nnz-1             # <<<<<<<<<<<<<<
 *             result.append(allvals[k])
 *         return result
 */
      __pyx_v_k = (__pyx_v_nnz - 1);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "lurrn/sparsmat.pyx":1222
 *             if k >= nnz:
 *                 k = nnz-1
 *             result.append(allvals[k])             # <<<<<<<<<<<<<<
 *         return result
 *     cpdef CSRMatrixD apply_threshold(self, numpy.ndarray thr):
 */
    __pyx_t_16 = __pyx_v_k;
    __pyx_t_9 = -1;
    if (unlikely(__pyx_t_16 >= (size_t)__pyx_pybuffernd_allvals.diminfo[0].shape)) __pyx_t_9 = 0;
    if (unlikely(__pyx_t_9 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_9);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_7 = PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_allvals.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_allvals.diminfo[0].strides))); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_18 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "lurrn/sparsmat.pyx":1218
 *         allvals.sort()
 *         result = []
 *         for q in qs:             # <<<<<<<<<<<<<<
 *             k = nnz*q
 *             if k >= nnz:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1223
 *                 k = nnz-1
 *             result.append(allvals[k])
 *         return result             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixD apply_threshold(self, numpy.ndarray thr):
 *         cdef VecD2 tmp=VecD2()
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1208
 *             results[i] = nz_vals[int(len(nz_vals)*perc)]
 *         return results
 *     def get_quantiles(self, qs):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, nnz
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] allvals
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_allvals.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.get_quantiles", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_allvals.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_allvals);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_q);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1224
 *             result.append(allvals[k])
 *         return result
 *     cpdef CSRMatrixD apply_threshold(self, numpy.ndarray thr):             # <<<<<<<<<<<<<<
 *         cdef VecD2 tmp=VecD2()
 *         cdef coordinate_t k, i, k2
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_39apply_threshold(PyObject *__pyx_v_self, PyObject *__pyx_v_thr); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_apply_threshold(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyArrayObject *__pyx_v_thr, int __pyx_skip_dispatch) {
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp = 0;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_k2;
  int __pyx_v_off1;
  int __pyx_v_off2;
  double __pyx_v_v;
  PyArrayObject *__pyx_v_thresholds = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_thresholds;
  __Pyx_Buffer __pyx_pybuffer_thresholds;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  coordinate_t __pyx_t_7;
  int __pyx_t_8;
  coordinate_t __pyx_t_9;
  int __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("apply_threshold", 0);
  __pyx_pybuffer_thresholds.pybuffer.buf = NULL;
  __pyx_pybuffer_thresholds.refcount = 0;
  __pyx_pybuffernd_thresholds.data = NULL;
  __pyx_pybuffernd_thresholds.rcbuffer = &__pyx_pybuffer_thresholds;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_apply_threshold); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_39apply_threshold)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_thr)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_thr));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_thr));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_thr));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1225
 *         return result
 *     cpdef CSRMatrixD apply_threshold(self, numpy.ndarray thr):
 *         cdef VecD2 tmp=VecD2()             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, i, k2
 *         cdef int off1, off2
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1229
 *         cdef int off1, off2
 *         cdef double v, marg_l
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] thresholds=thr             # <<<<<<<<<<<<<<
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 */
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_thresholds.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_thr), &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_thresholds = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_thresholds.diminfo[0].strides = __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_thresholds.diminfo[0].shape = __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.shape[0];
    }
  }
  __Pyx_INCREF(((PyObject *)__pyx_v_thr));
  __pyx_v_thresholds = ((PyArrayObject *)__pyx_v_thr);

  /* "lurrn/sparsmat.pyx":1230
 *         cdef double v, marg_l
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] thresholds=thr
 *         if self.mat.num_rows<100000:             # <<<<<<<<<<<<<<
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 */
  __pyx_t_6 = ((__pyx_v_self->mat->num_rows < 100000) != 0);
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":1231
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] thresholds=thr
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         else:
 *             tmp.vec.reserve(100000)
 */
    __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":1233
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 *             tmp.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.num_rows:
 *             off1=self.mat.offsets[k]
 */
    __pyx_v_tmp->vec.reserve(100000);
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":1234
 *         else:
 *             tmp.vec.reserve(100000)
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 */
  __pyx_t_7 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_7; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":1235
 *             tmp.vec.reserve(100000)
 *         for k from 0<=k<self.mat.num_rows:
 *             off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":1236
 *         for k from 0<=k<self.mat.num_rows:
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":1237
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                v=self.mat.values[i]
 *                k2=self.mat.rightColumns[i]
 */
    __pyx_t_8 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":1238
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]             # <<<<<<<<<<<<<<
 *                k2=self.mat.rightColumns[i]
 *                if v>=thresholds[k2]:
 */
      __pyx_v_v = (__pyx_v_self->mat->values[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":1239
 *             for i from off1<=i<off2:
 *                v=self.mat.values[i]
 *                k2=self.mat.rightColumns[i]             # <<<<<<<<<<<<<<
 *                if v>=thresholds[k2]:
 *                    tmp.add_count(k,k2,1.0)
 */
      __pyx_v_k2 = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":1240
 *                v=self.mat.values[i]
 *                k2=self.mat.rightColumns[i]
 *                if v>=thresholds[k2]:             # <<<<<<<<<<<<<<
 *                    tmp.add_count(k,k2,1.0)
 *         return tmp.to_csr()
 */
      __pyx_t_9 = __pyx_v_k2;
      __pyx_t_10 = -1;
      if (unlikely(__pyx_t_9 >= (size_t)__pyx_pybuffernd_thresholds.diminfo[0].shape)) __pyx_t_10 = 0;
      if (unlikely(__pyx_t_10 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_10);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = ((__pyx_v_v >= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_thresholds.diminfo[0].strides))) != 0);
      if (__pyx_t_6) {

        /* "lurrn/sparsmat.pyx":1241
 *                k2=self.mat.rightColumns[i]
 *                if v>=thresholds[k2]:
 *                    tmp.add_count(k,k2,1.0)             # <<<<<<<<<<<<<<
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD apply_scaling(self, numpy.ndarray thr):
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_5 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = NULL;
        __pyx_t_11 = 0;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
            __pyx_t_11 = 1;
          }
        }
        __pyx_t_12 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        if (__pyx_t_4) {
          PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        }
        PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_float_1_0);
        PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_11, __pyx_float_1_0);
        __Pyx_GIVEREF(__pyx_float_1_0);
        __pyx_t_3 = 0;
        __pyx_t_5 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L8;
      }
      __pyx_L8:;
    }
  }

  /* "lurrn/sparsmat.pyx":1242
 *                if v>=thresholds[k2]:
 *                    tmp.add_count(k,k2,1.0)
 *         return tmp.to_csr()             # <<<<<<<<<<<<<<
 *     cpdef CSRMatrixD apply_scaling(self, numpy.ndarray thr):
 *         cdef VecD2 tmp=VecD2()
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp->__pyx_vtab)->to_csr(__pyx_v_tmp, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1224
 *             result.append(allvals[k])
 *         return result
 *     cpdef CSRMatrixD apply_threshold(self, numpy.ndarray thr):             # <<<<<<<<<<<<<<
 *         cdef VecD2 tmp=VecD2()
 *         cdef coordinate_t k, i, k2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_12);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_thresholds.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.apply_threshold", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_thresholds.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XDECREF((PyObject *)__pyx_v_thresholds);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_39apply_threshold(PyObject *__pyx_v_self, PyObject *__pyx_v_thr); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_39apply_threshold(PyObject *__pyx_v_self, PyObject *__pyx_v_thr) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("apply_threshold (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_thr), __pyx_ptype_5numpy_ndarray, 1, "thr", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_38apply_threshold(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self), ((PyArrayObject *)__pyx_v_thr));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_38apply_threshold(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyArrayObject *__pyx_v_thr) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("apply_threshold", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_apply_threshold(__pyx_v_self, __pyx_v_thr, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.apply_threshold", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1243
 *                    tmp.add_count(k,k2,1.0)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD apply_scaling(self, numpy.ndarray thr):             # <<<<<<<<<<<<<<
 *         cdef VecD2 tmp=VecD2()
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] thresholds=thr
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_41apply_scaling(PyObject *__pyx_v_self, PyObject *__pyx_v_thr); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_apply_scaling(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyArrayObject *__pyx_v_thr, int __pyx_skip_dispatch) {
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp = 0;
  PyArrayObject *__pyx_v_thresholds = 0;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_k2;
  int __pyx_v_off1;
  int __pyx_v_off2;
  double __pyx_v_v;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_thresholds;
  __Pyx_Buffer __pyx_pybuffer_thresholds;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  coordinate_t __pyx_t_7;
  int __pyx_t_8;
  coordinate_t __pyx_t_9;
  int __pyx_t_10;
  __pyx_t_5numpy_float64_t __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("apply_scaling", 0);
  __pyx_pybuffer_thresholds.pybuffer.buf = NULL;
  __pyx_pybuffer_thresholds.refcount = 0;
  __pyx_pybuffernd_thresholds.data = NULL;
  __pyx_pybuffernd_thresholds.rcbuffer = &__pyx_pybuffer_thresholds;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_apply_scaling); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_41apply_scaling)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_thr)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_thr));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_thr));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_thr));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1244
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD apply_scaling(self, numpy.ndarray thr):
 *         cdef VecD2 tmp=VecD2()             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] thresholds=thr
 *         cdef coordinate_t k, i, k2
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1245
 *     cpdef CSRMatrixD apply_scaling(self, numpy.ndarray thr):
 *         cdef VecD2 tmp=VecD2()
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] thresholds=thr             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k, i, k2
 *         cdef int off1, off2
 */
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_thresholds.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_thr), &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_thresholds = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_thresholds.diminfo[0].strides = __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_thresholds.diminfo[0].shape = __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.shape[0];
    }
  }
  __Pyx_INCREF(((PyObject *)__pyx_v_thr));
  __pyx_v_thresholds = ((PyArrayObject *)__pyx_v_thr);

  /* "lurrn/sparsmat.pyx":1249
 *         cdef int off1, off2
 *         cdef double v, marg_l
 *         if self.mat.num_rows<100000:             # <<<<<<<<<<<<<<
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 */
  __pyx_t_6 = ((__pyx_v_self->mat->num_rows < 100000) != 0);
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":1250
 *         cdef double v, marg_l
 *         if self.mat.num_rows<100000:
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         else:
 *             tmp.vec.reserve(100000)
 */
    __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":1252
 *             tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         else:
 *             tmp.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *         for k from 0<=k<self.mat.num_rows:
 *             off1=self.mat.offsets[k]
 */
    __pyx_v_tmp->vec.reserve(100000);
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":1253
 *         else:
 *             tmp.vec.reserve(100000)
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 */
  __pyx_t_7 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_7; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":1254
 *             tmp.vec.reserve(100000)
 *         for k from 0<=k<self.mat.num_rows:
 *             off1=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":1255
 *         for k from 0<=k<self.mat.num_rows:
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                k2=self.mat.rightColumns[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":1256
 *             off1=self.mat.offsets[k]
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                k2=self.mat.rightColumns[i]
 *                v=self.mat.values[i]/thresholds[k2]
 */
    __pyx_t_8 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":1257
 *             off2=self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                k2=self.mat.rightColumns[i]             # <<<<<<<<<<<<<<
 *                v=self.mat.values[i]/thresholds[k2]
 *                if v>=1.0:
 */
      __pyx_v_k2 = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":1258
 *             for i from off1<=i<off2:
 *                k2=self.mat.rightColumns[i]
 *                v=self.mat.values[i]/thresholds[k2]             # <<<<<<<<<<<<<<
 *                if v>=1.0:
 *                    tmp.add_count(k,k2,1.0)
 */
      __pyx_t_9 = __pyx_v_k2;
      __pyx_t_10 = -1;
      if (unlikely(__pyx_t_9 >= (size_t)__pyx_pybuffernd_thresholds.diminfo[0].shape)) __pyx_t_10 = 0;
      if (unlikely(__pyx_t_10 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_10);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_11 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_thresholds.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_thresholds.diminfo[0].strides));
      if (unlikely(__pyx_t_11 == 0)) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        #ifdef WITH_THREAD
        PyGILState_Release(__pyx_gilstate_save);
        #endif
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_v_v = ((__pyx_v_self->mat->values[__pyx_v_i]) / __pyx_t_11);

      /* "lurrn/sparsmat.pyx":1259
 *                k2=self.mat.rightColumns[i]
 *                v=self.mat.values[i]/thresholds[k2]
 *                if v>=1.0:             # <<<<<<<<<<<<<<
 *                    tmp.add_count(k,k2,1.0)
 *                else:
 */
      __pyx_t_6 = ((__pyx_v_v >= 1.0) != 0);
      if (__pyx_t_6) {

        /* "lurrn/sparsmat.pyx":1260
 *                v=self.mat.values[i]/thresholds[k2]
 *                if v>=1.0:
 *                    tmp.add_count(k,k2,1.0)             # <<<<<<<<<<<<<<
 *                else:
 *                    tmp.add_count(k,k2,v)
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_5 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = NULL;
        __pyx_t_12 = 0;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
            __pyx_t_12 = 1;
          }
        }
        __pyx_t_13 = PyTuple_New(3+__pyx_t_12); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_13);
        if (__pyx_t_4) {
          PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        }
        PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_float_1_0);
        PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_12, __pyx_float_1_0);
        __Pyx_GIVEREF(__pyx_float_1_0);
        __pyx_t_3 = 0;
        __pyx_t_5 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_13, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L8;
      }
      /*else*/ {

        /* "lurrn/sparsmat.pyx":1262
 *                    tmp.add_count(k,k2,1.0)
 *                else:
 *                    tmp.add_count(k,k2,v)             # <<<<<<<<<<<<<<
 *         return tmp.to_csr()
 *     def scale_columns(self, factors):
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_13 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_5 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = PyFloat_FromDouble(__pyx_v_v); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = NULL;
        __pyx_t_12 = 0;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
            __pyx_t_12 = 1;
          }
        }
        __pyx_t_14 = PyTuple_New(3+__pyx_t_12); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_14);
        if (__pyx_t_4) {
          PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        }
        PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_12, __pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_13);
        PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_12, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_12, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_13 = 0;
        __pyx_t_5 = 0;
        __pyx_t_3 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_14, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __pyx_L8:;
    }
  }

  /* "lurrn/sparsmat.pyx":1263
 *                else:
 *                    tmp.add_count(k,k2,v)
 *         return tmp.to_csr()             # <<<<<<<<<<<<<<
 *     def scale_columns(self, factors):
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] factors_l = factors
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp->__pyx_vtab)->to_csr(__pyx_v_tmp, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1243
 *                    tmp.add_count(k,k2,1.0)
 *         return tmp.to_csr()
 *     cpdef CSRMatrixD apply_scaling(self, numpy.ndarray thr):             # <<<<<<<<<<<<<<
 *         cdef VecD2 tmp=VecD2()
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] thresholds=thr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_thresholds.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.apply_scaling", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_thresholds.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XDECREF((PyObject *)__pyx_v_thresholds);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_41apply_scaling(PyObject *__pyx_v_self, PyObject *__pyx_v_thr); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_41apply_scaling(PyObject *__pyx_v_self, PyObject *__pyx_v_thr) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("apply_scaling (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_thr), __pyx_ptype_5numpy_ndarray, 1, "thr", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_40apply_scaling(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self), ((PyArrayObject *)__pyx_v_thr));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_40apply_scaling(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyArrayObject *__pyx_v_thr) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("apply_scaling", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_apply_scaling(__pyx_v_self, __pyx_v_thr, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.apply_scaling", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1264
 *                    tmp.add_count(k,k2,v)
 *         return tmp.to_csr()
 *     def scale_columns(self, factors):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] factors_l = factors
 *         cdef coordinate_t k
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_43scale_columns(PyObject *__pyx_v_self, PyObject *__pyx_v_factors); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_43scale_columns(PyObject *__pyx_v_self, PyObject *__pyx_v_factors) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("scale_columns (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_42scale_columns(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self), ((PyObject *)__pyx_v_factors));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_42scale_columns(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_factors) {
  PyArrayObject *__pyx_v_factors_l = 0;
  coordinate_t __pyx_v_k;
  int __pyx_v_off1;
  int __pyx_v_off2;
  int __pyx_v_i;
  coordinate_t __pyx_v_k2;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_factors_l;
  __Pyx_Buffer __pyx_pybuffer_factors_l;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  coordinate_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  coordinate_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("scale_columns", 0);
  __pyx_pybuffer_factors_l.pybuffer.buf = NULL;
  __pyx_pybuffer_factors_l.refcount = 0;
  __pyx_pybuffernd_factors_l.data = NULL;
  __pyx_pybuffernd_factors_l.rcbuffer = &__pyx_pybuffer_factors_l;

  /* "lurrn/sparsmat.pyx":1265
 *         return tmp.to_csr()
 *     def scale_columns(self, factors):
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] factors_l = factors             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k
 *         cdef int off1, off2
 */
  if (!(likely(((__pyx_v_factors) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_factors, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_factors;
  __Pyx_INCREF(__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_factors_l.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_factors_l = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_factors_l.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_factors_l.diminfo[0].strides = __pyx_pybuffernd_factors_l.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_factors_l.diminfo[0].shape = __pyx_pybuffernd_factors_l.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_v_factors_l = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1268
 *         cdef coordinate_t k
 *         cdef int off1, off2
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             off1 = self.mat.offsets[k]
 *             off2 = self.mat.offsets[k+1]
 */
  __pyx_t_2 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_2; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":1269
 *         cdef int off1, off2
 *         for k from 0<=k<self.mat.num_rows:
 *             off1 = self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2 = self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":1270
 *         for k from 0<=k<self.mat.num_rows:
 *             off1 = self.mat.offsets[k]
 *             off2 = self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                 k2 = self.mat.rightColumns[i]
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":1271
 *             off1 = self.mat.offsets[k]
 *             off2 = self.mat.offsets[k+1]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                 k2 = self.mat.rightColumns[i]
 *                 self.mat.values[i] *= factors_l[k2]
 */
    __pyx_t_3 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":1272
 *             off2 = self.mat.offsets[k+1]
 *             for i from off1<=i<off2:
 *                 k2 = self.mat.rightColumns[i]             # <<<<<<<<<<<<<<
 *                 self.mat.values[i] *= factors_l[k2]
 *     def scale_rows(self, factors):
 */
      __pyx_v_k2 = (__pyx_v_self->mat->rightColumns[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":1273
 *             for i from off1<=i<off2:
 *                 k2 = self.mat.rightColumns[i]
 *                 self.mat.values[i] *= factors_l[k2]             # <<<<<<<<<<<<<<
 *     def scale_rows(self, factors):
 *         cdef coordinate_t k
 */
      __pyx_t_4 = __pyx_v_i;
      __pyx_t_5 = __pyx_v_k2;
      __pyx_t_6 = -1;
      if (unlikely(__pyx_t_5 >= (size_t)__pyx_pybuffernd_factors_l.diminfo[0].shape)) __pyx_t_6 = 0;
      if (unlikely(__pyx_t_6 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_6);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      (__pyx_v_self->mat->values[__pyx_t_4]) = ((__pyx_v_self->mat->values[__pyx_t_4]) * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_factors_l.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_factors_l.diminfo[0].strides)));
    }
  }

  /* "lurrn/sparsmat.pyx":1264
 *                    tmp.add_count(k,k2,v)
 *         return tmp.to_csr()
 *     def scale_columns(self, factors):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] factors_l = factors
 *         cdef coordinate_t k
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_factors_l.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.scale_columns", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_factors_l.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_factors_l);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1274
 *                 k2 = self.mat.rightColumns[i]
 *                 self.mat.values[i] *= factors_l[k2]
 *     def scale_rows(self, factors):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k
 *         cdef double factor
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_45scale_rows(PyObject *__pyx_v_self, PyObject *__pyx_v_factors); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_45scale_rows(PyObject *__pyx_v_self, PyObject *__pyx_v_factors) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("scale_rows (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_44scale_rows(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self), ((PyObject *)__pyx_v_factors));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_44scale_rows(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_factors) {
  coordinate_t __pyx_v_k;
  double __pyx_v_factor;
  int __pyx_v_off1;
  int __pyx_v_off2;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  coordinate_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  double __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("scale_rows", 0);

  /* "lurrn/sparsmat.pyx":1278
 *         cdef double factor
 *         cdef int off1, off2
 *         for k from 0<=k<self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             off1 = self.mat.offsets[k]
 *             off2 = self.mat.offsets[k+1]
 */
  __pyx_t_1 = __pyx_v_self->mat->num_rows;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) {

    /* "lurrn/sparsmat.pyx":1279
 *         cdef int off1, off2
 *         for k from 0<=k<self.mat.num_rows:
 *             off1 = self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *             off2 = self.mat.offsets[k+1]
 *             factor = factors[k]
 */
    __pyx_v_off1 = (__pyx_v_self->mat->offsets[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":1280
 *         for k from 0<=k<self.mat.num_rows:
 *             off1 = self.mat.offsets[k]
 *             off2 = self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *             factor = factors[k]
 *             for i from off1<=i<off2:
 */
    __pyx_v_off2 = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

    /* "lurrn/sparsmat.pyx":1281
 *             off1 = self.mat.offsets[k]
 *             off2 = self.mat.offsets[k+1]
 *             factor = factors[k]             # <<<<<<<<<<<<<<
 *             for i from off1<=i<off2:
 *                 self.mat.values[i] *= factor
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_factors, __pyx_v_k, coordinate_t, 0, __Pyx_PyInt_From_coordinate_t, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_3 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_factor = __pyx_t_3;

    /* "lurrn/sparsmat.pyx":1282
 *             off2 = self.mat.offsets[k+1]
 *             factor = factors[k]
 *             for i from off1<=i<off2:             # <<<<<<<<<<<<<<
 *                 self.mat.values[i] *= factor
 *     def left_marginals(self):
 */
    __pyx_t_4 = __pyx_v_off2;
    for (__pyx_v_i = __pyx_v_off1; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":1283
 *             factor = factors[k]
 *             for i from off1<=i<off2:
 *                 self.mat.values[i] *= factor             # <<<<<<<<<<<<<<
 *     def left_marginals(self):
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 */
      __pyx_t_5 = __pyx_v_i;
      (__pyx_v_self->mat->values[__pyx_t_5]) = ((__pyx_v_self->mat->values[__pyx_t_5]) * __pyx_v_factor);
    }
  }

  /* "lurrn/sparsmat.pyx":1274
 *                 k2 = self.mat.rightColumns[i]
 *                 self.mat.values[i] *= factors_l[k2]
 *     def scale_rows(self, factors):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t k
 *         cdef double factor
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.scale_rows", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1284
 *             for i from off1<=i<off2:
 *                 self.mat.values[i] *= factor
 *     def left_marginals(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 *         marginals_l=numpy.zeros(self.mat.num_rows,numpy.float64)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_47left_marginals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_47left_marginals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("left_marginals (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_46left_marginals(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_46left_marginals(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self) {
  PyArrayObject *__pyx_v_marginals_l = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_l;
  __Pyx_Buffer __pyx_pybuffer_marginals_l;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("left_marginals", 0);
  __pyx_pybuffer_marginals_l.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_l.refcount = 0;
  __pyx_pybuffernd_marginals_l.data = NULL;
  __pyx_pybuffernd_marginals_l.rcbuffer = &__pyx_pybuffer_marginals_l;

  /* "lurrn/sparsmat.pyx":1286
 *     def left_marginals(self):
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 *         marginals_l=numpy.zeros(self.mat.num_rows,numpy.float64)             # <<<<<<<<<<<<<<
 *         self.mat.compute_left_marginals(<double *> marginals_l.data)
 *         return marginals_l
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_coordinate_t(__pyx_v_self->mat->num_rows); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_l, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_marginals_l.diminfo[0].strides = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_l.diminfo[0].shape = __pyx_pybuffernd_marginals_l.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __pyx_v_marginals_l = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1287
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 *         marginals_l=numpy.zeros(self.mat.num_rows,numpy.float64)
 *         self.mat.compute_left_marginals(<double *> marginals_l.data)             # <<<<<<<<<<<<<<
 *         return marginals_l
 *     def right_marginals(self):
 */
  __pyx_v_self->mat->compute_left_marginals(((double *)__pyx_v_marginals_l->data));

  /* "lurrn/sparsmat.pyx":1288
 *         marginals_l=numpy.zeros(self.mat.num_rows,numpy.float64)
 *         self.mat.compute_left_marginals(<double *> marginals_l.data)
 *         return marginals_l             # <<<<<<<<<<<<<<
 *     def right_marginals(self):
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_r
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_marginals_l));
  __pyx_r = ((PyObject *)__pyx_v_marginals_l);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1284
 *             for i from off1<=i<off2:
 *                 self.mat.values[i] *= factor
 *     def left_marginals(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_l
 *         marginals_l=numpy.zeros(self.mat.num_rows,numpy.float64)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.left_marginals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_l.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_l);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1289
 *         self.mat.compute_left_marginals(<double *> marginals_l.data)
 *         return marginals_l
 *     def right_marginals(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float64)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_49right_marginals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_49right_marginals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("right_marginals (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_48right_marginals(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_48right_marginals(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self) {
  PyArrayObject *__pyx_v_marginals_r = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_r;
  __Pyx_Buffer __pyx_pybuffer_marginals_r;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("right_marginals", 0);
  __pyx_pybuffer_marginals_r.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_r.refcount = 0;
  __pyx_pybuffernd_marginals_r.data = NULL;
  __pyx_pybuffernd_marginals_r.rcbuffer = &__pyx_pybuffer_marginals_r;

  /* "lurrn/sparsmat.pyx":1291
 *     def right_marginals(self):
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float64)             # <<<<<<<<<<<<<<
 *         self.mat.compute_right_marginals(<double *> marginals_r.data)
 *         return marginals_r
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_long((((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0) + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_r, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_marginals_r.diminfo[0].strides = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_r.diminfo[0].shape = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __pyx_v_marginals_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1292
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float64)
 *         self.mat.compute_right_marginals(<double *> marginals_r.data)             # <<<<<<<<<<<<<<
 *         return marginals_r
 *     def right_squared_marginals(self):
 */
  __pyx_v_self->mat->compute_right_marginals(((double *)__pyx_v_marginals_r->data));

  /* "lurrn/sparsmat.pyx":1293
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float64)
 *         self.mat.compute_right_marginals(<double *> marginals_r.data)
 *         return marginals_r             # <<<<<<<<<<<<<<
 *     def right_squared_marginals(self):
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_r
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_marginals_r));
  __pyx_r = ((PyObject *)__pyx_v_marginals_r);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1289
 *         self.mat.compute_left_marginals(<double *> marginals_l.data)
 *         return marginals_l
 *     def right_marginals(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float64)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.right_marginals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_r);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1294
 *         self.mat.compute_right_marginals(<double *> marginals_r.data)
 *         return marginals_r
 *     def right_squared_marginals(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float64)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_51right_squared_marginals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_51right_squared_marginals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("right_squared_marginals (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_50right_squared_marginals(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_50right_squared_marginals(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self) {
  PyArrayObject *__pyx_v_marginals_r = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_marginals_r;
  __Pyx_Buffer __pyx_pybuffer_marginals_r;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("right_squared_marginals", 0);
  __pyx_pybuffer_marginals_r.pybuffer.buf = NULL;
  __pyx_pybuffer_marginals_r.refcount = 0;
  __pyx_pybuffernd_marginals_r.data = NULL;
  __pyx_pybuffernd_marginals_r.rcbuffer = &__pyx_pybuffer_marginals_r;

  /* "lurrn/sparsmat.pyx":1296
 *     def right_squared_marginals(self):
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float64)             # <<<<<<<<<<<<<<
 *         self.mat.compute_right_squared_marginals(<double *> marginals_r.data)
 *         return marginals_r
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_long((((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0) + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer, (PyObject*)__pyx_v_marginals_r, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_marginals_r.diminfo[0].strides = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_marginals_r.diminfo[0].shape = __pyx_pybuffernd_marginals_r.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __pyx_v_marginals_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1297
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float64)
 *         self.mat.compute_right_squared_marginals(<double *> marginals_r.data)             # <<<<<<<<<<<<<<
 *         return marginals_r
 *     cpdef double get_count(self,coordinate_t k, coordinate_t k2):
 */
  __pyx_v_self->mat->compute_right_squared_marginals(((double *)__pyx_v_marginals_r->data));

  /* "lurrn/sparsmat.pyx":1298
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float64)
 *         self.mat.compute_right_squared_marginals(<double *> marginals_r.data)
 *         return marginals_r             # <<<<<<<<<<<<<<
 *     cpdef double get_count(self,coordinate_t k, coordinate_t k2):
 *         if k<0 or k>=self.mat.num_rows:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_marginals_r));
  __pyx_r = ((PyObject *)__pyx_v_marginals_r);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1294
 *         self.mat.compute_right_marginals(<double *> marginals_r.data)
 *         return marginals_r
 *     def right_squared_marginals(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] marginals_r
 *         marginals_r=numpy.zeros(self.get_maxcol()+1,numpy.float64)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.right_squared_marginals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_marginals_r.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_marginals_r);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1299
 *         self.mat.compute_right_squared_marginals(<double *> marginals_r.data)
 *         return marginals_r
 *     cpdef double get_count(self,coordinate_t k, coordinate_t k2):             # <<<<<<<<<<<<<<
 *         if k<0 or k>=self.mat.num_rows:
 *             return 0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_53get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_10CSRMatrixD_get_count(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, coordinate_t __pyx_v_k, coordinate_t __pyx_v_k2, int __pyx_skip_dispatch) {
  int __pyx_v_lo;
  int __pyx_v_hi;
  int __pyx_v_mi;
  coordinate_t __pyx_v_a_mi;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  double __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_53get_count)) {
      __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_5 = __pyx_t_1; __pyx_t_6 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_7 = 1;
        }
      }
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_6) {
        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_9;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1300
 *         return marginals_r
 *     cpdef double get_count(self,coordinate_t k, coordinate_t k2):
 *         if k<0 or k>=self.mat.num_rows:             # <<<<<<<<<<<<<<
 *             return 0
 *         assert k<self.mat.num_rows
 */
  __pyx_t_11 = ((__pyx_v_k < 0) != 0);
  if (!__pyx_t_11) {
  } else {
    __pyx_t_10 = __pyx_t_11;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_11 = ((__pyx_v_k >= __pyx_v_self->mat->num_rows) != 0);
  __pyx_t_10 = __pyx_t_11;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_10) {

    /* "lurrn/sparsmat.pyx":1301
 *     cpdef double get_count(self,coordinate_t k, coordinate_t k2):
 *         if k<0 or k>=self.mat.num_rows:
 *             return 0             # <<<<<<<<<<<<<<
 *         assert k<self.mat.num_rows
 *         cdef int lo=self.mat.offsets[k]
 */
    __pyx_r = 0.0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1302
 *         if k<0 or k>=self.mat.num_rows:
 *             return 0
 *         assert k<self.mat.num_rows             # <<<<<<<<<<<<<<
 *         cdef int lo=self.mat.offsets[k]
 *         cdef int hi=self.mat.offsets[k+1]
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_k < __pyx_v_self->mat->num_rows) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":1303
 *             return 0
 *         assert k<self.mat.num_rows
 *         cdef int lo=self.mat.offsets[k]             # <<<<<<<<<<<<<<
 *         cdef int hi=self.mat.offsets[k+1]
 *         cdef int mi
 */
  __pyx_v_lo = (__pyx_v_self->mat->offsets[__pyx_v_k]);

  /* "lurrn/sparsmat.pyx":1304
 *         assert k<self.mat.num_rows
 *         cdef int lo=self.mat.offsets[k]
 *         cdef int hi=self.mat.offsets[k+1]             # <<<<<<<<<<<<<<
 *         cdef int mi
 *         cdef coordinate_t a_mi
 */
  __pyx_v_hi = (__pyx_v_self->mat->offsets[(__pyx_v_k + 1)]);

  /* "lurrn/sparsmat.pyx":1307
 *         cdef int mi
 *         cdef coordinate_t a_mi
 *         if hi==lo: return 0             # <<<<<<<<<<<<<<
 *         while hi-lo>1:
 *             mi=(hi+lo)//2
 */
  __pyx_t_10 = ((__pyx_v_hi == __pyx_v_lo) != 0);
  if (__pyx_t_10) {
    __pyx_r = 0.0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1308
 *         cdef coordinate_t a_mi
 *         if hi==lo: return 0
 *         while hi-lo>1:             # <<<<<<<<<<<<<<
 *             mi=(hi+lo)//2
 *             a_mi=self.mat.rightColumns[mi]
 */
  while (1) {
    __pyx_t_10 = (((__pyx_v_hi - __pyx_v_lo) > 1) != 0);
    if (!__pyx_t_10) break;

    /* "lurrn/sparsmat.pyx":1309
 *         if hi==lo: return 0
 *         while hi-lo>1:
 *             mi=(hi+lo)//2             # <<<<<<<<<<<<<<
 *             a_mi=self.mat.rightColumns[mi]
 *             if a_mi>k2:
 */
    __pyx_v_mi = __Pyx_div_long((__pyx_v_hi + __pyx_v_lo), 2);

    /* "lurrn/sparsmat.pyx":1310
 *         while hi-lo>1:
 *             mi=(hi+lo)//2
 *             a_mi=self.mat.rightColumns[mi]             # <<<<<<<<<<<<<<
 *             if a_mi>k2:
 *                 hi=mi
 */
    __pyx_v_a_mi = (__pyx_v_self->mat->rightColumns[__pyx_v_mi]);

    /* "lurrn/sparsmat.pyx":1311
 *             mi=(hi+lo)//2
 *             a_mi=self.mat.rightColumns[mi]
 *             if a_mi>k2:             # <<<<<<<<<<<<<<
 *                 hi=mi
 *             elif a_mi==k2:
 */
    __pyx_t_10 = ((__pyx_v_a_mi > __pyx_v_k2) != 0);
    if (__pyx_t_10) {

      /* "lurrn/sparsmat.pyx":1312
 *             a_mi=self.mat.rightColumns[mi]
 *             if a_mi>k2:
 *                 hi=mi             # <<<<<<<<<<<<<<
 *             elif a_mi==k2:
 *                 return self.mat.values[mi]
 */
      __pyx_v_hi = __pyx_v_mi;
      goto __pyx_L9;
    }

    /* "lurrn/sparsmat.pyx":1313
 *             if a_mi>k2:
 *                 hi=mi
 *             elif a_mi==k2:             # <<<<<<<<<<<<<<
 *                 return self.mat.values[mi]
 *             else:
 */
    __pyx_t_10 = ((__pyx_v_a_mi == __pyx_v_k2) != 0);
    if (__pyx_t_10) {

      /* "lurrn/sparsmat.pyx":1314
 *                 hi=mi
 *             elif a_mi==k2:
 *                 return self.mat.values[mi]             # <<<<<<<<<<<<<<
 *             else:
 *                 lo=mi+1
 */
      __pyx_r = (__pyx_v_self->mat->values[__pyx_v_mi]);
      goto __pyx_L0;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":1316
 *                 return self.mat.values[mi]
 *             else:
 *                 lo=mi+1             # <<<<<<<<<<<<<<
 *         if self.mat.rightColumns[lo]==k2:
 *             return self.mat.values[lo]
 */
      __pyx_v_lo = (__pyx_v_mi + 1);
    }
    __pyx_L9:;
  }

  /* "lurrn/sparsmat.pyx":1317
 *             else:
 *                 lo=mi+1
 *         if self.mat.rightColumns[lo]==k2:             # <<<<<<<<<<<<<<
 *             return self.mat.values[lo]
 *         return 0
 */
  __pyx_t_10 = (((__pyx_v_self->mat->rightColumns[__pyx_v_lo]) == __pyx_v_k2) != 0);
  if (__pyx_t_10) {

    /* "lurrn/sparsmat.pyx":1318
 *                 lo=mi+1
 *         if self.mat.rightColumns[lo]==k2:
 *             return self.mat.values[lo]             # <<<<<<<<<<<<<<
 *         return 0
 *     def write_binary(self,f):
 */
    __pyx_r = (__pyx_v_self->mat->values[__pyx_v_lo]);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1319
 *         if self.mat.rightColumns[lo]==k2:
 *             return self.mat.values[lo]
 *         return 0             # <<<<<<<<<<<<<<
 *     def write_binary(self,f):
 *         """writes the matrix in binary format"""
 */
  __pyx_r = 0.0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1299
 *         self.mat.compute_right_squared_marginals(<double *> marginals_r.data)
 *         return marginals_r
 *     cpdef double get_count(self,coordinate_t k, coordinate_t k2):             # <<<<<<<<<<<<<<
 *         if k<0 or k>=self.mat.num_rows:
 *             return 0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_WriteUnraisable("lurrn.sparsmat.CSRMatrixD.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_53get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_53get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_k2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_k2,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_count", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k2 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k2 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_count", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_52get_count(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self), __pyx_v_k, __pyx_v_k2);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_52get_count(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, coordinate_t __pyx_v_k, coordinate_t __pyx_v_k2) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_get_count(__pyx_v_self, __pyx_v_k, __pyx_v_k2, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1320
 *             return self.mat.values[lo]
 *         return 0
 *     def write_binary(self,f):             # <<<<<<<<<<<<<<
 *         """writes the matrix in binary format"""
 *         cdef int fileno=f.fileno()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_55write_binary(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static char __pyx_doc_5lurrn_8sparsmat_10CSRMatrixD_54write_binary[] = "writes the matrix in binary format";
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_55write_binary(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_binary (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_54write_binary(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_54write_binary(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, PyObject *__pyx_v_f) {
  int __pyx_v_fileno;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("write_binary", 0);

  /* "lurrn/sparsmat.pyx":1322
 *     def write_binary(self,f):
 *         """writes the matrix in binary format"""
 *         cdef int fileno=f.fileno()             # <<<<<<<<<<<<<<
 *         self.mat.write_binary(fileno)
 *     def transpose(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_fileno); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_fileno = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":1323
 *         """writes the matrix in binary format"""
 *         cdef int fileno=f.fileno()
 *         self.mat.write_binary(fileno)             # <<<<<<<<<<<<<<
 *     def transpose(self):
 *         cdef c_CSRMatrixD *matC=self.mat.transpose()
 */
  __pyx_v_self->mat->write_binary(__pyx_v_fileno);

  /* "lurrn/sparsmat.pyx":1320
 *             return self.mat.values[lo]
 *         return 0
 *     def write_binary(self,f):             # <<<<<<<<<<<<<<
 *         """writes the matrix in binary format"""
 *         cdef int fileno=f.fileno()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.write_binary", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1324
 *         cdef int fileno=f.fileno()
 *         self.mat.write_binary(fileno)
 *     def transpose(self):             # <<<<<<<<<<<<<<
 *         cdef c_CSRMatrixD *matC=self.mat.transpose()
 *         cdef CSRMatrixD mat=CSRMatrixD()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_57transpose(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_57transpose(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("transpose (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_56transpose(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_56transpose(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self) {
  struct CSRMatrix<double> *__pyx_v_matC;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_mat = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transpose", 0);

  /* "lurrn/sparsmat.pyx":1325
 *         self.mat.write_binary(fileno)
 *     def transpose(self):
 *         cdef c_CSRMatrixD *matC=self.mat.transpose()             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixD mat=CSRMatrixD()
 *         mat.set_matrix(matC)
 */
  __pyx_v_matC = __pyx_v_self->mat->transpose();

  /* "lurrn/sparsmat.pyx":1326
 *     def transpose(self):
 *         cdef c_CSRMatrixD *matC=self.mat.transpose()
 *         cdef CSRMatrixD mat=CSRMatrixD()             # <<<<<<<<<<<<<<
 *         mat.set_matrix(matC)
 *         return mat
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixD)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_mat = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1327
 *         cdef c_CSRMatrixD *matC=self.mat.transpose()
 *         cdef CSRMatrixD mat=CSRMatrixD()
 *         mat.set_matrix(matC)             # <<<<<<<<<<<<<<
 *         return mat
 *     def __add__(self,other):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_mat->__pyx_vtab)->set_matrix(__pyx_v_mat, __pyx_v_matC);

  /* "lurrn/sparsmat.pyx":1328
 *         cdef CSRMatrixD mat=CSRMatrixD()
 *         mat.set_matrix(matC)
 *         return mat             # <<<<<<<<<<<<<<
 *     def __add__(self,other):
 *         cdef CSRMatrixD mat1
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_mat));
  __pyx_r = ((PyObject *)__pyx_v_mat);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1324
 *         cdef int fileno=f.fileno()
 *         self.mat.write_binary(fileno)
 *     def transpose(self):             # <<<<<<<<<<<<<<
 *         cdef c_CSRMatrixD *matC=self.mat.transpose()
 *         cdef CSRMatrixD mat=CSRMatrixD()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.transpose", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mat);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1329
 *         mat.set_matrix(matC)
 *         return mat
 *     def __add__(self,other):             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixD mat1
 *         cdef CSRMatrixD mat2
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_59__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_59__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_58__add__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_58__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_mat1 = 0;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_mat2 = 0;
  struct CSRMatrix<double> *__pyx_v_matC;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_mat = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":1333
 *         cdef CSRMatrixD mat2
 *         cdef c_CSRMatrixD *matC
 *         mat1=self             # <<<<<<<<<<<<<<
 *         mat2=other
 *         matC=add_csrD(mat1.mat,mat2.mat)
 */
  if (!(likely(((__pyx_v_self) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_self, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_self;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_mat1 = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1334
 *         cdef c_CSRMatrixD *matC
 *         mat1=self
 *         mat2=other             # <<<<<<<<<<<<<<
 *         matC=add_csrD(mat1.mat,mat2.mat)
 *         cdef CSRMatrixD mat=CSRMatrixD()
 */
  if (!(likely(((__pyx_v_other) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_other, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_other;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_mat2 = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1335
 *         mat1=self
 *         mat2=other
 *         matC=add_csrD(mat1.mat,mat2.mat)             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixD mat=CSRMatrixD()
 *         mat.set_matrix(matC)
 */
  __pyx_v_matC = add_csr(__pyx_v_mat1->mat, __pyx_v_mat2->mat);

  /* "lurrn/sparsmat.pyx":1336
 *         mat2=other
 *         matC=add_csrD(mat1.mat,mat2.mat)
 *         cdef CSRMatrixD mat=CSRMatrixD()             # <<<<<<<<<<<<<<
 *         mat.set_matrix(matC)
 *         return mat
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixD)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_mat = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1337
 *         matC=add_csrD(mat1.mat,mat2.mat)
 *         cdef CSRMatrixD mat=CSRMatrixD()
 *         mat.set_matrix(matC)             # <<<<<<<<<<<<<<
 *         return mat
 *     def __dealloc__(self):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_mat->__pyx_vtab)->set_matrix(__pyx_v_mat, __pyx_v_matC);

  /* "lurrn/sparsmat.pyx":1338
 *         cdef CSRMatrixD mat=CSRMatrixD()
 *         mat.set_matrix(matC)
 *         return mat             # <<<<<<<<<<<<<<
 *     def __dealloc__(self):
 *         if self.mat!=NULL:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_mat));
  __pyx_r = ((PyObject *)__pyx_v_mat);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1329
 *         mat.set_matrix(matC)
 *         return mat
 *     def __add__(self,other):             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixD mat1
 *         cdef CSRMatrixD mat2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mat1);
  __Pyx_XDECREF((PyObject *)__pyx_v_mat2);
  __Pyx_XDECREF((PyObject *)__pyx_v_mat);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1339
 *         mat.set_matrix(matC)
 *         return mat
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.mat!=NULL:
 *             if self.buf is not None:
 */

/* Python wrapper */
static void __pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_61__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_61__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_60__dealloc__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_60__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lurrn/sparsmat.pyx":1340
 *         return mat
 *     def __dealloc__(self):
 *         if self.mat!=NULL:             # <<<<<<<<<<<<<<
 *             if self.buf is not None:
 *                 self.buf=None
 */
  __pyx_t_1 = ((__pyx_v_self->mat != NULL) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":1341
 *     def __dealloc__(self):
 *         if self.mat!=NULL:
 *             if self.buf is not None:             # <<<<<<<<<<<<<<
 *                 self.buf=None
 *             else:
 */
    __pyx_t_1 = (__pyx_v_self->buf != Py_None);
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":1342
 *         if self.mat!=NULL:
 *             if self.buf is not None:
 *                 self.buf=None             # <<<<<<<<<<<<<<
 *             else:
 *                 cxx_deleteA(self.mat.offsets)
 */
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      __Pyx_GOTREF(__pyx_v_self->buf);
      __Pyx_DECREF(__pyx_v_self->buf);
      __pyx_v_self->buf = Py_None;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":1344
 *                 self.buf=None
 *             else:
 *                 cxx_deleteA(self.mat.offsets)             # <<<<<<<<<<<<<<
 *                 if (self.mat.rightColumns!=NULL):
 *                     cxx_deleteA(self.mat.rightColumns)
 */
      delete [](__pyx_v_self->mat->offsets);

      /* "lurrn/sparsmat.pyx":1345
 *             else:
 *                 cxx_deleteA(self.mat.offsets)
 *                 if (self.mat.rightColumns!=NULL):             # <<<<<<<<<<<<<<
 *                     cxx_deleteA(self.mat.rightColumns)
 *                     cxx_deleteA(self.mat.values)
 */
      __pyx_t_2 = ((__pyx_v_self->mat->rightColumns != NULL) != 0);
      if (__pyx_t_2) {

        /* "lurrn/sparsmat.pyx":1346
 *                 cxx_deleteA(self.mat.offsets)
 *                 if (self.mat.rightColumns!=NULL):
 *                     cxx_deleteA(self.mat.rightColumns)             # <<<<<<<<<<<<<<
 *                     cxx_deleteA(self.mat.values)
 *             cxx_delete(self.mat)
 */
        delete [](__pyx_v_self->mat->rightColumns);

        /* "lurrn/sparsmat.pyx":1347
 *                 if (self.mat.rightColumns!=NULL):
 *                     cxx_deleteA(self.mat.rightColumns)
 *                     cxx_deleteA(self.mat.values)             # <<<<<<<<<<<<<<
 *             cxx_delete(self.mat)
 *     def __reduce__(self):
 */
        delete [](__pyx_v_self->mat->values);
        goto __pyx_L5;
      }
      __pyx_L5:;
    }
    __pyx_L4:;

    /* "lurrn/sparsmat.pyx":1348
 *                     cxx_deleteA(self.mat.rightColumns)
 *                     cxx_deleteA(self.mat.values)
 *             cxx_delete(self.mat)             # <<<<<<<<<<<<<<
 *     def __reduce__(self):
 *         # choose compatibility over performance.
 */
    delete(__pyx_v_self->mat);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":1339
 *         mat.set_matrix(matC)
 *         return mat
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.mat!=NULL:
 *             if self.buf is not None:
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":1349
 *                     cxx_deleteA(self.mat.values)
 *             cxx_delete(self.mat)
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         # choose compatibility over performance.
 *         cdef VecD2 tmp=VecD2()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_63__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_63__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_62__reduce__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_62__reduce__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self) {
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "lurrn/sparsmat.pyx":1351
 *     def __reduce__(self):
 *         # choose compatibility over performance.
 *         cdef VecD2 tmp=VecD2()             # <<<<<<<<<<<<<<
 *         tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         tmp.extend(self.item_iter())
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1352
 *         # choose compatibility over performance.
 *         cdef VecD2 tmp=VecD2()
 *         tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])             # <<<<<<<<<<<<<<
 *         tmp.extend(self.item_iter())
 *         return (CSRMatrixD,(),tmp)
 */
  __pyx_v_tmp->vec.reserve((__pyx_v_self->mat->offsets[__pyx_v_self->mat->num_rows]));

  /* "lurrn/sparsmat.pyx":1353
 *         cdef VecD2 tmp=VecD2()
 *         tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         tmp.extend(self.item_iter())             # <<<<<<<<<<<<<<
 *         return (CSRMatrixD,(),tmp)
 *     def __setstate__(self,VecD2 tmp):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tmp), __pyx_n_s_extend); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1354
 *         tmp.vec.reserve(self.mat.offsets[self.mat.num_rows])
 *         tmp.extend(self.item_iter())
 *         return (CSRMatrixD,(),tmp)             # <<<<<<<<<<<<<<
 *     def __setstate__(self,VecD2 tmp):
 *         tmp.ensure_compact()
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixD)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixD)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixD)));
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  __Pyx_INCREF(((PyObject *)__pyx_v_tmp));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_tmp));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_tmp));
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1349
 *                     cxx_deleteA(self.mat.values)
 *             cxx_delete(self.mat)
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         # choose compatibility over performance.
 *         cdef VecD2 tmp=VecD2()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1355
 *         tmp.extend(self.item_iter())
 *         return (CSRMatrixD,(),tmp)
 *     def __setstate__(self,VecD2 tmp):             # <<<<<<<<<<<<<<
 *         tmp.ensure_compact()
 *         self.set_matrix(vec2csrD(&tmp.vec))
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_65__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_tmp); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_65__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_tmp) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tmp), __pyx_ptype_5lurrn_8sparsmat_VecD2, 1, "tmp", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_64__setstate__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10CSRMatrixD_64__setstate__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_tmp) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* "lurrn/sparsmat.pyx":1356
 *         return (CSRMatrixD,(),tmp)
 *     def __setstate__(self,VecD2 tmp):
 *         tmp.ensure_compact()             # <<<<<<<<<<<<<<
 *         self.set_matrix(vec2csrD(&tmp.vec))
 * 
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_tmp->__pyx_vtab)->ensure_compact(__pyx_v_tmp);

  /* "lurrn/sparsmat.pyx":1357
 *     def __setstate__(self,VecD2 tmp):
 *         tmp.ensure_compact()
 *         self.set_matrix(vec2csrD(&tmp.vec))             # <<<<<<<<<<<<<<
 * 
 * cdef class CSRMatrixD_item_iter:
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_self->__pyx_vtab)->set_matrix(__pyx_v_self, vec2csr((&__pyx_v_tmp->vec)));

  /* "lurrn/sparsmat.pyx":1355
 *         tmp.extend(self.item_iter())
 *         return (CSRMatrixD,(),tmp)
 *     def __setstate__(self,VecD2 tmp):             # <<<<<<<<<<<<<<
 *         tmp.ensure_compact()
 *         self.set_matrix(vec2csrD(&tmp.vec))
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1364
 *     cdef coordinate_t k
 *     cdef int off
 *     def __init__(self, mat):             # <<<<<<<<<<<<<<
 *         self.mat=mat
 *         self.matC=self.mat.mat
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_20CSRMatrixD_item_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_20CSRMatrixD_item_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_mat = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mat,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mat)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_mat = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD_item_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_20CSRMatrixD_item_iter___init__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter *)__pyx_v_self), __pyx_v_mat);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_20CSRMatrixD_item_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter *__pyx_v_self, PyObject *__pyx_v_mat) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct CSRMatrix<double> *__pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":1365
 *     cdef int off
 *     def __init__(self, mat):
 *         self.mat=mat             # <<<<<<<<<<<<<<
 *         self.matC=self.mat.mat
 *         self.k=0
 */
  if (!(likely(((__pyx_v_mat) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_mat, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_mat;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->mat);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->mat));
  __pyx_v_self->mat = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1366
 *     def __init__(self, mat):
 *         self.mat=mat
 *         self.matC=self.mat.mat             # <<<<<<<<<<<<<<
 *         self.k=0
 *         self.off=0
 */
  __pyx_t_2 = __pyx_v_self->mat->mat;
  __pyx_v_self->matC = __pyx_t_2;

  /* "lurrn/sparsmat.pyx":1367
 *         self.mat=mat
 *         self.matC=self.mat.mat
 *         self.k=0             # <<<<<<<<<<<<<<
 *         self.off=0
 *     def __iter__(self):
 */
  __pyx_v_self->k = 0;

  /* "lurrn/sparsmat.pyx":1368
 *         self.matC=self.mat.mat
 *         self.k=0
 *         self.off=0             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self
 */
  __pyx_v_self->off = 0;

  /* "lurrn/sparsmat.pyx":1364
 *     cdef coordinate_t k
 *     cdef int off
 *     def __init__(self, mat):             # <<<<<<<<<<<<<<
 *         self.mat=mat
 *         self.matC=self.mat.mat
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD_item_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1369
 *         self.k=0
 *         self.off=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_20CSRMatrixD_item_iter_3__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_20CSRMatrixD_item_iter_3__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_20CSRMatrixD_item_iter_2__iter__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_20CSRMatrixD_item_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":1370
 *         self.off=0
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 *     def __next__(self):
 *         while self.off==self.matC.offsets[self.k+1]:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1369
 *         self.k=0
 *         self.off=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1371
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         while self.off==self.matC.offsets[self.k+1]:
 *             self.k+=1
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_20CSRMatrixD_item_iter_5__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_20CSRMatrixD_item_iter_5__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_20CSRMatrixD_item_iter_4__next__(((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_20CSRMatrixD_item_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter *__pyx_v_self) {
  PyObject *__pyx_v_res = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "lurrn/sparsmat.pyx":1372
 *         return self
 *     def __next__(self):
 *         while self.off==self.matC.offsets[self.k+1]:             # <<<<<<<<<<<<<<
 *             self.k+=1
 *             if self.k>=self.matC.num_rows:
 */
  while (1) {
    __pyx_t_1 = ((__pyx_v_self->off == (__pyx_v_self->matC->offsets[(__pyx_v_self->k + 1)])) != 0);
    if (!__pyx_t_1) break;

    /* "lurrn/sparsmat.pyx":1373
 *     def __next__(self):
 *         while self.off==self.matC.offsets[self.k+1]:
 *             self.k+=1             # <<<<<<<<<<<<<<
 *             if self.k>=self.matC.num_rows:
 *                 raise StopIteration
 */
    __pyx_v_self->k = (__pyx_v_self->k + 1);

    /* "lurrn/sparsmat.pyx":1374
 *         while self.off==self.matC.offsets[self.k+1]:
 *             self.k+=1
 *             if self.k>=self.matC.num_rows:             # <<<<<<<<<<<<<<
 *                 raise StopIteration
 *         res=(self.k,
 */
    __pyx_t_1 = ((__pyx_v_self->k >= __pyx_v_self->matC->num_rows) != 0);
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":1375
 *             self.k+=1
 *             if self.k>=self.matC.num_rows:
 *                 raise StopIteration             # <<<<<<<<<<<<<<
 *         res=(self.k,
 *              self.matC.rightColumns[self.off],
 */
      __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }

  /* "lurrn/sparsmat.pyx":1376
 *             if self.k>=self.matC.num_rows:
 *                 raise StopIteration
 *         res=(self.k,             # <<<<<<<<<<<<<<
 *              self.matC.rightColumns[self.off],
 *              self.matC.values[self.off])
 */
  __pyx_t_2 = __Pyx_PyInt_From_coordinate_t(__pyx_v_self->k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "lurrn/sparsmat.pyx":1377
 *                 raise StopIteration
 *         res=(self.k,
 *              self.matC.rightColumns[self.off],             # <<<<<<<<<<<<<<
 *              self.matC.values[self.off])
 *         self.off+=1
 */
  __pyx_t_3 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->matC->rightColumns[__pyx_v_self->off])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "lurrn/sparsmat.pyx":1378
 *         res=(self.k,
 *              self.matC.rightColumns[self.off],
 *              self.matC.values[self.off])             # <<<<<<<<<<<<<<
 *         self.off+=1
 *         return res
 */
  __pyx_t_4 = PyFloat_FromDouble((__pyx_v_self->matC->values[__pyx_v_self->off])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":1376
 *             if self.k>=self.matC.num_rows:
 *                 raise StopIteration
 *         res=(self.k,             # <<<<<<<<<<<<<<
 *              self.matC.rightColumns[self.off],
 *              self.matC.values[self.off])
 */
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_v_res = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "lurrn/sparsmat.pyx":1379
 *              self.matC.rightColumns[self.off],
 *              self.matC.values[self.off])
 *         self.off+=1             # <<<<<<<<<<<<<<
 *         return res
 * 
 */
  __pyx_v_self->off = (__pyx_v_self->off + 1);

  /* "lurrn/sparsmat.pyx":1380
 *              self.matC.values[self.off])
 *         self.off+=1
 *         return res             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_res);
  __pyx_r = __pyx_v_res;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1371
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         while self.off==self.matC.offsets[self.k+1]:
 *             self.k+=1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.CSRMatrixD_item_iter.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_res);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1384
 * 
 * 
 * def csrFromBuffer(object buf):             # <<<<<<<<<<<<<<
 *     """takes an object conforming to the Buffer protocol and
 *     creates a CSR matrix from that."""
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_1csrFromBuffer(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static char __pyx_doc_5lurrn_8sparsmat_csrFromBuffer[] = "takes an object conforming to the Buffer protocol and\n    creates a CSR matrix from that.";
static PyMethodDef __pyx_mdef_5lurrn_8sparsmat_1csrFromBuffer = {"csrFromBuffer", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_1csrFromBuffer, METH_O, __pyx_doc_5lurrn_8sparsmat_csrFromBuffer};
static PyObject *__pyx_pw_5lurrn_8sparsmat_1csrFromBuffer(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("csrFromBuffer (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_csrFromBuffer(__pyx_self, ((PyObject *)__pyx_v_buf));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_csrFromBuffer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  const char* __pyx_v_buffer;
  Py_ssize_t __pyx_v_buffer_len;
  int *__pyx_v_tmp;
  struct CSRMatrix<int> *__pyx_v_c_matI;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_matI = 0;
  struct CSRMatrix<float> *__pyx_v_c_matF;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_matF = 0;
  struct CSRMatrix<double> *__pyx_v_c_matD;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_matD = 0;
  int __pyx_v_result;
  PyObject *__pyx_v_tcode = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("csrFromBuffer", 0);

  /* "lurrn/sparsmat.pyx":1389
 *     cdef const_char_ptr buffer
 *     cdef Py_ssize_t buffer_len
 *     PyObject_AsCharBuffer(buf,&buffer,&buffer_len)             # <<<<<<<<<<<<<<
 *     cdef int *tmp=<int *>buffer
 *     cdef c_CSRMatrixI *c_matI
 */
  __pyx_t_1 = PyObject_AsCharBuffer(__pyx_v_buf, (&__pyx_v_buffer), (&__pyx_v_buffer_len)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lurrn/sparsmat.pyx":1390
 *     cdef Py_ssize_t buffer_len
 *     PyObject_AsCharBuffer(buf,&buffer,&buffer_len)
 *     cdef int *tmp=<int *>buffer             # <<<<<<<<<<<<<<
 *     cdef c_CSRMatrixI *c_matI
 *     cdef CSRMatrixI matI
 */
  __pyx_v_tmp = ((int *)__pyx_v_buffer);

  /* "lurrn/sparsmat.pyx":1397
 *     cdef c_CSRMatrixD *c_matD
 *     cdef CSRMatrixD matD
 *     if tmp[1]&0xff==c'I':             # <<<<<<<<<<<<<<
 *         c_matI=new_CSRMatrixI()
 *         result=csrFromBufferI(<void *>buffer,c_matI)
 */
  __pyx_t_2 = ((((__pyx_v_tmp[1]) & 0xff) == 'I') != 0);
  if (__pyx_t_2) {

    /* "lurrn/sparsmat.pyx":1398
 *     cdef CSRMatrixD matD
 *     if tmp[1]&0xff==c'I':
 *         c_matI=new_CSRMatrixI()             # <<<<<<<<<<<<<<
 *         result=csrFromBufferI(<void *>buffer,c_matI)
 *         if result==-1:
 */
    __pyx_v_c_matI = new CSRMatrix<int>();

    /* "lurrn/sparsmat.pyx":1399
 *     if tmp[1]&0xff==c'I':
 *         c_matI=new_CSRMatrixI()
 *         result=csrFromBufferI(<void *>buffer,c_matI)             # <<<<<<<<<<<<<<
 *         if result==-1:
 *             raise ValueError
 */
    __pyx_v_result = csrFromBuffer(((void *)__pyx_v_buffer), __pyx_v_c_matI);

    /* "lurrn/sparsmat.pyx":1400
 *         c_matI=new_CSRMatrixI()
 *         result=csrFromBufferI(<void *>buffer,c_matI)
 *         if result==-1:             # <<<<<<<<<<<<<<
 *             raise ValueError
 *         matI=CSRMatrixI()
 */
    __pyx_t_2 = ((__pyx_v_result == -1) != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":1401
 *         result=csrFromBufferI(<void *>buffer,c_matI)
 *         if result==-1:
 *             raise ValueError             # <<<<<<<<<<<<<<
 *         matI=CSRMatrixI()
 *         matI.set_matrix(c_matI)
 */
      __Pyx_Raise(__pyx_builtin_ValueError, 0, 0, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "lurrn/sparsmat.pyx":1402
 *         if result==-1:
 *             raise ValueError
 *         matI=CSRMatrixI()             # <<<<<<<<<<<<<<
 *         matI.set_matrix(c_matI)
 *         matI.buf=buf
 */
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixI)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_matI = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "lurrn/sparsmat.pyx":1403
 *             raise ValueError
 *         matI=CSRMatrixI()
 *         matI.set_matrix(c_matI)             # <<<<<<<<<<<<<<
 *         matI.buf=buf
 *         return matI
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_matI->__pyx_vtab)->set_matrix(__pyx_v_matI, __pyx_v_c_matI);

    /* "lurrn/sparsmat.pyx":1404
 *         matI=CSRMatrixI()
 *         matI.set_matrix(c_matI)
 *         matI.buf=buf             # <<<<<<<<<<<<<<
 *         return matI
 *     elif tmp[1]&0xff==c'F' and (tmp[1]>>24)==c'4':
 */
    __Pyx_INCREF(__pyx_v_buf);
    __Pyx_GIVEREF(__pyx_v_buf);
    __Pyx_GOTREF(__pyx_v_matI->buf);
    __Pyx_DECREF(__pyx_v_matI->buf);
    __pyx_v_matI->buf = __pyx_v_buf;

    /* "lurrn/sparsmat.pyx":1405
 *         matI.set_matrix(c_matI)
 *         matI.buf=buf
 *         return matI             # <<<<<<<<<<<<<<
 *     elif tmp[1]&0xff==c'F' and (tmp[1]>>24)==c'4':
 *         c_matF=new_CSRMatrixF()
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_matI));
    __pyx_r = ((PyObject *)__pyx_v_matI);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1406
 *         matI.buf=buf
 *         return matI
 *     elif tmp[1]&0xff==c'F' and (tmp[1]>>24)==c'4':             # <<<<<<<<<<<<<<
 *         c_matF=new_CSRMatrixF()
 *         result=csrFromBufferF(<void *>buffer,c_matF)
 */
  __pyx_t_4 = ((((__pyx_v_tmp[1]) & 0xff) == 'F') != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_4 = ((((__pyx_v_tmp[1]) >> 24) == '4') != 0);
  __pyx_t_2 = __pyx_t_4;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_2) {

    /* "lurrn/sparsmat.pyx":1407
 *         return matI
 *     elif tmp[1]&0xff==c'F' and (tmp[1]>>24)==c'4':
 *         c_matF=new_CSRMatrixF()             # <<<<<<<<<<<<<<
 *         result=csrFromBufferF(<void *>buffer,c_matF)
 *         if result==-1:
 */
    __pyx_v_c_matF = new CSRMatrix<float>();

    /* "lurrn/sparsmat.pyx":1408
 *     elif tmp[1]&0xff==c'F' and (tmp[1]>>24)==c'4':
 *         c_matF=new_CSRMatrixF()
 *         result=csrFromBufferF(<void *>buffer,c_matF)             # <<<<<<<<<<<<<<
 *         if result==-1:
 *             raise ValueError
 */
    __pyx_v_result = csrFromBuffer(((void *)__pyx_v_buffer), __pyx_v_c_matF);

    /* "lurrn/sparsmat.pyx":1409
 *         c_matF=new_CSRMatrixF()
 *         result=csrFromBufferF(<void *>buffer,c_matF)
 *         if result==-1:             # <<<<<<<<<<<<<<
 *             raise ValueError
 *         matF=CSRMatrixF()
 */
    __pyx_t_2 = ((__pyx_v_result == -1) != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":1410
 *         result=csrFromBufferF(<void *>buffer,c_matF)
 *         if result==-1:
 *             raise ValueError             # <<<<<<<<<<<<<<
 *         matF=CSRMatrixF()
 *         matF.set_matrix(c_matF)
 */
      __Pyx_Raise(__pyx_builtin_ValueError, 0, 0, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "lurrn/sparsmat.pyx":1411
 *         if result==-1:
 *             raise ValueError
 *         matF=CSRMatrixF()             # <<<<<<<<<<<<<<
 *         matF.set_matrix(c_matF)
 *         matF.buf=buf
 */
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixF)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_matF = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "lurrn/sparsmat.pyx":1412
 *             raise ValueError
 *         matF=CSRMatrixF()
 *         matF.set_matrix(c_matF)             # <<<<<<<<<<<<<<
 *         matF.buf=buf
 *         return matF
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_matF->__pyx_vtab)->set_matrix(__pyx_v_matF, __pyx_v_c_matF);

    /* "lurrn/sparsmat.pyx":1413
 *         matF=CSRMatrixF()
 *         matF.set_matrix(c_matF)
 *         matF.buf=buf             # <<<<<<<<<<<<<<
 *         return matF
 *     elif tmp[1]&0xff==c'F' and (tmp[1]>>24)==c'8':
 */
    __Pyx_INCREF(__pyx_v_buf);
    __Pyx_GIVEREF(__pyx_v_buf);
    __Pyx_GOTREF(__pyx_v_matF->buf);
    __Pyx_DECREF(__pyx_v_matF->buf);
    __pyx_v_matF->buf = __pyx_v_buf;

    /* "lurrn/sparsmat.pyx":1414
 *         matF.set_matrix(c_matF)
 *         matF.buf=buf
 *         return matF             # <<<<<<<<<<<<<<
 *     elif tmp[1]&0xff==c'F' and (tmp[1]>>24)==c'8':
 *         c_matD=new_CSRMatrixD()
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_matF));
    __pyx_r = ((PyObject *)__pyx_v_matF);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1415
 *         matF.buf=buf
 *         return matF
 *     elif tmp[1]&0xff==c'F' and (tmp[1]>>24)==c'8':             # <<<<<<<<<<<<<<
 *         c_matD=new_CSRMatrixD()
 *         result=csrFromBufferD(<void *>buffer,c_matD)
 */
  __pyx_t_4 = ((((__pyx_v_tmp[1]) & 0xff) == 'F') != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_4 = ((((__pyx_v_tmp[1]) >> 24) == '8') != 0);
  __pyx_t_2 = __pyx_t_4;
  __pyx_L8_bool_binop_done:;
  if (__pyx_t_2) {

    /* "lurrn/sparsmat.pyx":1416
 *         return matF
 *     elif tmp[1]&0xff==c'F' and (tmp[1]>>24)==c'8':
 *         c_matD=new_CSRMatrixD()             # <<<<<<<<<<<<<<
 *         result=csrFromBufferD(<void *>buffer,c_matD)
 *         if result==-1:
 */
    __pyx_v_c_matD = new CSRMatrix<double>();

    /* "lurrn/sparsmat.pyx":1417
 *     elif tmp[1]&0xff==c'F' and (tmp[1]>>24)==c'8':
 *         c_matD=new_CSRMatrixD()
 *         result=csrFromBufferD(<void *>buffer,c_matD)             # <<<<<<<<<<<<<<
 *         if result==-1:
 *             raise ValueError
 */
    __pyx_v_result = csrFromBuffer(((void *)__pyx_v_buffer), __pyx_v_c_matD);

    /* "lurrn/sparsmat.pyx":1418
 *         c_matD=new_CSRMatrixD()
 *         result=csrFromBufferD(<void *>buffer,c_matD)
 *         if result==-1:             # <<<<<<<<<<<<<<
 *             raise ValueError
 *         matD=CSRMatrixD()
 */
    __pyx_t_2 = ((__pyx_v_result == -1) != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":1419
 *         result=csrFromBufferD(<void *>buffer,c_matD)
 *         if result==-1:
 *             raise ValueError             # <<<<<<<<<<<<<<
 *         matD=CSRMatrixD()
 *         matD.set_matrix(c_matD)
 */
      __Pyx_Raise(__pyx_builtin_ValueError, 0, 0, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "lurrn/sparsmat.pyx":1420
 *         if result==-1:
 *             raise ValueError
 *         matD=CSRMatrixD()             # <<<<<<<<<<<<<<
 *         matD.set_matrix(c_matD)
 *         matD.buf=buf
 */
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixD)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_matD = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "lurrn/sparsmat.pyx":1421
 *             raise ValueError
 *         matD=CSRMatrixD()
 *         matD.set_matrix(c_matD)             # <<<<<<<<<<<<<<
 *         matD.buf=buf
 *         return matD
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_matD->__pyx_vtab)->set_matrix(__pyx_v_matD, __pyx_v_c_matD);

    /* "lurrn/sparsmat.pyx":1422
 *         matD=CSRMatrixD()
 *         matD.set_matrix(c_matD)
 *         matD.buf=buf             # <<<<<<<<<<<<<<
 *         return matD
 *     else:
 */
    __Pyx_INCREF(__pyx_v_buf);
    __Pyx_GIVEREF(__pyx_v_buf);
    __Pyx_GOTREF(__pyx_v_matD->buf);
    __Pyx_DECREF(__pyx_v_matD->buf);
    __pyx_v_matD->buf = __pyx_v_buf;

    /* "lurrn/sparsmat.pyx":1423
 *         matD.set_matrix(c_matD)
 *         matD.buf=buf
 *         return matD             # <<<<<<<<<<<<<<
 *     else:
 *         # hrm... this only works on 32bit machines
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_matD));
    __pyx_r = ((PyObject *)__pyx_v_matD);
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":1427
 *         # hrm... this only works on 32bit machines
 *         # what's the Python equivalent of sizeof(int)???
 *         tcode=PyString_FromStringAndSize(buffer+4,4)             # <<<<<<<<<<<<<<
 *         raise ValueError("wrong tcode "+tcode)
 * 
 */
    __pyx_t_3 = PyString_FromStringAndSize((__pyx_v_buffer + 4), 4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_tcode = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "lurrn/sparsmat.pyx":1428
 *         # what's the Python equivalent of sizeof(int)???
 *         tcode=PyString_FromStringAndSize(buffer+4,4)
 *         raise ValueError("wrong tcode "+tcode)             # <<<<<<<<<<<<<<
 * 
 * def mmapCSR(f):
 */
    __pyx_t_3 = PyNumber_Add(__pyx_kp_s_wrong_tcode, __pyx_v_tcode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lurrn/sparsmat.pyx":1384
 * 
 * 
 * def csrFromBuffer(object buf):             # <<<<<<<<<<<<<<
 *     """takes an object conforming to the Buffer protocol and
 *     creates a CSR matrix from that."""
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.csrFromBuffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_matI);
  __Pyx_XDECREF((PyObject *)__pyx_v_matF);
  __Pyx_XDECREF((PyObject *)__pyx_v_matD);
  __Pyx_XDECREF(__pyx_v_tcode);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1430
 *         raise ValueError("wrong tcode "+tcode)
 * 
 * def mmapCSR(f):             # <<<<<<<<<<<<<<
 *     ## py2.4 compat: determine length
 *     ## instead of passing length=0
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_3mmapCSR(PyObject *__pyx_self, PyObject *__pyx_v_f); /*proto*/
static PyMethodDef __pyx_mdef_5lurrn_8sparsmat_3mmapCSR = {"mmapCSR", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_3mmapCSR, METH_O, 0};
static PyObject *__pyx_pw_5lurrn_8sparsmat_3mmapCSR(PyObject *__pyx_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("mmapCSR (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_2mmapCSR(__pyx_self, ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_2mmapCSR(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_v_flen = NULL;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("mmapCSR", 0);

  /* "lurrn/sparsmat.pyx":1434
 *     ## instead of passing length=0
 *     # go to end of file and note position
 *     f.seek(0,2)             # <<<<<<<<<<<<<<
 *     flen=f.tell()
 *     a=mmap.mmap(f.fileno(),flen,access=mmap.ACCESS_READ)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_seek); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":1435
 *     # go to end of file and note position
 *     f.seek(0,2)
 *     flen=f.tell()             # <<<<<<<<<<<<<<
 *     a=mmap.mmap(f.fileno(),flen,access=mmap.ACCESS_READ)
 *     return csrFromBuffer(a)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_tell); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_flen = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":1436
 *     f.seek(0,2)
 *     flen=f.tell()
 *     a=mmap.mmap(f.fileno(),flen,access=mmap.ACCESS_READ)             # <<<<<<<<<<<<<<
 *     return csrFromBuffer(a)
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_mmap); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_mmap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_fileno); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_flen);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_flen);
  __Pyx_GIVEREF(__pyx_v_flen);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_mmap); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ACCESS_READ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_access, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_a = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "lurrn/sparsmat.pyx":1437
 *     flen=f.tell()
 *     a=mmap.mmap(f.fileno(),flen,access=mmap.ACCESS_READ)
 *     return csrFromBuffer(a)             # <<<<<<<<<<<<<<
 * 
 * ## I -> int
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_csrFromBuffer); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_a); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(__pyx_v_a);
    PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_a);
    __Pyx_GIVEREF(__pyx_v_a);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1430
 *         raise ValueError("wrong tcode "+tcode)
 * 
 * def mmapCSR(f):             # <<<<<<<<<<<<<<
 *     ## py2.4 compat: determine length
 *     ## instead of passing length=0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.mmapCSR", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_flen);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1446
 * cdef class VecI1:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_5VecI1_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_5VecI1_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1___init__(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_5VecI1___init__(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":1447
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     def item_iter(self):
 *         self.ensure_compact()
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":1446
 * cdef class VecI1:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1448
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecI1_iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("item_iter (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1_2item_iter(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("item_iter", 0);

  /* "lurrn/sparsmat.pyx":1449
 *         self.is_compact=True
 *     def item_iter(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return IVecI1_iter(self)
 *     def get_size(self,compactify=True):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":1450
 *     def item_iter(self):
 *         self.ensure_compact()
 *         return IVecI1_iter(self)             # <<<<<<<<<<<<<<
 *     def get_size(self,compactify=True):
 *         if compactify:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_IVecI1_iter)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1448
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecI1_iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.item_iter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1451
 *         self.ensure_compact()
 *         return IVecI1_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1451; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1451; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1_4get_size(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":1452
 *         return IVecI1_iter(self)
 *     def get_size(self,compactify=True):
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *         return self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":1453
 *     def get_size(self,compactify=True):
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return self.vec.size()
 *     def __len__(self):
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":1454
 *         if compactify:
 *             self.ensure_compact()
 *         return self.vec.size()             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return self.get_size(True)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_self->vec.size()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1451
 *         self.ensure_compact()
 *         return IVecI1_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1455
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecI1_7__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecI1_7__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1_6__len__(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecI1_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":1456
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1455
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1457
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1_8clear(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear", 0);

  /* "lurrn/sparsmat.pyx":1458
 *         return self.get_size(True)
 *     def clear(self):
 *         self.vec.resize(0)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void compactify(self):
 */
  __pyx_v_self->vec.resize(0);

  /* "lurrn/sparsmat.pyx":1459
 *     def clear(self):
 *         self.vec.resize(0)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrI1 comp
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":1457
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1460
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrI1 comp
 *         c_IVecI1_sort(self.vec.begin(),self.vec.end(),comp)
 */

static void __pyx_f_5lurrn_8sparsmat_5VecI1_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self) {
  struct smallerAddr<1,int> __pyx_v_comp;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compactify", 0);

  /* "lurrn/sparsmat.pyx":1462
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrI1 comp
 *         c_IVecI1_sort(self.vec.begin(),self.vec.end(),comp)             # <<<<<<<<<<<<<<
 *         c_compactifyI1(&self.vec)
 *         self.is_compact=True
 */
  sort(__pyx_v_self->vec.begin(), __pyx_v_self->vec.end(), __pyx_v_comp);

  /* "lurrn/sparsmat.pyx":1463
 *         cdef c_SmallerAddrI1 comp
 *         c_IVecI1_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyI1(&self.vec)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 */
  compactify((&__pyx_v_self->vec));

  /* "lurrn/sparsmat.pyx":1464
 *         c_IVecI1_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyI1(&self.vec)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":1460
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrI1 comp
 *         c_IVecI1_sort(self.vec.begin(),self.vec.end(),comp)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":1465
 *         c_compactifyI1(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

static void __pyx_f_5lurrn_8sparsmat_5VecI1_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":1466
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:             # <<<<<<<<<<<<<<
 *             self.compactify()
 *     cpdef int get_count(self,coordinate_t k0):
 */
  __pyx_t_1 = ((!(__pyx_v_self->is_compact != 0)) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":1467
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 *             self.compactify()             # <<<<<<<<<<<<<<
 *     cpdef int get_count(self,coordinate_t k0):
 *         cdef c_CItemI1 ci
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI1 *)__pyx_v_self->__pyx_vtab)->compactify(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":1465
 *         c_compactifyI1(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":1468
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef int get_count(self,coordinate_t k0):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI1 ci
 *         ci.addr[0]=k0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_arg_k0); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecI1_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, coordinate_t __pyx_v_k0, int __pyx_skip_dispatch) {
  struct CountItem<1,int> __pyx_v_ci;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_11get_count)) {
      __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1470
 *     cpdef int get_count(self,coordinate_t k0):
 *         cdef c_CItemI1 ci
 *         ci.addr[0]=k0             # <<<<<<<<<<<<<<
 *         return c_get_countI1(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0, int item):
 */
  (__pyx_v_ci.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":1471
 *         cdef c_CItemI1 ci
 *         ci.addr[0]=k0
 *         return c_get_countI1(&self.vec,ci)             # <<<<<<<<<<<<<<
 *     cdef void c_add(self, coordinate_t k0, int item):
 *         cdef c_CItemI1 c
 */
  __pyx_r = get_count_v((&__pyx_v_self->vec), __pyx_v_ci);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1468
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef int get_count(self,coordinate_t k0):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI1 ci
 *         ci.addr[0]=k0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecI1.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_arg_k0); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_arg_k0) {
  coordinate_t __pyx_v_k0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_count (wrapper)", 0);
  assert(__pyx_arg_k0); {
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(__pyx_arg_k0); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1_10get_count(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self), ((coordinate_t)__pyx_v_k0));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, coordinate_t __pyx_v_k0) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_5lurrn_8sparsmat_5VecI1_get_count(__pyx_v_self, __pyx_v_k0, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1472
 *         ci.addr[0]=k0
 *         return c_get_countI1(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0, int item):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI1 c
 *         c.addr[0]=k0
 */

static void __pyx_f_5lurrn_8sparsmat_5VecI1_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, coordinate_t __pyx_v_k0, int __pyx_v_item) {
  struct CountItem<1,int> __pyx_v_c;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_add", 0);

  /* "lurrn/sparsmat.pyx":1474
 *     cdef void c_add(self, coordinate_t k0, int item):
 *         cdef c_CItemI1 c
 *         c.addr[0]=k0             # <<<<<<<<<<<<<<
 *         c.item=item
 *         self.vec.push_back(c)
 */
  (__pyx_v_c.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":1475
 *         cdef c_CItemI1 c
 *         c.addr[0]=k0
 *         c.item=item             # <<<<<<<<<<<<<<
 *         self.vec.push_back(c)
 *         self.is_compact=False
 */
  __pyx_v_c.item = __pyx_v_item;

  /* "lurrn/sparsmat.pyx":1476
 *         c.addr[0]=k0
 *         c.item=item
 *         self.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0, item=1):
 */
  __pyx_v_self->vec.push_back(__pyx_v_c);

  /* "lurrn/sparsmat.pyx":1477
 *         c.item=item
 *         self.vec.push_back(c)
 *         self.is_compact=False             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.c_add(k0, item)
 */
  __pyx_v_self->is_compact = 0;

  /* "lurrn/sparsmat.pyx":1472
 *         ci.addr[0]=k0
 *         return c_get_countI1(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0, int item):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI1 c
 *         c.addr[0]=k0
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":1478
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0, item=1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0, item)
 *     def __add__(VecI1 self, VecI1 other):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  PyObject *__pyx_v_item = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_item,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_item);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1478; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1478; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_item = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1478; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1_12add_count(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self), __pyx_v_k0, __pyx_v_item);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, coordinate_t __pyx_v_k0, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":1479
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.c_add(k0, item)             # <<<<<<<<<<<<<<
 *     def __add__(VecI1 self, VecI1 other):
 *         cdef c_CItemI1 c1, c2
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_item); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI1 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_v_k0, __pyx_t_1);

  /* "lurrn/sparsmat.pyx":1478
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0, item=1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0, item)
 *     def __add__(VecI1 self, VecI1 other):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1480
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.c_add(k0, item)
 *     def __add__(VecI1 self, VecI1 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI1 c1, c2
 *         cdef unsigned int i1, i2
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_VecI1, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_VecI1, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1_14__add__(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_other) {
  struct CountItem<1,int> __pyx_v_c1;
  struct CountItem<1,int> __pyx_v_c2;
  unsigned int __pyx_v_i1;
  unsigned int __pyx_v_i2;
  int __pyx_v_k;
  int __pyx_v_delta;
  struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":1485
 *         cdef int k, delta
 *         cdef VecI1 result
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         other.ensure_compact()
 *         result=VecI1()
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":1486
 *         cdef VecI1 result
 *         self.ensure_compact()
 *         other.ensure_compact()             # <<<<<<<<<<<<<<
 *         result=VecI1()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI1 *)__pyx_v_other->__pyx_vtab)->ensure_compact(__pyx_v_other);

  /* "lurrn/sparsmat.pyx":1487
 *         self.ensure_compact()
 *         other.ensure_compact()
 *         result=VecI1()             # <<<<<<<<<<<<<<
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1488
 *         other.ensure_compact()
 *         result=VecI1()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))             # <<<<<<<<<<<<<<
 *         i1=0
 *         i2=0
 */
  __pyx_t_2 = __pyx_v_other->vec.size();
  __pyx_t_3 = __pyx_v_self->vec.size();
  if (((__pyx_t_2 > __pyx_t_3) != 0)) {
    __pyx_t_4 = __pyx_t_2;
  } else {
    __pyx_t_4 = __pyx_t_3;
  }
  __pyx_v_result->vec.reserve(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":1489
 *         result=VecI1()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0             # <<<<<<<<<<<<<<
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 */
  __pyx_v_i1 = 0;

  /* "lurrn/sparsmat.pyx":1490
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 *         i2=0             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 */
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":1491
 *         i1=0
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 */
  while (1) {
    __pyx_t_6 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_6 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":1492
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             delta=0
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":1493
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             delta=0
 *             for k from 0<=k<1:
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":1494
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 *             delta=0             # <<<<<<<<<<<<<<
 *             for k from 0<=k<1:
 *                 if c1.addr[k]<c2.addr[k]:
 */
    __pyx_v_delta = 0;

    /* "lurrn/sparsmat.pyx":1495
 *             c2=other.vec.at(i2)
 *             delta=0
 *             for k from 0<=k<1:             # <<<<<<<<<<<<<<
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 */
    for (__pyx_v_k = 0; __pyx_v_k < 1; __pyx_v_k++) {

      /* "lurrn/sparsmat.pyx":1496
 *             delta=0
 *             for k from 0<=k<1:
 *                 if c1.addr[k]<c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=-1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) < (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":1497
 *             for k from 0<=k<1:
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1             # <<<<<<<<<<<<<<
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 */
        __pyx_v_delta = -1;

        /* "lurrn/sparsmat.pyx":1498
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 *                     break             # <<<<<<<<<<<<<<
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 */
        goto __pyx_L8_break;
      }

      /* "lurrn/sparsmat.pyx":1499
 *                     delta=-1
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) > (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":1500
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1             # <<<<<<<<<<<<<<
 *                     break
 *             if delta==0:
 */
        __pyx_v_delta = 1;

        /* "lurrn/sparsmat.pyx":1501
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 *                     break             # <<<<<<<<<<<<<<
 *             if delta==0:
 *                 c1.item+=c2.item
 */
        goto __pyx_L8_break;
      }
    }
    __pyx_L8_break:;

    /* "lurrn/sparsmat.pyx":1507
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
    switch (__pyx_v_delta) {

      /* "lurrn/sparsmat.pyx":1502
 *                     delta=1
 *                     break
 *             if delta==0:             # <<<<<<<<<<<<<<
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)
 */
      case 0:

      /* "lurrn/sparsmat.pyx":1503
 *                     break
 *             if delta==0:
 *                 c1.item+=c2.item             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      __pyx_v_c1.item = (__pyx_v_c1.item + __pyx_v_c2.item);

      /* "lurrn/sparsmat.pyx":1504
 *             if delta==0:
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *                 i2+=1
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":1505
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *                 i2+=1
 *             elif delta==-1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);

      /* "lurrn/sparsmat.pyx":1506
 *                 result.vec.push_back(c1)
 *                 i1+=1
 *                 i2+=1             # <<<<<<<<<<<<<<
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;

      /* "lurrn/sparsmat.pyx":1507
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      case -1:

      /* "lurrn/sparsmat.pyx":1508
 *                 i2+=1
 *             elif delta==-1:
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             else:
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":1509
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             else:
 *                 result.vec.push_back(c2)
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      break;
      default:

      /* "lurrn/sparsmat.pyx":1511
 *                 i1+=1
 *             else:
 *                 result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *                 i2+=1
 *         while i1<self.vec.size():
 */
      __pyx_v_result->vec.push_back(__pyx_v_c2);

      /* "lurrn/sparsmat.pyx":1512
 *             else:
 *                 result.vec.push_back(c2)
 *                 i2+=1             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;
    }
  }

  /* "lurrn/sparsmat.pyx":1513
 *                 result.vec.push_back(c2)
 *                 i2+=1
 *         while i1<self.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":1514
 *                 i2+=1
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c1)
 *             i1+=1
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":1515
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *             i1+=1
 *         while i2<other.vec.size():
 */
    __pyx_v_result->vec.push_back(__pyx_v_c1);

    /* "lurrn/sparsmat.pyx":1516
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 *             i1+=1             # <<<<<<<<<<<<<<
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);
  }

  /* "lurrn/sparsmat.pyx":1517
 *             result.vec.push_back(c1)
 *             i1+=1
 *         while i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":1518
 *             i1+=1
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c2)
 *             i2+=1
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":1519
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *             i2+=1
 *         return result
 */
    __pyx_v_result->vec.push_back(__pyx_v_c2);

    /* "lurrn/sparsmat.pyx":1520
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 *             i2+=1             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_v_i2 = (__pyx_v_i2 + 1);
  }

  /* "lurrn/sparsmat.pyx":1521
 *             result.vec.push_back(c2)
 *             i2+=1
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     cpdef SparseVectorI to_sparse(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1480
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.c_add(k0, item)
 *     def __add__(VecI1 self, VecI1 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI1 c1, c2
 *         cdef unsigned int i1, i2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1523
 *         return result
 * 
 *     cpdef SparseVectorI to_sparse(self):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI1 c
 *         cdef SparseVectorI result
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_17to_sparse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_f_5lurrn_8sparsmat_5VecI1_to_sparse(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, int __pyx_skip_dispatch) {
  struct CountItem<1,int> __pyx_v_c;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_result = 0;
  coordinate_t __pyx_v_n;
  coordinate_t __pyx_v_i;
  coordinate_t *__pyx_v_idx_ptr;
  int *__pyx_v_vals_ptr;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  coordinate_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_sparse", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_to_sparse); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_17to_sparse)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_SparseVectorI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1529
 *         cdef coordinate_t *idx_ptr
 *         cdef int *vals_ptr
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         idx_ptr=<coordinate_t *>PyMem_Malloc(n*sizeof(coordinate_t))
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":1530
 *         cdef int *vals_ptr
 *         self.ensure_compact()
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         idx_ptr=<coordinate_t *>PyMem_Malloc(n*sizeof(coordinate_t))
 *         vals_ptr=<int *>PyMem_Malloc(n*sizeof(int))
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":1531
 *         self.ensure_compact()
 *         n=self.vec.size()
 *         idx_ptr=<coordinate_t *>PyMem_Malloc(n*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         vals_ptr=<int *>PyMem_Malloc(n*sizeof(int))
 *         for i from 0<=i<n:
 */
  __pyx_v_idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_n * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":1532
 *         n=self.vec.size()
 *         idx_ptr=<coordinate_t *>PyMem_Malloc(n*sizeof(coordinate_t))
 *         vals_ptr=<int *>PyMem_Malloc(n*sizeof(int))             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *           c=self.vec.at(i)
 */
  __pyx_v_vals_ptr = ((int *)PyMem_Malloc((__pyx_v_n * (sizeof(int)))));

  /* "lurrn/sparsmat.pyx":1533
 *         idx_ptr=<coordinate_t *>PyMem_Malloc(n*sizeof(coordinate_t))
 *         vals_ptr=<int *>PyMem_Malloc(n*sizeof(int))
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *           c=self.vec.at(i)
 *           idx_ptr[i]=c.addr[0]
 */
  __pyx_t_5 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":1534
 *         vals_ptr=<int *>PyMem_Malloc(n*sizeof(int))
 *         for i from 0<=i<n:
 *           c=self.vec.at(i)             # <<<<<<<<<<<<<<
 *           idx_ptr[i]=c.addr[0]
 *           vals_ptr[i]=c.item
 */
    __pyx_v_c = __pyx_v_self->vec.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":1535
 *         for i from 0<=i<n:
 *           c=self.vec.at(i)
 *           idx_ptr[i]=c.addr[0]             # <<<<<<<<<<<<<<
 *           vals_ptr[i]=c.item
 *         result=SparseVectorI(None)
 */
    (__pyx_v_idx_ptr[__pyx_v_i]) = (__pyx_v_c.addr[0]);

    /* "lurrn/sparsmat.pyx":1536
 *           c=self.vec.at(i)
 *           idx_ptr[i]=c.addr[0]
 *           vals_ptr[i]=c.item             # <<<<<<<<<<<<<<
 *         result=SparseVectorI(None)
 *         result.idx_ptr=idx_ptr
 */
    __pyx_t_6 = __pyx_v_c.item;
    (__pyx_v_vals_ptr[__pyx_v_i]) = __pyx_t_6;
  }

  /* "lurrn/sparsmat.pyx":1537
 *           idx_ptr[i]=c.addr[0]
 *           vals_ptr[i]=c.item
 *         result=SparseVectorI(None)             # <<<<<<<<<<<<<<
 *         result.idx_ptr=idx_ptr
 *         result.vals_ptr=vals_ptr
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorI)), __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1538
 *           vals_ptr[i]=c.item
 *         result=SparseVectorI(None)
 *         result.idx_ptr=idx_ptr             # <<<<<<<<<<<<<<
 *         result.vals_ptr=vals_ptr
 *         result.my_len=n
 */
  __pyx_v_result->idx_ptr = __pyx_v_idx_ptr;

  /* "lurrn/sparsmat.pyx":1539
 *         result=SparseVectorI(None)
 *         result.idx_ptr=idx_ptr
 *         result.vals_ptr=vals_ptr             # <<<<<<<<<<<<<<
 *         result.my_len=n
 *         return result
 */
  __pyx_v_result->vals_ptr = __pyx_v_vals_ptr;

  /* "lurrn/sparsmat.pyx":1540
 *         result.idx_ptr=idx_ptr
 *         result.vals_ptr=vals_ptr
 *         result.my_len=n             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
  __pyx_v_result->my_len = __pyx_v_n;

  /* "lurrn/sparsmat.pyx":1541
 *         result.vals_ptr=vals_ptr
 *         result.my_len=n
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def tofile(self, f):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1523
 *         return result
 * 
 *     cpdef SparseVectorI to_sparse(self):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI1 c
 *         cdef SparseVectorI result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.to_sparse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_17to_sparse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_17to_sparse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_sparse (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1_16to_sparse(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_16to_sparse(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_sparse", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_5VecI1_to_sparse(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.to_sparse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1543
 *         return result
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_19tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_19tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tofile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1_18tofile(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_18tofile(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  long __pyx_v_k;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  long __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("tofile", 0);

  /* "lurrn/sparsmat.pyx":1545
 *     def tofile(self, f):
 *         cdef long i, n, k, k_max
 *         n=self.get_size()             # <<<<<<<<<<<<<<
 *         f.write('I1 %d\n'%(n,))
 *         k=0
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":1546
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 *         f.write('I1 %d\n'%(n,))             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_I1_d, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1547
 *         n=self.get_size()
 *         f.write('I1 %d\n'%(n,))
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecI1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemI1))
 */
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":1548
 *         f.write('I1 %d\n'%(n,))
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecI1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemI1))
 *             f.write(s)
 */
  __pyx_t_4 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":1549
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecI1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemI1))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *             k+=CHUNK_SIZE
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), (256 * (sizeof(struct CountItem<1,int>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":1550
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecI1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemI1))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":1551
 *             s=PyString_FromStringAndSize(<char *>c_VecI1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemI1))
 *             f.write(s)
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecI1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemI1))
 */
    __pyx_v_k = (__pyx_v_k + 256);
  }

  /* "lurrn/sparsmat.pyx":1552
 *             f.write(s)
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecI1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemI1))
 *             f.write(s)
 */
  __pyx_t_7 = ((__pyx_v_k < __pyx_v_n) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":1553
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecI1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemI1))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *     def fromfile(self, f):
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), ((__pyx_v_n - __pyx_v_k) * (sizeof(struct CountItem<1,int>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":1554
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecI1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemI1))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *     def fromfile(self, f):
 *         cdef long i, n
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":1543
 *         return result
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.tofile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1555
 *             s=PyString_FromStringAndSize(<char *>c_VecI1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemI1))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_21fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_21fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fromfile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1_20fromfile(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_20fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  PyObject *__pyx_v_line = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  long __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  size_t __pyx_t_9;
  char *__pyx_t_10;
  size_t __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromfile", 0);

  /* "lurrn/sparsmat.pyx":1557
 *     def fromfile(self, f):
 *         cdef long i, n
 *         line=f.readline().strip().split()             # <<<<<<<<<<<<<<
 *         assert line[0]=='I1'
 *         n=long(line[1])
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_readline); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_line = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1558
 *         cdef long i, n
 *         line=f.readline().strip().split()
 *         assert line[0]=='I1'             # <<<<<<<<<<<<<<
 *         n=long(line[1])
 *         self.clear()
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1558; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_I1, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_6)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":1559
 *         line=f.readline().strip().split()
 *         assert line[0]=='I1'
 *         n=long(line[1])             # <<<<<<<<<<<<<<
 *         self.clear()
 *         self.vec.resize(n)
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1559; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyLong_Type))), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_7;

  /* "lurrn/sparsmat.pyx":1560
 *         assert line[0]=='I1'
 *         n=long(line[1])
 *         self.clear()             # <<<<<<<<<<<<<<
 *         self.vec.resize(n)
 *         k=0
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clear); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1561
 *         n=long(line[1])
 *         self.clear()
 *         self.vec.resize(n)             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_v_self->vec.resize(__pyx_v_n);

  /* "lurrn/sparsmat.pyx":1562
 *         self.clear()
 *         self.vec.resize(n)
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemI1))
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_k = __pyx_int_0;

  /* "lurrn/sparsmat.pyx":1563
 *         self.vec.resize(n)
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemI1))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemI1)
 */
  __pyx_t_7 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":1564
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemI1))             # <<<<<<<<<<<<<<
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemI1)
 *             memcpy(<void *>c_VecI1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemI1))
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyInt_FromSize_t((256 * (sizeof(struct CountItem<1,int>)))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":1565
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemI1))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemI1)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecI1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemI1))
 *             k+=CHUNK_SIZE
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!((__pyx_t_8 == (256 * (sizeof(struct CountItem<1,int>)))) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":1566
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemI1))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemI1)
 *             memcpy(<void *>c_VecI1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemI1))             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), (256 * (sizeof(struct CountItem<1,int>))));

    /* "lurrn/sparsmat.pyx":1567
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemI1)
 *             memcpy(<void *>c_VecI1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemI1))
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemI1))
 */
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_k, __pyx_int_256); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_1);
    __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1568
 *             memcpy(<void *>c_VecI1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemI1))
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=f.read((n-k)*sizeof(c_CItemI1))
 *             assert len(s)==(n-k)*sizeof(c_CItemI1)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":1569
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemI1))             # <<<<<<<<<<<<<<
 *             assert len(s)==(n-k)*sizeof(c_CItemI1)
 *             memcpy(<void *>c_VecI1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemI1))
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_5, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<1,int>))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":1570
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemI1))
 *             assert len(s)==(n-k)*sizeof(c_CItemI1)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecI1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemI1))
 *     cpdef int get_maxcol(self, int k=0):
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<1,int>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_6)) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":1571
 *             s=f.read((n-k)*sizeof(c_CItemI1))
 *             assert len(s)==(n-k)*sizeof(c_CItemI1)
 *             memcpy(<void *>c_VecI1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemI1))             # <<<<<<<<<<<<<<
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<1,int>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), __pyx_t_11);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":1555
 *             s=PyString_FromStringAndSize(<char *>c_VecI1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemI1))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.fromfile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_line);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1572
 *             assert len(s)==(n-k)*sizeof(c_CItemI1)
 *             memcpy(<void *>c_VecI1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemI1))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<1
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecI1_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI1_get_maxcol *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_i;
  int __pyx_v_n;
  int __pyx_v_new_val;
  int __pyx_v_col;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_maxcol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_23get_maxcol)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1574
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<1             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         if n==0:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_9 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_9 = ((__pyx_v_k < 1) != 0);
    __pyx_t_8 = __pyx_t_9;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_8)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":1575
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<1
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         if n==0:
 *             return -1
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":1576
 *         assert k>=0 and k<1
 *         n=self.vec.size()
 *         if n==0:             # <<<<<<<<<<<<<<
 *             return -1
 *         if k==0:
 */
  __pyx_t_8 = ((__pyx_v_n == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":1577
 *         n=self.vec.size()
 *         if n==0:
 *             return -1             # <<<<<<<<<<<<<<
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 */
    __pyx_r = -1;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1578
 *         if n==0:
 *             return -1
 *         if k==0:             # <<<<<<<<<<<<<<
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 */
  __pyx_t_8 = ((__pyx_v_k == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":1579
 *             return -1
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]             # <<<<<<<<<<<<<<
 *         col=-1
 *         n=self.vec.size()
 */
    __pyx_r = (__pyx_v_self->vec.at((__pyx_v_n - 1)).addr[0]);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1580
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 *         col=-1             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_v_col = -1;

  /* "lurrn/sparsmat.pyx":1581
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":1582
 *         col=-1
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 */
  __pyx_t_7 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":1583
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             if new_val>col:
 *                 col=new_val
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":1584
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:             # <<<<<<<<<<<<<<
 *                 col=new_val
 *         return col
 */
    __pyx_t_8 = ((__pyx_v_new_val > __pyx_v_col) != 0);
    if (__pyx_t_8) {

      /* "lurrn/sparsmat.pyx":1585
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 *                 col=new_val             # <<<<<<<<<<<<<<
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 */
      __pyx_v_col = __pyx_v_new_val;
      goto __pyx_L9;
    }
    __pyx_L9:;
  }

  /* "lurrn/sparsmat.pyx":1586
 *             if new_val>col:
 *                 col=new_val
 *         return col             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 *         cdef int old_val, new_val, i, n, count
 */
  __pyx_r = __pyx_v_col;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1572
 *             assert len(s)==(n-k)*sizeof(c_CItemI1)
 *             memcpy(<void *>c_VecI1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemI1))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecI1.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_maxcol (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_maxcol") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_maxcol", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1_22get_maxcol(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_22get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecI1_get_maxcol __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = __pyx_vtabptr_5lurrn_8sparsmat_VecI1->get_maxcol(__pyx_v_self, 1, &__pyx_t_2); 
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1587
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecI1_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI1_get_type_counts *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_new_val;
  int __pyx_v_i;
  int __pyx_v_n;
  PyArrayObject *__pyx_v_result = 0;
  long __pyx_v_n_types;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecI1_get_maxcol __pyx_t_11;
  PyArrayObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_25get_type_counts)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1590
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<1             # <<<<<<<<<<<<<<
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_8 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_k < 1) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_7)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":1591
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<1
 *         if self.vec.size()==0:             # <<<<<<<<<<<<<<
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 */
  __pyx_t_7 = ((__pyx_v_self->vec.size() == 0) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":1592
 *         assert k>=0 and k<1
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_9 = 1;
      }
    }
    __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_2) {
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1593
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":1594
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1             # <<<<<<<<<<<<<<
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 */
  __pyx_t_11.__pyx_n = 1;
  __pyx_t_11.k = __pyx_v_k;
  __pyx_t_10 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI1 *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0, &__pyx_t_11); 
  __pyx_v_n_types = (__pyx_t_10 + 1);

  /* "lurrn/sparsmat.pyx":1595
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_n_types); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_9 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_6) {
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_12 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
    }
    __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_12 = 0;
  __pyx_v_result = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1596
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":1597
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":1598
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             result[new_val]+=1
 *         return result
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":1599
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1             # <<<<<<<<<<<<<<
 *         return result
 *     cpdef VecI1 remap(self, int k, numpy.ndarray filt):
 */
    __pyx_t_16 = __pyx_v_new_val;
    __pyx_t_17 = -1;
    if (__pyx_t_16 < 0) {
      __pyx_t_16 += __pyx_pybuffernd_result.diminfo[0].shape;
      if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 0;
    } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_17 = 0;
    if (unlikely(__pyx_t_17 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_17);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_result.diminfo[0].strides) += 1;
  }

  /* "lurrn/sparsmat.pyx":1600
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 *         return result             # <<<<<<<<<<<<<<
 *     cpdef VecI1 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyArrayObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1587
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1_24get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_24get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecI1_get_type_counts __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_5lurrn_8sparsmat_VecI1->get_type_counts(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1601
 *             result[new_val]+=1
 *         return result
 *     cpdef VecI1 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_f_5lurrn_8sparsmat_5VecI1_remap(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_wanted = 0;
  PyArrayObject *__pyx_v_target = 0;
  int __pyx_v_n;
  int __pyx_v_i;
  struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_result = 0;
  struct CountItem<1,int> __pyx_v_c;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_target;
  __Pyx_Buffer __pyx_pybuffer_target;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_wanted;
  __Pyx_Buffer __pyx_pybuffer_wanted;
  struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __pyx_pybuffer_wanted.pybuffer.buf = NULL;
  __pyx_pybuffer_wanted.refcount = 0;
  __pyx_pybuffernd_wanted.data = NULL;
  __pyx_pybuffernd_wanted.rcbuffer = &__pyx_pybuffer_wanted;
  __pyx_pybuffer_target.pybuffer.buf = NULL;
  __pyx_pybuffer_target.refcount = 0;
  __pyx_pybuffernd_target.data = NULL;
  __pyx_pybuffernd_target.rcbuffer = &__pyx_pybuffer_target;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_remap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_27remap)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_filt));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_filt));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_filt));
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_VecI1))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1602
 *         return result
 *     cpdef VecI1 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_wanted = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_wanted.diminfo[0].strides = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_wanted.diminfo[0].shape = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_8 = 0;
  __pyx_v_wanted = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":1603
 *     cpdef VecI1 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_cumsum); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Subtract(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_target = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_target.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_target.diminfo[0].strides = __pyx_pybuffernd_target.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_target.diminfo[0].shape = __pyx_pybuffernd_target.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_9 = 0;
  __pyx_v_target = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1604
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         cdef int n=self.vec.size()
 *         cdef int i
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":1605
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()             # <<<<<<<<<<<<<<
 *         cdef int i
 *         cdef VecI1 result=VecI1()
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":1607
 *         cdef int n=self.vec.size()
 *         cdef int i
 *         cdef VecI1 result=VecI1()             # <<<<<<<<<<<<<<
 *         cdef c_CItemI1 c
 *         for i from 0<=i<n:
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1609
 *         cdef VecI1 result=VecI1()
 *         cdef c_CItemI1 c
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":1610
 *         cdef c_CItemI1 c
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)             # <<<<<<<<<<<<<<
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 */
    __pyx_v_c = __pyx_v_self->vec.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":1611
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:             # <<<<<<<<<<<<<<
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 */
    __pyx_t_11 = (__pyx_v_c.addr[__pyx_v_k]);
    __pyx_t_12 = -1;
    if (__pyx_t_11 < 0) {
      __pyx_t_11 += __pyx_pybuffernd_wanted.diminfo[0].shape;
      if (unlikely(__pyx_t_11 < 0)) __pyx_t_12 = 0;
    } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_wanted.diminfo[0].shape)) __pyx_t_12 = 0;
    if (unlikely(__pyx_t_12 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_12);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_wanted.diminfo[0].strides)) != 0);
    if (__pyx_t_13) {

      /* "lurrn/sparsmat.pyx":1612
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c)
 *         return result
 */
      __pyx_t_12 = (__pyx_v_c.addr[__pyx_v_k]);
      __pyx_t_14 = -1;
      if (__pyx_t_12 < 0) {
        __pyx_t_12 += __pyx_pybuffernd_target.diminfo[0].shape;
        if (unlikely(__pyx_t_12 < 0)) __pyx_t_14 = 0;
      } else if (unlikely(__pyx_t_12 >= __pyx_pybuffernd_target.diminfo[0].shape)) __pyx_t_14 = 0;
      if (unlikely(__pyx_t_14 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_14);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      (__pyx_v_c.addr[__pyx_v_k]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_target.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_target.diminfo[0].strides));

      /* "lurrn/sparsmat.pyx":1613
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         return result
 *     def append(self,tup):
 */
      __pyx_v_result->vec.push_back(__pyx_v_c);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "lurrn/sparsmat.pyx":1614
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 *         return result             # <<<<<<<<<<<<<<
 *     def append(self,tup):
 *         k0,val=tup
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1601
 *             result[new_val]+=1
 *         return result
 *     cpdef VecI1 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_wanted);
  __Pyx_XDECREF((PyObject *)__pyx_v_target);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_filt = ((PyArrayObject *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_filt), __pyx_ptype_5numpy_ndarray, 1, "filt", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1_26remap(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_26remap(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_5VecI1_remap(__pyx_v_self, __pyx_v_k, __pyx_v_filt, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1615
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,val=tup
 *         self.c_add(k0,val)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_29append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_29append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("append (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1_28append(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self), ((PyObject *)__pyx_v_tup));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_28append(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *(*__pyx_t_4)(PyObject *);
  coordinate_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("append", 0);

  /* "lurrn/sparsmat.pyx":1616
 *         return result
 *     def append(self,tup):
 *         k0,val=tup             # <<<<<<<<<<<<<<
 *         self.c_add(k0,val)
 *     def extend(self,tups):
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_tup))) || (PyList_CheckExact(__pyx_v_tup))) {
    PyObject* sequence = __pyx_v_tup;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    #endif
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_4(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_k0 = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_val = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":1617
 *     def append(self,tup):
 *         k0,val=tup
 *         self.c_add(k0,val)             # <<<<<<<<<<<<<<
 *     def extend(self,tups):
 *         for k0,val in tups:
 */
  __pyx_t_5 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_5 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_val); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI1 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_5, __pyx_t_6);

  /* "lurrn/sparsmat.pyx":1615
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,val=tup
 *         self.c_add(k0,val)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1618
 *         k0,val=tup
 *         self.c_add(k0,val)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,val in tups:
 *             self.c_add(k0,val)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_31extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_31extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extend (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1_30extend(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self), ((PyObject *)__pyx_v_tups));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_30extend(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  coordinate_t __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("extend", 0);

  /* "lurrn/sparsmat.pyx":1619
 *         self.c_add(k0,val)
 *     def extend(self,tups):
 *         for k0,val in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,val)
 *     def __iter__(self):
 */
  if (likely(PyList_CheckExact(__pyx_v_tups)) || PyTuple_CheckExact(__pyx_v_tups)) {
    __pyx_t_1 = __pyx_v_tups; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_tups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_k0, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "lurrn/sparsmat.pyx":1620
 *     def extend(self,tups):
 *         for k0,val in tups:
 *             self.c_add(k0,val)             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self.item_iter()
 */
    __pyx_t_9 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_9 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_val); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI1 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_9, __pyx_t_10);

    /* "lurrn/sparsmat.pyx":1619
 *         self.c_add(k0,val)
 *     def extend(self,tups):
 *         for k0,val in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,val)
 *     def __iter__(self):
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1618
 *         k0,val=tup
 *         self.c_add(k0,val)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,val in tups:
 *             self.c_add(k0,val)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.extend", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1621
 *         for k0,val in tups:
 *             self.c_add(k0,val)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_33__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_33__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1_32__iter__(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_32__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":1622
 *             self.c_add(k0,val)
 *     def __iter__(self):
 *         return self.item_iter()             # <<<<<<<<<<<<<<
 *     def __reduce__(self):
 *         return (VecI1,(),(),self.item_iter())
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1621
 *         for k0,val in tups:
 *             self.c_add(k0,val)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1623
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecI1,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_35__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_35__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1_34__reduce__(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_34__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "lurrn/sparsmat.pyx":1624
 *         return self.item_iter()
 *     def __reduce__(self):
 *         return (VecI1,(),(),self.item_iter())             # <<<<<<<<<<<<<<
 *     def __setstate__(self,state):
 *         pass
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI1)));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI1)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI1)));
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1623
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecI1,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1625
 *     def __reduce__(self):
 *         return (VecI1,(),(),self.item_iter())
 *     def __setstate__(self,state):             # <<<<<<<<<<<<<<
 *         pass
 *     def __repr__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_37__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_37__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1_36__setstate__(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self), ((PyObject *)__pyx_v_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_36__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1627
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecI1(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_39__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI1_39__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI1_38__repr__(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI1_38__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "lurrn/sparsmat.pyx":1628
 *         pass
 *     def __repr__(self):
 *         return 'VecI1(%s)'%(str(list(self)),)             # <<<<<<<<<<<<<<
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_VecI1_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1627
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecI1(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI1.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1629
 *     def __repr__(self):
 *         return 'VecI1(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

/* Python wrapper */
static void __pyx_pw_5lurrn_8sparsmat_5VecI1_41__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5lurrn_8sparsmat_5VecI1_41__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5lurrn_8sparsmat_5VecI1_40__dealloc__(((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5lurrn_8sparsmat_5VecI1_40__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lurrn/sparsmat.pyx":1631
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()             # <<<<<<<<<<<<<<
 * 
 * cdef class IVecI1_iter:
 */
  __pyx_v_self->vec.~vector();

  /* "lurrn/sparsmat.pyx":1629
 *     def __repr__(self):
 *         return 'VecI1(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":1637
 *     cdef c_VecI1 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_11IVecI1_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_11IVecI1_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_vec = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_vec,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1637; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_vec = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1637; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.IVecI1_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecI1_iter___init__(((struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter *)__pyx_v_self), __pyx_v_vec);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_11IVecI1_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter *__pyx_v_self, PyObject *__pyx_v_vec) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":1638
 *     cdef unsigned int k
 *     def __init__(self,vec):
 *         self.vec=vec             # <<<<<<<<<<<<<<
 *         self.vecC=&self.vec.vec
 *         self.k=0
 */
  if (!(likely(((__pyx_v_vec) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_vec, __pyx_ptype_5lurrn_8sparsmat_VecI1))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_vec;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->vec);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->vec));
  __pyx_v_self->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1639
 *     def __init__(self,vec):
 *         self.vec=vec
 *         self.vecC=&self.vec.vec             # <<<<<<<<<<<<<<
 *         self.k=0
 *     def __iter__(self):
 */
  __pyx_v_self->vecC = (&__pyx_v_self->vec->vec);

  /* "lurrn/sparsmat.pyx":1640
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 *         self.k=0             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self
 */
  __pyx_v_self->k = 0;

  /* "lurrn/sparsmat.pyx":1637
 *     cdef c_VecI1 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecI1_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1641
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecI1_iter_3__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecI1_iter_3__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecI1_iter_2__iter__(((struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecI1_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":1642
 *         self.k=0
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1641
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1643
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecI1_iter_5__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecI1_iter_5__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecI1_iter_4__next__(((struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecI1_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter *__pyx_v_self) {
  struct CountItem<1,int> __pyx_v_res;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "lurrn/sparsmat.pyx":1644
 *         return self
 *     def __next__(self):
 *         if self.k>=self.vecC.size():             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         cdef c_CItemI1 res=self.vecC.at(self.k)
 */
  __pyx_t_1 = ((__pyx_v_self->k >= __pyx_v_self->vecC->size()) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":1645
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         cdef c_CItemI1 res=self.vecC.at(self.k)
 *         self.k+=1
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lurrn/sparsmat.pyx":1646
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 *         cdef c_CItemI1 res=self.vecC.at(self.k)             # <<<<<<<<<<<<<<
 *         self.k+=1
 *         return (res.addr[0],
 */
  __pyx_v_res = __pyx_v_self->vecC->at(__pyx_v_self->k);

  /* "lurrn/sparsmat.pyx":1647
 *             raise StopIteration
 *         cdef c_CItemI1 res=self.vecC.at(self.k)
 *         self.k+=1             # <<<<<<<<<<<<<<
 *         return (res.addr[0],
 *                 res.item)
 */
  __pyx_v_self->k = (__pyx_v_self->k + 1);

  /* "lurrn/sparsmat.pyx":1648
 *         cdef c_CItemI1 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.item)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_res.addr[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "lurrn/sparsmat.pyx":1649
 *         self.k+=1
 *         return (res.addr[0],
 *                 res.item)             # <<<<<<<<<<<<<<
 * 
 * cdef class LargeVecI1:
 */
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_res.item); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "lurrn/sparsmat.pyx":1648
 *         cdef c_CItemI1 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.item)
 * 
 */
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1643
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecI1_iter.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1654
 *     cdef public object compact
 *     cdef public VecI1 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecI1()
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI1_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI1_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI1___init__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI1___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":1655
 *     cdef public VecI1 loose
 *     def __init__(self):
 *         self.compact=[]             # <<<<<<<<<<<<<<
 *         self.loose=VecI1()
 *         self.loose.vec.reserve(100000)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1656
 *     def __init__(self):
 *         self.compact=[]
 *         self.loose=VecI1()             # <<<<<<<<<<<<<<
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1657
 *         self.compact=[]
 *         self.loose=VecI1()
 *         self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 */
  __pyx_v_self->loose->vec.reserve(100000);

  /* "lurrn/sparsmat.pyx":1654
 *     cdef public object compact
 *     cdef public VecI1 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecI1()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI1.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1658
 *         self.loose=VecI1()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ensure_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_2ensure_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI1_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":1659
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *         self.loose=VecI1()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":1660
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *         self.loose=VecI1()
 *         while len(self.compact)>=2:
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":1661
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 *         self.loose=VecI1()             # <<<<<<<<<<<<<<
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":1662
 *             self.compact.append(self.loose)
 *         self.loose=VecI1()
 *         while len(self.compact)>=2:             # <<<<<<<<<<<<<<
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0, item=1):
 */
  while (1) {
    __pyx_t_2 = __pyx_v_self->compact;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = ((__pyx_t_6 >= 2) != 0);
    if (!__pyx_t_4) break;

    /* "lurrn/sparsmat.pyx":1663
 *         self.loose=VecI1()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.loose.c_add(k0, item)
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1663; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1663; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_1, -2, 0, NULL, NULL, &__pyx_slice__5, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1658
 *         self.loose=VecI1()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI1.ensure_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1664
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0, item=1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0, item)
 *         if self.loose.get_size(False)>=100000:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  PyObject *__pyx_v_item = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_item,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_item);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1664; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1664; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_item = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1664; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI1.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_4add_count(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *)__pyx_v_self), __pyx_v_k0, __pyx_v_item);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI1_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self, coordinate_t __pyx_v_k0, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":1665
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.loose.c_add(k0, item)             # <<<<<<<<<<<<<<
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_item); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI1 *)__pyx_v_self->loose->__pyx_vtab)->c_add(__pyx_v_self->loose, __pyx_v_k0, __pyx_t_1);

  /* "lurrn/sparsmat.pyx":1666
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.loose.c_add(k0, item)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_int_100000, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":1667
 *         self.loose.c_add(k0, item)
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *             self.loose=VecI1()
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI1 *)__pyx_v_self->loose->__pyx_vtab)->ensure_compact(__pyx_v_self->loose);

    /* "lurrn/sparsmat.pyx":1668
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *             self.loose=VecI1()
 *             self.loose.vec.reserve(100000)
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lurrn/sparsmat.pyx":1669
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 *             self.loose=VecI1()             # <<<<<<<<<<<<<<
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 */
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->loose);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
    __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":1670
 *             self.compact.append(self.loose)
 *             self.loose=VecI1()
 *             self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 */
    __pyx_v_self->loose->vec.reserve(100000);

    /* "lurrn/sparsmat.pyx":1671
 *             self.loose=VecI1()
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and             # <<<<<<<<<<<<<<
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
    while (1) {
      __pyx_t_2 = __pyx_v_self->compact;
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_7 = ((__pyx_t_6 >= 2) != 0);
      if (__pyx_t_7) {
      } else {
        __pyx_t_4 = __pyx_t_7;
        goto __pyx_L6_bool_binop_done;
      }

      /* "lurrn/sparsmat.pyx":1672
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):             # <<<<<<<<<<<<<<
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 */
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1672; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1672; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyNumber_Multiply(__pyx_float_0_6, __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_2, __pyx_t_9, Py_GE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_4 = __pyx_t_7;
      __pyx_L6_bool_binop_done:;
      if (!__pyx_t_4) break;

      /* "lurrn/sparsmat.pyx":1673
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = PyNumber_Add(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyList_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_9, -2, 0, NULL, NULL, &__pyx_slice__7, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":1664
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0, item=1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0, item)
 *         if self.loose.get_size(False)>=100000:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI1.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1674
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_6get_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI1_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_compact", 0);

  /* "lurrn/sparsmat.pyx":1675
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         if len(self.compact)>0:
 *             return self.compact[0]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1676
 *     def get_compact(self):
 *         self.ensure_compact()
 *         if len(self.compact)>0:             # <<<<<<<<<<<<<<
 *             return self.compact[0]
 *         else:
 */
  __pyx_t_1 = __pyx_v_self->compact;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((__pyx_t_4 > 0) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":1677
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 *             return self.compact[0]             # <<<<<<<<<<<<<<
 *         else:
 *             return VecI1()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1677; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":1679
 *             return self.compact[0]
 *         else:
 *             return VecI1()             # <<<<<<<<<<<<<<
 *     def get_size(self, compactify=True):
 *         cdef int n
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1674
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI1.get_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1680
 *         else:
 *             return VecI1()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1680; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1680; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI1.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_8get_size(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI1_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  int __pyx_v_n;
  PyObject *__pyx_v_c = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":1682
 *     def get_size(self, compactify=True):
 *         cdef int n
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *             if self.compact:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":1683
 *         cdef int n
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *             if self.compact:
 *                 return self.compact[0].get_size()
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":1684
 *         if compactify:
 *             self.ensure_compact()
 *             if self.compact:             # <<<<<<<<<<<<<<
 *                 return self.compact[0].get_size()
 *             else:
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->compact); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":1685
 *             self.ensure_compact()
 *             if self.compact:
 *                 return self.compact[0].get_size()             # <<<<<<<<<<<<<<
 *             else:
 *                 return 0
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":1687
 *                 return self.compact[0].get_size()
 *             else:
 *                 return 0             # <<<<<<<<<<<<<<
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_int_0);
      __pyx_r = __pyx_int_0;
      goto __pyx_L0;
    }
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":1689
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_v_self->compact)) || PyTuple_CheckExact(__pyx_v_self->compact)) {
      __pyx_t_4 = __pyx_v_self->compact; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_self->compact); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_get_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":1690
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":1691
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)
 *             return n             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         self.ensure_compact()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1680
 *         else:
 *             return VecI1()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI1.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_c);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1692
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_11__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_11__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_10__iter__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI1_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":1693
 *             return n
 *     def __iter__(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         try:
 *             return iter(self.compact[0])
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1694
 *     def __iter__(self):
 *         self.ensure_compact()
 *         try:             # <<<<<<<<<<<<<<
 *             return iter(self.compact[0])
 *         except IndexError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "lurrn/sparsmat.pyx":1695
 *         self.ensure_compact()
 *         try:
 *             return iter(self.compact[0])             # <<<<<<<<<<<<<<
 *         except IndexError:
 *             return iter([])
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1695; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1695; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L7_try_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":1696
 *         try:
 *             return iter(self.compact[0])
 *         except IndexError:             # <<<<<<<<<<<<<<
 *             return iter([])
 * 
 */
    __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_IndexError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI1.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1696; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_3);

      /* "lurrn/sparsmat.pyx":1697
 *             return iter(self.compact[0])
 *         except IndexError:
 *             return iter([])             # <<<<<<<<<<<<<<
 * 
 *     def get_type_counts(self, k=0):
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1697; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1697; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_r = __pyx_t_9;
      __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1692
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI1.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1699
 *             return iter([])
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_13get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_13get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_12get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI1_12get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);

  /* "lurrn/sparsmat.pyx":1700
 * 
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)             # <<<<<<<<<<<<<<
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_k);
    __Pyx_GIVEREF(__pyx_v_k);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1699
 *             return iter([])
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1701
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_15remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_15remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  PyObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1701; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1701; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = values[0];
    __pyx_v_filt = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1701; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_14remap(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI1_14remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);

  /* "lurrn/sparsmat.pyx":1702
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_remap); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_v_k);
  PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_k);
  __Pyx_GIVEREF(__pyx_v_k);
  __Pyx_INCREF(__pyx_v_filt);
  PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_filt);
  __Pyx_GIVEREF(__pyx_v_filt);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1701
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1652
 * 
 * cdef class LargeVecI1:
 *     cdef public object compact             # <<<<<<<<<<<<<<
 *     cdef public VecI1 loose
 *     def __init__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_7compact_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_7compact_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_7compact___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI1_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->compact);
  __pyx_r = __pyx_v_self->compact;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI1_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI1_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_7compact_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI1_7compact_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI1_7compact_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_7compact_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1653
 * cdef class LargeVecI1:
 *     cdef public object compact
 *     cdef public VecI1 loose             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *         self.compact=[]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_5loose_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_5loose_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_5loose___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI1_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->loose));
  __pyx_r = ((PyObject *)__pyx_v_self->loose);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI1_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI1_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_5loose_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5lurrn_8sparsmat_VecI1))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI1.loose.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI1_5loose_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI1_5loose_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_5loose_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI1_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1709
 * cdef class VecI2:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_5VecI2_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_5VecI2_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2___init__(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_5VecI2___init__(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":1710
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     def item_iter(self):
 *         self.ensure_compact()
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":1709
 * cdef class VecI2:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1711
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecI2_iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("item_iter (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2_2item_iter(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("item_iter", 0);

  /* "lurrn/sparsmat.pyx":1712
 *         self.is_compact=True
 *     def item_iter(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return IVecI2_iter(self)
 *     def get_size(self,compactify=True):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":1713
 *     def item_iter(self):
 *         self.ensure_compact()
 *         return IVecI2_iter(self)             # <<<<<<<<<<<<<<
 *     def get_size(self,compactify=True):
 *         if compactify:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_IVecI2_iter)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1711
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecI2_iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.item_iter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1714
 *         self.ensure_compact()
 *         return IVecI2_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1714; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1714; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2_4get_size(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":1715
 *         return IVecI2_iter(self)
 *     def get_size(self,compactify=True):
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *         return self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":1716
 *     def get_size(self,compactify=True):
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return self.vec.size()
 *     def __len__(self):
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":1717
 *         if compactify:
 *             self.ensure_compact()
 *         return self.vec.size()             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return self.get_size(True)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_self->vec.size()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1714
 *         self.ensure_compact()
 *         return IVecI2_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1718
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecI2_7__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecI2_7__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2_6__len__(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecI2_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":1719
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1718
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1720
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2_8clear(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear", 0);

  /* "lurrn/sparsmat.pyx":1721
 *         return self.get_size(True)
 *     def clear(self):
 *         self.vec.resize(0)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void compactify(self):
 */
  __pyx_v_self->vec.resize(0);

  /* "lurrn/sparsmat.pyx":1722
 *     def clear(self):
 *         self.vec.resize(0)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrI2 comp
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":1720
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1723
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrI2 comp
 *         c_IVecI2_sort(self.vec.begin(),self.vec.end(),comp)
 */

static void __pyx_f_5lurrn_8sparsmat_5VecI2_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self) {
  struct smallerAddr<2,int> __pyx_v_comp;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compactify", 0);

  /* "lurrn/sparsmat.pyx":1725
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrI2 comp
 *         c_IVecI2_sort(self.vec.begin(),self.vec.end(),comp)             # <<<<<<<<<<<<<<
 *         c_compactifyI2(&self.vec)
 *         self.is_compact=True
 */
  sort(__pyx_v_self->vec.begin(), __pyx_v_self->vec.end(), __pyx_v_comp);

  /* "lurrn/sparsmat.pyx":1726
 *         cdef c_SmallerAddrI2 comp
 *         c_IVecI2_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyI2(&self.vec)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 */
  compactify((&__pyx_v_self->vec));

  /* "lurrn/sparsmat.pyx":1727
 *         c_IVecI2_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyI2(&self.vec)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":1723
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrI2 comp
 *         c_IVecI2_sort(self.vec.begin(),self.vec.end(),comp)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":1728
 *         c_compactifyI2(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

static void __pyx_f_5lurrn_8sparsmat_5VecI2_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":1729
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:             # <<<<<<<<<<<<<<
 *             self.compactify()
 *     cpdef int get_count(self,coordinate_t k0,coordinate_t k1):
 */
  __pyx_t_1 = ((!(__pyx_v_self->is_compact != 0)) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":1730
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 *             self.compactify()             # <<<<<<<<<<<<<<
 *     cpdef int get_count(self,coordinate_t k0,coordinate_t k1):
 *         cdef c_CItemI2 ci
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_self->__pyx_vtab)->compactify(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":1728
 *         c_compactifyI2(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":1731
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef int get_count(self,coordinate_t k0,coordinate_t k1):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI2 ci
 *         ci.addr[0]=k0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecI2_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, int __pyx_skip_dispatch) {
  struct CountItem<2,int> __pyx_v_ci;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_11get_count)) {
      __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_5 = __pyx_t_1; __pyx_t_6 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_7 = 1;
        }
      }
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_6) {
        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_9;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1733
 *     cpdef int get_count(self,coordinate_t k0,coordinate_t k1):
 *         cdef c_CItemI2 ci
 *         ci.addr[0]=k0             # <<<<<<<<<<<<<<
 *         ci.addr[1]=k1
 *         return c_get_countI2(&self.vec,ci)
 */
  (__pyx_v_ci.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":1734
 *         cdef c_CItemI2 ci
 *         ci.addr[0]=k0
 *         ci.addr[1]=k1             # <<<<<<<<<<<<<<
 *         return c_get_countI2(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1, int item):
 */
  (__pyx_v_ci.addr[1]) = __pyx_v_k1;

  /* "lurrn/sparsmat.pyx":1735
 *         ci.addr[0]=k0
 *         ci.addr[1]=k1
 *         return c_get_countI2(&self.vec,ci)             # <<<<<<<<<<<<<<
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1, int item):
 *         cdef c_CItemI2 c
 */
  __pyx_r = get_count_v((&__pyx_v_self->vec), __pyx_v_ci);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1731
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef int get_count(self,coordinate_t k0,coordinate_t k1):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI2 ci
 *         ci.addr[0]=k0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecI2.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_count", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_count", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2_10get_count(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_5lurrn_8sparsmat_5VecI2_get_count(__pyx_v_self, __pyx_v_k0, __pyx_v_k1, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1736
 *         ci.addr[1]=k1
 *         return c_get_countI2(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1, int item):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI2 c
 *         c.addr[0]=k0
 */

static void __pyx_f_5lurrn_8sparsmat_5VecI2_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, int __pyx_v_item) {
  struct CountItem<2,int> __pyx_v_c;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_add", 0);

  /* "lurrn/sparsmat.pyx":1738
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1, int item):
 *         cdef c_CItemI2 c
 *         c.addr[0]=k0             # <<<<<<<<<<<<<<
 *         c.addr[1]=k1
 *         c.item=item
 */
  (__pyx_v_c.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":1739
 *         cdef c_CItemI2 c
 *         c.addr[0]=k0
 *         c.addr[1]=k1             # <<<<<<<<<<<<<<
 *         c.item=item
 *         self.vec.push_back(c)
 */
  (__pyx_v_c.addr[1]) = __pyx_v_k1;

  /* "lurrn/sparsmat.pyx":1740
 *         c.addr[0]=k0
 *         c.addr[1]=k1
 *         c.item=item             # <<<<<<<<<<<<<<
 *         self.vec.push_back(c)
 *         self.is_compact=False
 */
  __pyx_v_c.item = __pyx_v_item;

  /* "lurrn/sparsmat.pyx":1741
 *         c.addr[1]=k1
 *         c.item=item
 *         self.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 */
  __pyx_v_self->vec.push_back(__pyx_v_c);

  /* "lurrn/sparsmat.pyx":1742
 *         c.item=item
 *         self.vec.push_back(c)
 *         self.is_compact=False             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.c_add(k0,k1, item)
 */
  __pyx_v_self->is_compact = 0;

  /* "lurrn/sparsmat.pyx":1736
 *         ci.addr[1]=k1
 *         return c_get_countI2(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1, int item):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI2 c
 *         c.addr[0]=k0
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":1743
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1, item)
 *     def __add__(VecI2 self, VecI2 other):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  PyObject *__pyx_v_item = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,&__pyx_n_s_item,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_item);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_item = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2_12add_count(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1, __pyx_v_item);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":1744
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.c_add(k0,k1, item)             # <<<<<<<<<<<<<<
 *     def __add__(VecI2 self, VecI2 other):
 *         cdef c_CItemI2 c1, c2
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_item); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_v_k0, __pyx_v_k1, __pyx_t_1);

  /* "lurrn/sparsmat.pyx":1743
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1, item)
 *     def __add__(VecI2 self, VecI2 other):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1745
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.c_add(k0,k1, item)
 *     def __add__(VecI2 self, VecI2 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI2 c1, c2
 *         cdef unsigned int i1, i2
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_VecI2, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_VecI2, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2_14__add__(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_other) {
  struct CountItem<2,int> __pyx_v_c1;
  struct CountItem<2,int> __pyx_v_c2;
  unsigned int __pyx_v_i1;
  unsigned int __pyx_v_i2;
  int __pyx_v_k;
  int __pyx_v_delta;
  struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":1750
 *         cdef int k, delta
 *         cdef VecI2 result
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         other.ensure_compact()
 *         result=VecI2()
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":1751
 *         cdef VecI2 result
 *         self.ensure_compact()
 *         other.ensure_compact()             # <<<<<<<<<<<<<<
 *         result=VecI2()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_other->__pyx_vtab)->ensure_compact(__pyx_v_other);

  /* "lurrn/sparsmat.pyx":1752
 *         self.ensure_compact()
 *         other.ensure_compact()
 *         result=VecI2()             # <<<<<<<<<<<<<<
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1753
 *         other.ensure_compact()
 *         result=VecI2()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))             # <<<<<<<<<<<<<<
 *         i1=0
 *         i2=0
 */
  __pyx_t_2 = __pyx_v_other->vec.size();
  __pyx_t_3 = __pyx_v_self->vec.size();
  if (((__pyx_t_2 > __pyx_t_3) != 0)) {
    __pyx_t_4 = __pyx_t_2;
  } else {
    __pyx_t_4 = __pyx_t_3;
  }
  __pyx_v_result->vec.reserve(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":1754
 *         result=VecI2()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0             # <<<<<<<<<<<<<<
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 */
  __pyx_v_i1 = 0;

  /* "lurrn/sparsmat.pyx":1755
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 *         i2=0             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 */
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":1756
 *         i1=0
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 */
  while (1) {
    __pyx_t_6 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_6 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":1757
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             delta=0
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":1758
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             delta=0
 *             for k from 0<=k<2:
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":1759
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 *             delta=0             # <<<<<<<<<<<<<<
 *             for k from 0<=k<2:
 *                 if c1.addr[k]<c2.addr[k]:
 */
    __pyx_v_delta = 0;

    /* "lurrn/sparsmat.pyx":1760
 *             c2=other.vec.at(i2)
 *             delta=0
 *             for k from 0<=k<2:             # <<<<<<<<<<<<<<
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 */
    for (__pyx_v_k = 0; __pyx_v_k < 2; __pyx_v_k++) {

      /* "lurrn/sparsmat.pyx":1761
 *             delta=0
 *             for k from 0<=k<2:
 *                 if c1.addr[k]<c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=-1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) < (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":1762
 *             for k from 0<=k<2:
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1             # <<<<<<<<<<<<<<
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 */
        __pyx_v_delta = -1;

        /* "lurrn/sparsmat.pyx":1763
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 *                     break             # <<<<<<<<<<<<<<
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 */
        goto __pyx_L8_break;
      }

      /* "lurrn/sparsmat.pyx":1764
 *                     delta=-1
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) > (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":1765
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1             # <<<<<<<<<<<<<<
 *                     break
 *             if delta==0:
 */
        __pyx_v_delta = 1;

        /* "lurrn/sparsmat.pyx":1766
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 *                     break             # <<<<<<<<<<<<<<
 *             if delta==0:
 *                 c1.item+=c2.item
 */
        goto __pyx_L8_break;
      }
    }
    __pyx_L8_break:;

    /* "lurrn/sparsmat.pyx":1772
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
    switch (__pyx_v_delta) {

      /* "lurrn/sparsmat.pyx":1767
 *                     delta=1
 *                     break
 *             if delta==0:             # <<<<<<<<<<<<<<
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)
 */
      case 0:

      /* "lurrn/sparsmat.pyx":1768
 *                     break
 *             if delta==0:
 *                 c1.item+=c2.item             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      __pyx_v_c1.item = (__pyx_v_c1.item + __pyx_v_c2.item);

      /* "lurrn/sparsmat.pyx":1769
 *             if delta==0:
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *                 i2+=1
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":1770
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *                 i2+=1
 *             elif delta==-1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);

      /* "lurrn/sparsmat.pyx":1771
 *                 result.vec.push_back(c1)
 *                 i1+=1
 *                 i2+=1             # <<<<<<<<<<<<<<
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;

      /* "lurrn/sparsmat.pyx":1772
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      case -1:

      /* "lurrn/sparsmat.pyx":1773
 *                 i2+=1
 *             elif delta==-1:
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             else:
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":1774
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             else:
 *                 result.vec.push_back(c2)
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      break;
      default:

      /* "lurrn/sparsmat.pyx":1776
 *                 i1+=1
 *             else:
 *                 result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *                 i2+=1
 *         while i1<self.vec.size():
 */
      __pyx_v_result->vec.push_back(__pyx_v_c2);

      /* "lurrn/sparsmat.pyx":1777
 *             else:
 *                 result.vec.push_back(c2)
 *                 i2+=1             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;
    }
  }

  /* "lurrn/sparsmat.pyx":1778
 *                 result.vec.push_back(c2)
 *                 i2+=1
 *         while i1<self.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":1779
 *                 i2+=1
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c1)
 *             i1+=1
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":1780
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *             i1+=1
 *         while i2<other.vec.size():
 */
    __pyx_v_result->vec.push_back(__pyx_v_c1);

    /* "lurrn/sparsmat.pyx":1781
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 *             i1+=1             # <<<<<<<<<<<<<<
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);
  }

  /* "lurrn/sparsmat.pyx":1782
 *             result.vec.push_back(c1)
 *             i1+=1
 *         while i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":1783
 *             i1+=1
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c2)
 *             i2+=1
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":1784
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *             i2+=1
 *         return result
 */
    __pyx_v_result->vec.push_back(__pyx_v_c2);

    /* "lurrn/sparsmat.pyx":1785
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 *             i2+=1             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_v_i2 = (__pyx_v_i2 + 1);
  }

  /* "lurrn/sparsmat.pyx":1786
 *             result.vec.push_back(c2)
 *             i2+=1
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     cpdef CSRMatrixI to_csr(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1745
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.c_add(k0,k1, item)
 *     def __add__(VecI2 self, VecI2 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI2 c1, c2
 *         cdef unsigned int i1, i2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1788
 *         return result
 * 
 *     cpdef CSRMatrixI to_csr(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         cdef c_CSRMatrixI *matC=vec2csrI(&self.vec)
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_17to_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_f_5lurrn_8sparsmat_5VecI2_to_csr(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, int __pyx_skip_dispatch) {
  struct CSRMatrix<int> *__pyx_v_matC;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_mat = 0;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_csr", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_to_csr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_17to_csr)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1789
 * 
 *     cpdef CSRMatrixI to_csr(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         cdef c_CSRMatrixI *matC=vec2csrI(&self.vec)
 *         cdef CSRMatrixI mat=CSRMatrixI()
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":1790
 *     cpdef CSRMatrixI to_csr(self):
 *         self.ensure_compact()
 *         cdef c_CSRMatrixI *matC=vec2csrI(&self.vec)             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixI mat=CSRMatrixI()
 *         mat.set_matrix(matC)
 */
  __pyx_v_matC = vec2csr((&__pyx_v_self->vec));

  /* "lurrn/sparsmat.pyx":1791
 *         self.ensure_compact()
 *         cdef c_CSRMatrixI *matC=vec2csrI(&self.vec)
 *         cdef CSRMatrixI mat=CSRMatrixI()             # <<<<<<<<<<<<<<
 *         mat.set_matrix(matC)
 *         return mat
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixI)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_mat = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1792
 *         cdef c_CSRMatrixI *matC=vec2csrI(&self.vec)
 *         cdef CSRMatrixI mat=CSRMatrixI()
 *         mat.set_matrix(matC)             # <<<<<<<<<<<<<<
 *         return mat
 * 
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_mat->__pyx_vtab)->set_matrix(__pyx_v_mat, __pyx_v_matC);

  /* "lurrn/sparsmat.pyx":1793
 *         cdef CSRMatrixI mat=CSRMatrixI()
 *         mat.set_matrix(matC)
 *         return mat             # <<<<<<<<<<<<<<
 * 
 *     def tofile(self, f):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_mat));
  __pyx_r = __pyx_v_mat;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1788
 *         return result
 * 
 *     cpdef CSRMatrixI to_csr(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         cdef c_CSRMatrixI *matC=vec2csrI(&self.vec)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.to_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mat);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_17to_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_17to_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_csr (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2_16to_csr(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_16to_csr(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_csr", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_5VecI2_to_csr(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.to_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1795
 *         return mat
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_19tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_19tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tofile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2_18tofile(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_18tofile(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  long __pyx_v_k;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  long __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("tofile", 0);

  /* "lurrn/sparsmat.pyx":1797
 *     def tofile(self, f):
 *         cdef long i, n, k, k_max
 *         n=self.get_size()             # <<<<<<<<<<<<<<
 *         f.write('I2 %d\n'%(n,))
 *         k=0
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":1798
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 *         f.write('I2 %d\n'%(n,))             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_I2_d, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1799
 *         n=self.get_size()
 *         f.write('I2 %d\n'%(n,))
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecI2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemI2))
 */
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":1800
 *         f.write('I2 %d\n'%(n,))
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecI2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemI2))
 *             f.write(s)
 */
  __pyx_t_4 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":1801
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecI2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemI2))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *             k+=CHUNK_SIZE
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), (256 * (sizeof(struct CountItem<2,int>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":1802
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecI2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemI2))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":1803
 *             s=PyString_FromStringAndSize(<char *>c_VecI2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemI2))
 *             f.write(s)
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecI2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemI2))
 */
    __pyx_v_k = (__pyx_v_k + 256);
  }

  /* "lurrn/sparsmat.pyx":1804
 *             f.write(s)
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecI2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemI2))
 *             f.write(s)
 */
  __pyx_t_7 = ((__pyx_v_k < __pyx_v_n) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":1805
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecI2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemI2))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *     def fromfile(self, f):
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), ((__pyx_v_n - __pyx_v_k) * (sizeof(struct CountItem<2,int>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":1806
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecI2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemI2))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *     def fromfile(self, f):
 *         cdef long i, n
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":1795
 *         return mat
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.tofile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1807
 *             s=PyString_FromStringAndSize(<char *>c_VecI2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemI2))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_21fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_21fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fromfile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2_20fromfile(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_20fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  PyObject *__pyx_v_line = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  long __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  size_t __pyx_t_9;
  char *__pyx_t_10;
  size_t __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromfile", 0);

  /* "lurrn/sparsmat.pyx":1809
 *     def fromfile(self, f):
 *         cdef long i, n
 *         line=f.readline().strip().split()             # <<<<<<<<<<<<<<
 *         assert line[0]=='I2'
 *         n=long(line[1])
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_readline); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_line = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1810
 *         cdef long i, n
 *         line=f.readline().strip().split()
 *         assert line[0]=='I2'             # <<<<<<<<<<<<<<
 *         n=long(line[1])
 *         self.clear()
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_I2, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_6)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":1811
 *         line=f.readline().strip().split()
 *         assert line[0]=='I2'
 *         n=long(line[1])             # <<<<<<<<<<<<<<
 *         self.clear()
 *         self.vec.resize(n)
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1811; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyLong_Type))), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_7;

  /* "lurrn/sparsmat.pyx":1812
 *         assert line[0]=='I2'
 *         n=long(line[1])
 *         self.clear()             # <<<<<<<<<<<<<<
 *         self.vec.resize(n)
 *         k=0
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clear); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1813
 *         n=long(line[1])
 *         self.clear()
 *         self.vec.resize(n)             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_v_self->vec.resize(__pyx_v_n);

  /* "lurrn/sparsmat.pyx":1814
 *         self.clear()
 *         self.vec.resize(n)
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemI2))
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_k = __pyx_int_0;

  /* "lurrn/sparsmat.pyx":1815
 *         self.vec.resize(n)
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemI2))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemI2)
 */
  __pyx_t_7 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":1816
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemI2))             # <<<<<<<<<<<<<<
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemI2)
 *             memcpy(<void *>c_VecI2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemI2))
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyInt_FromSize_t((256 * (sizeof(struct CountItem<2,int>)))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":1817
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemI2))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemI2)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecI2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemI2))
 *             k+=CHUNK_SIZE
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!((__pyx_t_8 == (256 * (sizeof(struct CountItem<2,int>)))) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":1818
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemI2))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemI2)
 *             memcpy(<void *>c_VecI2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemI2))             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), (256 * (sizeof(struct CountItem<2,int>))));

    /* "lurrn/sparsmat.pyx":1819
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemI2)
 *             memcpy(<void *>c_VecI2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemI2))
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemI2))
 */
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_k, __pyx_int_256); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_1);
    __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1820
 *             memcpy(<void *>c_VecI2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemI2))
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=f.read((n-k)*sizeof(c_CItemI2))
 *             assert len(s)==(n-k)*sizeof(c_CItemI2)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":1821
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemI2))             # <<<<<<<<<<<<<<
 *             assert len(s)==(n-k)*sizeof(c_CItemI2)
 *             memcpy(<void *>c_VecI2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemI2))
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_5, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<2,int>))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":1822
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemI2))
 *             assert len(s)==(n-k)*sizeof(c_CItemI2)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecI2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemI2))
 *     cpdef int get_maxcol(self, int k=0):
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<2,int>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_6)) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":1823
 *             s=f.read((n-k)*sizeof(c_CItemI2))
 *             assert len(s)==(n-k)*sizeof(c_CItemI2)
 *             memcpy(<void *>c_VecI2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemI2))             # <<<<<<<<<<<<<<
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<2,int>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), __pyx_t_11);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":1807
 *             s=PyString_FromStringAndSize(<char *>c_VecI2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemI2))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.fromfile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_line);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1824
 *             assert len(s)==(n-k)*sizeof(c_CItemI2)
 *             memcpy(<void *>c_VecI2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemI2))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<2
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecI2_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI2_get_maxcol *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_i;
  int __pyx_v_n;
  int __pyx_v_new_val;
  int __pyx_v_col;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_maxcol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_23get_maxcol)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1826
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<2             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         if n==0:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_9 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_9 = ((__pyx_v_k < 2) != 0);
    __pyx_t_8 = __pyx_t_9;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_8)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":1827
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<2
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         if n==0:
 *             return -1
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":1828
 *         assert k>=0 and k<2
 *         n=self.vec.size()
 *         if n==0:             # <<<<<<<<<<<<<<
 *             return -1
 *         if k==0:
 */
  __pyx_t_8 = ((__pyx_v_n == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":1829
 *         n=self.vec.size()
 *         if n==0:
 *             return -1             # <<<<<<<<<<<<<<
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 */
    __pyx_r = -1;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1830
 *         if n==0:
 *             return -1
 *         if k==0:             # <<<<<<<<<<<<<<
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 */
  __pyx_t_8 = ((__pyx_v_k == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":1831
 *             return -1
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]             # <<<<<<<<<<<<<<
 *         col=-1
 *         n=self.vec.size()
 */
    __pyx_r = (__pyx_v_self->vec.at((__pyx_v_n - 1)).addr[0]);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1832
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 *         col=-1             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_v_col = -1;

  /* "lurrn/sparsmat.pyx":1833
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":1834
 *         col=-1
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 */
  __pyx_t_7 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":1835
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             if new_val>col:
 *                 col=new_val
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":1836
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:             # <<<<<<<<<<<<<<
 *                 col=new_val
 *         return col
 */
    __pyx_t_8 = ((__pyx_v_new_val > __pyx_v_col) != 0);
    if (__pyx_t_8) {

      /* "lurrn/sparsmat.pyx":1837
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 *                 col=new_val             # <<<<<<<<<<<<<<
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 */
      __pyx_v_col = __pyx_v_new_val;
      goto __pyx_L9;
    }
    __pyx_L9:;
  }

  /* "lurrn/sparsmat.pyx":1838
 *             if new_val>col:
 *                 col=new_val
 *         return col             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 *         cdef int old_val, new_val, i, n, count
 */
  __pyx_r = __pyx_v_col;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1824
 *             assert len(s)==(n-k)*sizeof(c_CItemI2)
 *             memcpy(<void *>c_VecI2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemI2))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecI2.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_maxcol (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_maxcol") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_maxcol", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2_22get_maxcol(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_22get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecI2_get_maxcol __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = __pyx_vtabptr_5lurrn_8sparsmat_VecI2->get_maxcol(__pyx_v_self, 1, &__pyx_t_2); 
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1839
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecI2_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI2_get_type_counts *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_new_val;
  int __pyx_v_i;
  int __pyx_v_n;
  PyArrayObject *__pyx_v_result = 0;
  long __pyx_v_n_types;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecI2_get_maxcol __pyx_t_11;
  PyArrayObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_25get_type_counts)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1842
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<2             # <<<<<<<<<<<<<<
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_8 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_k < 2) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_7)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":1843
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<2
 *         if self.vec.size()==0:             # <<<<<<<<<<<<<<
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 */
  __pyx_t_7 = ((__pyx_v_self->vec.size() == 0) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":1844
 *         assert k>=0 and k<2
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_9 = 1;
      }
    }
    __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_2) {
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1845
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":1846
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1             # <<<<<<<<<<<<<<
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 */
  __pyx_t_11.__pyx_n = 1;
  __pyx_t_11.k = __pyx_v_k;
  __pyx_t_10 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0, &__pyx_t_11); 
  __pyx_v_n_types = (__pyx_t_10 + 1);

  /* "lurrn/sparsmat.pyx":1847
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_n_types); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_9 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_6) {
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_12 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
    }
    __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_12 = 0;
  __pyx_v_result = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1848
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":1849
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":1850
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             result[new_val]+=1
 *         return result
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":1851
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1             # <<<<<<<<<<<<<<
 *         return result
 *     cpdef VecI2 remap(self, int k, numpy.ndarray filt):
 */
    __pyx_t_16 = __pyx_v_new_val;
    __pyx_t_17 = -1;
    if (__pyx_t_16 < 0) {
      __pyx_t_16 += __pyx_pybuffernd_result.diminfo[0].shape;
      if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 0;
    } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_17 = 0;
    if (unlikely(__pyx_t_17 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_17);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_result.diminfo[0].strides) += 1;
  }

  /* "lurrn/sparsmat.pyx":1852
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 *         return result             # <<<<<<<<<<<<<<
 *     cpdef VecI2 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyArrayObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1839
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2_24get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_24get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecI2_get_type_counts __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_5lurrn_8sparsmat_VecI2->get_type_counts(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1853
 *             result[new_val]+=1
 *         return result
 *     cpdef VecI2 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_f_5lurrn_8sparsmat_5VecI2_remap(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_wanted = 0;
  PyArrayObject *__pyx_v_target = 0;
  int __pyx_v_n;
  int __pyx_v_i;
  struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_result = 0;
  struct CountItem<2,int> __pyx_v_c;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_target;
  __Pyx_Buffer __pyx_pybuffer_target;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_wanted;
  __Pyx_Buffer __pyx_pybuffer_wanted;
  struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __pyx_pybuffer_wanted.pybuffer.buf = NULL;
  __pyx_pybuffer_wanted.refcount = 0;
  __pyx_pybuffernd_wanted.data = NULL;
  __pyx_pybuffernd_wanted.rcbuffer = &__pyx_pybuffer_wanted;
  __pyx_pybuffer_target.pybuffer.buf = NULL;
  __pyx_pybuffer_target.refcount = 0;
  __pyx_pybuffernd_target.data = NULL;
  __pyx_pybuffernd_target.rcbuffer = &__pyx_pybuffer_target;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_remap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_27remap)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_filt));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_filt));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_filt));
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_VecI2))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1854
 *         return result
 *     cpdef VecI2 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_wanted = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_wanted.diminfo[0].strides = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_wanted.diminfo[0].shape = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_8 = 0;
  __pyx_v_wanted = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":1855
 *     cpdef VecI2 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_cumsum); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Subtract(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_target = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_target.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_target.diminfo[0].strides = __pyx_pybuffernd_target.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_target.diminfo[0].shape = __pyx_pybuffernd_target.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_9 = 0;
  __pyx_v_target = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1856
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         cdef int n=self.vec.size()
 *         cdef int i
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":1857
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()             # <<<<<<<<<<<<<<
 *         cdef int i
 *         cdef VecI2 result=VecI2()
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":1859
 *         cdef int n=self.vec.size()
 *         cdef int i
 *         cdef VecI2 result=VecI2()             # <<<<<<<<<<<<<<
 *         cdef c_CItemI2 c
 *         for i from 0<=i<n:
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1861
 *         cdef VecI2 result=VecI2()
 *         cdef c_CItemI2 c
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":1862
 *         cdef c_CItemI2 c
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)             # <<<<<<<<<<<<<<
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 */
    __pyx_v_c = __pyx_v_self->vec.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":1863
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:             # <<<<<<<<<<<<<<
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 */
    __pyx_t_11 = (__pyx_v_c.addr[__pyx_v_k]);
    __pyx_t_12 = -1;
    if (__pyx_t_11 < 0) {
      __pyx_t_11 += __pyx_pybuffernd_wanted.diminfo[0].shape;
      if (unlikely(__pyx_t_11 < 0)) __pyx_t_12 = 0;
    } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_wanted.diminfo[0].shape)) __pyx_t_12 = 0;
    if (unlikely(__pyx_t_12 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_12);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_wanted.diminfo[0].strides)) != 0);
    if (__pyx_t_13) {

      /* "lurrn/sparsmat.pyx":1864
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c)
 *         return result
 */
      __pyx_t_12 = (__pyx_v_c.addr[__pyx_v_k]);
      __pyx_t_14 = -1;
      if (__pyx_t_12 < 0) {
        __pyx_t_12 += __pyx_pybuffernd_target.diminfo[0].shape;
        if (unlikely(__pyx_t_12 < 0)) __pyx_t_14 = 0;
      } else if (unlikely(__pyx_t_12 >= __pyx_pybuffernd_target.diminfo[0].shape)) __pyx_t_14 = 0;
      if (unlikely(__pyx_t_14 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_14);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      (__pyx_v_c.addr[__pyx_v_k]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_target.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_target.diminfo[0].strides));

      /* "lurrn/sparsmat.pyx":1865
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         return result
 *     def append(self,tup):
 */
      __pyx_v_result->vec.push_back(__pyx_v_c);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "lurrn/sparsmat.pyx":1866
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 *         return result             # <<<<<<<<<<<<<<
 *     def append(self,tup):
 *         k0,k1,val=tup
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1853
 *             result[new_val]+=1
 *         return result
 *     cpdef VecI2 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_wanted);
  __Pyx_XDECREF((PyObject *)__pyx_v_target);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_filt = ((PyArrayObject *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_filt), __pyx_ptype_5numpy_ndarray, 1, "filt", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2_26remap(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_26remap(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_5VecI2_remap(__pyx_v_self, __pyx_v_k, __pyx_v_filt, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1867
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,k1,val=tup
 *         self.c_add(k0,k1,val)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_29append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_29append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("append (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2_28append(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self), ((PyObject *)__pyx_v_tup));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_28append(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_k1 = NULL;
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *(*__pyx_t_5)(PyObject *);
  coordinate_t __pyx_t_6;
  coordinate_t __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("append", 0);

  /* "lurrn/sparsmat.pyx":1868
 *         return result
 *     def append(self,tup):
 *         k0,k1,val=tup             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1,val)
 *     def extend(self,tups):
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_tup))) || (PyList_CheckExact(__pyx_v_tup))) {
    PyObject* sequence = __pyx_v_tup;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    #endif
  } else {
    Py_ssize_t index = -1;
    __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 2; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_k0 = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_k1 = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_val = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "lurrn/sparsmat.pyx":1869
 *     def append(self,tup):
 *         k0,k1,val=tup
 *         self.c_add(k0,k1,val)             # <<<<<<<<<<<<<<
 *     def extend(self,tups):
 *         for k0,k1,val in tups:
 */
  __pyx_t_6 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_6 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k1); if (unlikely((__pyx_t_7 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_val); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_6, __pyx_t_7, __pyx_t_8);

  /* "lurrn/sparsmat.pyx":1867
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,k1,val=tup
 *         self.c_add(k0,k1,val)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_k1);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1870
 *         k0,k1,val=tup
 *         self.c_add(k0,k1,val)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,k1,val in tups:
 *             self.c_add(k0,k1,val)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_31extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_31extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extend (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2_30extend(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self), ((PyObject *)__pyx_v_tups));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_30extend(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_k1 = NULL;
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  coordinate_t __pyx_t_10;
  coordinate_t __pyx_t_11;
  int __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("extend", 0);

  /* "lurrn/sparsmat.pyx":1871
 *         self.c_add(k0,k1,val)
 *     def extend(self,tups):
 *         for k0,k1,val in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,k1,val)
 *     def __iter__(self):
 */
  if (likely(PyList_CheckExact(__pyx_v_tups)) || PyTuple_CheckExact(__pyx_v_tups)) {
    __pyx_t_1 = __pyx_v_tups; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_tups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_8 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      index = 2; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_9 = NULL;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_k0, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_k1, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "lurrn/sparsmat.pyx":1872
 *     def extend(self,tups):
 *         for k0,k1,val in tups:
 *             self.c_add(k0,k1,val)             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self.item_iter()
 */
    __pyx_t_10 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_10 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k1); if (unlikely((__pyx_t_11 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_v_val); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_10, __pyx_t_11, __pyx_t_12);

    /* "lurrn/sparsmat.pyx":1871
 *         self.c_add(k0,k1,val)
 *     def extend(self,tups):
 *         for k0,k1,val in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,k1,val)
 *     def __iter__(self):
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1870
 *         k0,k1,val=tup
 *         self.c_add(k0,k1,val)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,k1,val in tups:
 *             self.c_add(k0,k1,val)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.extend", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_k1);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1873
 *         for k0,k1,val in tups:
 *             self.c_add(k0,k1,val)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_33__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_33__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2_32__iter__(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_32__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":1874
 *             self.c_add(k0,k1,val)
 *     def __iter__(self):
 *         return self.item_iter()             # <<<<<<<<<<<<<<
 *     def __reduce__(self):
 *         return (VecI2,(),(),self.item_iter())
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1873
 *         for k0,k1,val in tups:
 *             self.c_add(k0,k1,val)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1875
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecI2,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_35__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_35__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2_34__reduce__(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_34__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "lurrn/sparsmat.pyx":1876
 *         return self.item_iter()
 *     def __reduce__(self):
 *         return (VecI2,(),(),self.item_iter())             # <<<<<<<<<<<<<<
 *     def __setstate__(self,state):
 *         pass
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI2)));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI2)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI2)));
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1875
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecI2,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1877
 *     def __reduce__(self):
 *         return (VecI2,(),(),self.item_iter())
 *     def __setstate__(self,state):             # <<<<<<<<<<<<<<
 *         pass
 *     def __repr__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_37__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_37__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2_36__setstate__(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self), ((PyObject *)__pyx_v_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_36__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1879
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecI2(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_39__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI2_39__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI2_38__repr__(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI2_38__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "lurrn/sparsmat.pyx":1880
 *         pass
 *     def __repr__(self):
 *         return 'VecI2(%s)'%(str(list(self)),)             # <<<<<<<<<<<<<<
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_VecI2_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1879
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecI2(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI2.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1881
 *     def __repr__(self):
 *         return 'VecI2(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

/* Python wrapper */
static void __pyx_pw_5lurrn_8sparsmat_5VecI2_41__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5lurrn_8sparsmat_5VecI2_41__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5lurrn_8sparsmat_5VecI2_40__dealloc__(((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5lurrn_8sparsmat_5VecI2_40__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lurrn/sparsmat.pyx":1883
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()             # <<<<<<<<<<<<<<
 * 
 * cdef class IVecI2_iter:
 */
  __pyx_v_self->vec.~vector();

  /* "lurrn/sparsmat.pyx":1881
 *     def __repr__(self):
 *         return 'VecI2(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":1889
 *     cdef c_VecI2 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_11IVecI2_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_11IVecI2_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_vec = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_vec,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1889; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_vec = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1889; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.IVecI2_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecI2_iter___init__(((struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter *)__pyx_v_self), __pyx_v_vec);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_11IVecI2_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter *__pyx_v_self, PyObject *__pyx_v_vec) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":1890
 *     cdef unsigned int k
 *     def __init__(self,vec):
 *         self.vec=vec             # <<<<<<<<<<<<<<
 *         self.vecC=&self.vec.vec
 *         self.k=0
 */
  if (!(likely(((__pyx_v_vec) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_vec, __pyx_ptype_5lurrn_8sparsmat_VecI2))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_vec;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->vec);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->vec));
  __pyx_v_self->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1891
 *     def __init__(self,vec):
 *         self.vec=vec
 *         self.vecC=&self.vec.vec             # <<<<<<<<<<<<<<
 *         self.k=0
 *     def __iter__(self):
 */
  __pyx_v_self->vecC = (&__pyx_v_self->vec->vec);

  /* "lurrn/sparsmat.pyx":1892
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 *         self.k=0             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self
 */
  __pyx_v_self->k = 0;

  /* "lurrn/sparsmat.pyx":1889
 *     cdef c_VecI2 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecI2_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1893
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecI2_iter_3__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecI2_iter_3__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecI2_iter_2__iter__(((struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecI2_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":1894
 *         self.k=0
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1893
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1895
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecI2_iter_5__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecI2_iter_5__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecI2_iter_4__next__(((struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecI2_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter *__pyx_v_self) {
  struct CountItem<2,int> __pyx_v_res;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "lurrn/sparsmat.pyx":1896
 *         return self
 *     def __next__(self):
 *         if self.k>=self.vecC.size():             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         cdef c_CItemI2 res=self.vecC.at(self.k)
 */
  __pyx_t_1 = ((__pyx_v_self->k >= __pyx_v_self->vecC->size()) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":1897
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         cdef c_CItemI2 res=self.vecC.at(self.k)
 *         self.k+=1
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lurrn/sparsmat.pyx":1898
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 *         cdef c_CItemI2 res=self.vecC.at(self.k)             # <<<<<<<<<<<<<<
 *         self.k+=1
 *         return (res.addr[0],
 */
  __pyx_v_res = __pyx_v_self->vecC->at(__pyx_v_self->k);

  /* "lurrn/sparsmat.pyx":1899
 *             raise StopIteration
 *         cdef c_CItemI2 res=self.vecC.at(self.k)
 *         self.k+=1             # <<<<<<<<<<<<<<
 *         return (res.addr[0],
 *                 res.addr[1],
 */
  __pyx_v_self->k = (__pyx_v_self->k + 1);

  /* "lurrn/sparsmat.pyx":1900
 *         cdef c_CItemI2 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.addr[1],
 *                 res.item)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_res.addr[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "lurrn/sparsmat.pyx":1901
 *         self.k+=1
 *         return (res.addr[0],
 *                 res.addr[1],             # <<<<<<<<<<<<<<
 *                 res.item)
 * 
 */
  __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_res.addr[1])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "lurrn/sparsmat.pyx":1902
 *         return (res.addr[0],
 *                 res.addr[1],
 *                 res.item)             # <<<<<<<<<<<<<<
 * 
 * cdef class LargeVecI2:
 */
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_res.item); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":1900
 *         cdef c_CItemI2 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.addr[1],
 *                 res.item)
 */
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1895
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecI2_iter.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1907
 *     cdef public object compact
 *     cdef public VecI2 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecI2()
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI2_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI2_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI2___init__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI2___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":1908
 *     cdef public VecI2 loose
 *     def __init__(self):
 *         self.compact=[]             # <<<<<<<<<<<<<<
 *         self.loose=VecI2()
 *         self.loose.vec.reserve(100000)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1909
 *     def __init__(self):
 *         self.compact=[]
 *         self.loose=VecI2()             # <<<<<<<<<<<<<<
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1910
 *         self.compact=[]
 *         self.loose=VecI2()
 *         self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 */
  __pyx_v_self->loose->vec.reserve(100000);

  /* "lurrn/sparsmat.pyx":1907
 *     cdef public object compact
 *     cdef public VecI2 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecI2()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI2.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1911
 *         self.loose=VecI2()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ensure_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_2ensure_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":1912
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *         self.loose=VecI2()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":1913
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *         self.loose=VecI2()
 *         while len(self.compact)>=2:
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":1914
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 *         self.loose=VecI2()             # <<<<<<<<<<<<<<
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":1915
 *             self.compact.append(self.loose)
 *         self.loose=VecI2()
 *         while len(self.compact)>=2:             # <<<<<<<<<<<<<<
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 */
  while (1) {
    __pyx_t_2 = __pyx_v_self->compact;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = ((__pyx_t_6 >= 2) != 0);
    if (!__pyx_t_4) break;

    /* "lurrn/sparsmat.pyx":1916
 *         self.loose=VecI2()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.loose.c_add(k0,k1, item)
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_1, -2, 0, NULL, NULL, &__pyx_slice__12, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1911
 *         self.loose=VecI2()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI2.ensure_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1917
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0,k1, item)
 *         if self.loose.get_size(False)>=100000:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  PyObject *__pyx_v_item = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,&__pyx_n_s_item,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_item);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_item = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI2.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_4add_count(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1, __pyx_v_item);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":1918
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.loose.c_add(k0,k1, item)             # <<<<<<<<<<<<<<
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_item); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_self->loose->__pyx_vtab)->c_add(__pyx_v_self->loose, __pyx_v_k0, __pyx_v_k1, __pyx_t_1);

  /* "lurrn/sparsmat.pyx":1919
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.loose.c_add(k0,k1, item)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_int_100000, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":1920
 *         self.loose.c_add(k0,k1, item)
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *             self.loose=VecI2()
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_self->loose->__pyx_vtab)->ensure_compact(__pyx_v_self->loose);

    /* "lurrn/sparsmat.pyx":1921
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *             self.loose=VecI2()
 *             self.loose.vec.reserve(100000)
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lurrn/sparsmat.pyx":1922
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 *             self.loose=VecI2()             # <<<<<<<<<<<<<<
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 */
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->loose);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
    __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":1923
 *             self.compact.append(self.loose)
 *             self.loose=VecI2()
 *             self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 */
    __pyx_v_self->loose->vec.reserve(100000);

    /* "lurrn/sparsmat.pyx":1924
 *             self.loose=VecI2()
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and             # <<<<<<<<<<<<<<
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
    while (1) {
      __pyx_t_2 = __pyx_v_self->compact;
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_7 = ((__pyx_t_6 >= 2) != 0);
      if (__pyx_t_7) {
      } else {
        __pyx_t_4 = __pyx_t_7;
        goto __pyx_L6_bool_binop_done;
      }

      /* "lurrn/sparsmat.pyx":1925
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):             # <<<<<<<<<<<<<<
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 */
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1925; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1925; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyNumber_Multiply(__pyx_float_0_6, __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_2, __pyx_t_9, Py_GE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_4 = __pyx_t_7;
      __pyx_L6_bool_binop_done:;
      if (!__pyx_t_4) break;

      /* "lurrn/sparsmat.pyx":1926
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1926; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1926; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = PyNumber_Add(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyList_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_9, -2, 0, NULL, NULL, &__pyx_slice__14, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":1917
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0,k1, item)
 *         if self.loose.get_size(False)>=100000:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI2.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1927
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_6get_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_compact", 0);

  /* "lurrn/sparsmat.pyx":1928
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         if len(self.compact)>0:
 *             return self.compact[0]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1929
 *     def get_compact(self):
 *         self.ensure_compact()
 *         if len(self.compact)>0:             # <<<<<<<<<<<<<<
 *             return self.compact[0]
 *         else:
 */
  __pyx_t_1 = __pyx_v_self->compact;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((__pyx_t_4 > 0) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":1930
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 *             return self.compact[0]             # <<<<<<<<<<<<<<
 *         else:
 *             return VecI2()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1930; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":1932
 *             return self.compact[0]
 *         else:
 *             return VecI2()             # <<<<<<<<<<<<<<
 *     def get_size(self, compactify=True):
 *         cdef int n
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1927
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI2.get_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1933
 *         else:
 *             return VecI2()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1933; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1933; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI2.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_8get_size(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  int __pyx_v_n;
  PyObject *__pyx_v_c = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":1935
 *     def get_size(self, compactify=True):
 *         cdef int n
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *             if self.compact:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":1936
 *         cdef int n
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *             if self.compact:
 *                 return self.compact[0].get_size()
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":1937
 *         if compactify:
 *             self.ensure_compact()
 *             if self.compact:             # <<<<<<<<<<<<<<
 *                 return self.compact[0].get_size()
 *             else:
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->compact); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":1938
 *             self.ensure_compact()
 *             if self.compact:
 *                 return self.compact[0].get_size()             # <<<<<<<<<<<<<<
 *             else:
 *                 return 0
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1938; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":1940
 *                 return self.compact[0].get_size()
 *             else:
 *                 return 0             # <<<<<<<<<<<<<<
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_int_0);
      __pyx_r = __pyx_int_0;
      goto __pyx_L0;
    }
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":1942
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_v_self->compact)) || PyTuple_CheckExact(__pyx_v_self->compact)) {
      __pyx_t_4 = __pyx_v_self->compact; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_self->compact); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_get_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":1943
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":1944
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)
 *             return n             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         self.ensure_compact()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1933
 *         else:
 *             return VecI2()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI2.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_c);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1945
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_11__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_11__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_10__iter__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":1946
 *             return n
 *     def __iter__(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         try:
 *             return iter(self.compact[0])
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1947
 *     def __iter__(self):
 *         self.ensure_compact()
 *         try:             # <<<<<<<<<<<<<<
 *             return iter(self.compact[0])
 *         except IndexError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "lurrn/sparsmat.pyx":1948
 *         self.ensure_compact()
 *         try:
 *             return iter(self.compact[0])             # <<<<<<<<<<<<<<
 *         except IndexError:
 *             return iter([])
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1948; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1948; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L7_try_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":1949
 *         try:
 *             return iter(self.compact[0])
 *         except IndexError:             # <<<<<<<<<<<<<<
 *             return iter([])
 * 
 */
    __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_IndexError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI2.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1949; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_3);

      /* "lurrn/sparsmat.pyx":1950
 *             return iter(self.compact[0])
 *         except IndexError:
 *             return iter([])             # <<<<<<<<<<<<<<
 * 
 *     cpdef CSRMatrixI to_csr(self):
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1950; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1950; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_r = __pyx_t_9;
      __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":1945
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI2.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1952
 *             return iter([])
 * 
 *     cpdef CSRMatrixI to_csr(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return self.compact[0].to_csr()
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_13to_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_f_5lurrn_8sparsmat_10LargeVecI2_to_csr(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self, int __pyx_skip_dispatch) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_csr", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_to_csr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_13to_csr)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1953
 * 
 *     cpdef CSRMatrixI to_csr(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return self.compact[0].to_csr()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1954
 *     cpdef CSRMatrixI to_csr(self):
 *         self.ensure_compact()
 *         return self.compact[0].to_csr()             # <<<<<<<<<<<<<<
 * 
 *     def get_type_counts(self, k=0):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1954; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_to_csr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1952
 *             return iter([])
 * 
 *     cpdef CSRMatrixI to_csr(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return self.compact[0].to_csr()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI2.to_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_13to_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_13to_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_csr (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_12to_csr(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_12to_csr(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_csr", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10LargeVecI2_to_csr(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI2.to_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1956
 *         return self.compact[0].to_csr()
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_15get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_15get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_14get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_14get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);

  /* "lurrn/sparsmat.pyx":1957
 * 
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)             # <<<<<<<<<<<<<<
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_k);
    __Pyx_GIVEREF(__pyx_v_k);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1956
 *         return self.compact[0].to_csr()
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1958
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_17remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_17remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  PyObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1958; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1958; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = values[0];
    __pyx_v_filt = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1958; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_16remap(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_16remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);

  /* "lurrn/sparsmat.pyx":1959
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_remap); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_v_k);
  PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_k);
  __Pyx_GIVEREF(__pyx_v_k);
  __Pyx_INCREF(__pyx_v_filt);
  PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_filt);
  __Pyx_GIVEREF(__pyx_v_filt);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1958
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1905
 * 
 * cdef class LargeVecI2:
 *     cdef public object compact             # <<<<<<<<<<<<<<
 *     cdef public VecI2 loose
 *     def __init__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_7compact_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_7compact_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_7compact___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->compact);
  __pyx_r = __pyx_v_self->compact;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI2_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI2_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_7compact_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI2_7compact_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI2_7compact_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_7compact_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1906
 * cdef class LargeVecI2:
 *     cdef public object compact
 *     cdef public VecI2 loose             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *         self.compact=[]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_5loose_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_5loose_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_5loose___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI2_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->loose));
  __pyx_r = ((PyObject *)__pyx_v_self->loose);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI2_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI2_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_5loose_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5lurrn_8sparsmat_VecI2))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI2.loose.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI2_5loose_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI2_5loose_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_5loose_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI2_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1966
 * cdef class VecI3:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_5VecI3_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_5VecI3_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI3___init__(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_5VecI3___init__(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":1967
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     def item_iter(self):
 *         self.ensure_compact()
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":1966
 * cdef class VecI3:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1968
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecI3_iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("item_iter (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI3_2item_iter(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("item_iter", 0);

  /* "lurrn/sparsmat.pyx":1969
 *         self.is_compact=True
 *     def item_iter(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return IVecI3_iter(self)
 *     def get_size(self,compactify=True):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":1970
 *     def item_iter(self):
 *         self.ensure_compact()
 *         return IVecI3_iter(self)             # <<<<<<<<<<<<<<
 *     def get_size(self,compactify=True):
 *         if compactify:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_IVecI3_iter)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1968
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecI3_iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.item_iter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1971
 *         self.ensure_compact()
 *         return IVecI3_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1971; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1971; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI3_4get_size(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":1972
 *         return IVecI3_iter(self)
 *     def get_size(self,compactify=True):
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *         return self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":1973
 *     def get_size(self,compactify=True):
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return self.vec.size()
 *     def __len__(self):
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":1974
 *         if compactify:
 *             self.ensure_compact()
 *         return self.vec.size()             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return self.get_size(True)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_self->vec.size()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1971
 *         self.ensure_compact()
 *         return IVecI3_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1975
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecI3_7__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecI3_7__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI3_6__len__(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecI3_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":1976
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1975
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1977
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI3_8clear(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear", 0);

  /* "lurrn/sparsmat.pyx":1978
 *         return self.get_size(True)
 *     def clear(self):
 *         self.vec.resize(0)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void compactify(self):
 */
  __pyx_v_self->vec.resize(0);

  /* "lurrn/sparsmat.pyx":1979
 *     def clear(self):
 *         self.vec.resize(0)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrI3 comp
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":1977
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1980
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrI3 comp
 *         c_IVecI3_sort(self.vec.begin(),self.vec.end(),comp)
 */

static void __pyx_f_5lurrn_8sparsmat_5VecI3_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self) {
  struct smallerAddr<3,int> __pyx_v_comp;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compactify", 0);

  /* "lurrn/sparsmat.pyx":1982
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrI3 comp
 *         c_IVecI3_sort(self.vec.begin(),self.vec.end(),comp)             # <<<<<<<<<<<<<<
 *         c_compactifyI3(&self.vec)
 *         self.is_compact=True
 */
  sort(__pyx_v_self->vec.begin(), __pyx_v_self->vec.end(), __pyx_v_comp);

  /* "lurrn/sparsmat.pyx":1983
 *         cdef c_SmallerAddrI3 comp
 *         c_IVecI3_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyI3(&self.vec)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 */
  compactify((&__pyx_v_self->vec));

  /* "lurrn/sparsmat.pyx":1984
 *         c_IVecI3_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyI3(&self.vec)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":1980
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrI3 comp
 *         c_IVecI3_sort(self.vec.begin(),self.vec.end(),comp)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":1985
 *         c_compactifyI3(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

static void __pyx_f_5lurrn_8sparsmat_5VecI3_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":1986
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:             # <<<<<<<<<<<<<<
 *             self.compactify()
 *     cpdef int get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):
 */
  __pyx_t_1 = ((!(__pyx_v_self->is_compact != 0)) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":1987
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 *             self.compactify()             # <<<<<<<<<<<<<<
 *     cpdef int get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):
 *         cdef c_CItemI3 ci
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI3 *)__pyx_v_self->__pyx_vtab)->compactify(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":1985
 *         c_compactifyI3(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":1988
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef int get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI3 ci
 *         ci.addr[0]=k0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecI3_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, int __pyx_skip_dispatch) {
  struct CountItem<3,int> __pyx_v_ci;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI3_11get_count)) {
      __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_6 = __pyx_t_1; __pyx_t_7 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
          __pyx_t_8 = 1;
        }
      }
      __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_5 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_10;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":1990
 *     cpdef int get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):
 *         cdef c_CItemI3 ci
 *         ci.addr[0]=k0             # <<<<<<<<<<<<<<
 *         ci.addr[1]=k1
 *         ci.addr[2]=k2
 */
  (__pyx_v_ci.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":1991
 *         cdef c_CItemI3 ci
 *         ci.addr[0]=k0
 *         ci.addr[1]=k1             # <<<<<<<<<<<<<<
 *         ci.addr[2]=k2
 *         return c_get_countI3(&self.vec,ci)
 */
  (__pyx_v_ci.addr[1]) = __pyx_v_k1;

  /* "lurrn/sparsmat.pyx":1992
 *         ci.addr[0]=k0
 *         ci.addr[1]=k1
 *         ci.addr[2]=k2             # <<<<<<<<<<<<<<
 *         return c_get_countI3(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, int item):
 */
  (__pyx_v_ci.addr[2]) = __pyx_v_k2;

  /* "lurrn/sparsmat.pyx":1993
 *         ci.addr[1]=k1
 *         ci.addr[2]=k2
 *         return c_get_countI3(&self.vec,ci)             # <<<<<<<<<<<<<<
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, int item):
 *         cdef c_CItemI3 c
 */
  __pyx_r = get_count_v((&__pyx_v_self->vec), __pyx_v_ci);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":1988
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef int get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI3 ci
 *         ci.addr[0]=k0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecI3.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,&__pyx_n_s_k2,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_count", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1988; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_count", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1988; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1988; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1988; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1988; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k2 = __Pyx_PyInt_As_coordinate_t(values[2]); if (unlikely((__pyx_v_k2 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1988; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_count", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1988; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI3_10get_count(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1, __pyx_v_k2);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_5lurrn_8sparsmat_5VecI3_get_count(__pyx_v_self, __pyx_v_k0, __pyx_v_k1, __pyx_v_k2, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":1994
 *         ci.addr[2]=k2
 *         return c_get_countI3(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, int item):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI3 c
 *         c.addr[0]=k0
 */

static void __pyx_f_5lurrn_8sparsmat_5VecI3_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, int __pyx_v_item) {
  struct CountItem<3,int> __pyx_v_c;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_add", 0);

  /* "lurrn/sparsmat.pyx":1996
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, int item):
 *         cdef c_CItemI3 c
 *         c.addr[0]=k0             # <<<<<<<<<<<<<<
 *         c.addr[1]=k1
 *         c.addr[2]=k2
 */
  (__pyx_v_c.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":1997
 *         cdef c_CItemI3 c
 *         c.addr[0]=k0
 *         c.addr[1]=k1             # <<<<<<<<<<<<<<
 *         c.addr[2]=k2
 *         c.item=item
 */
  (__pyx_v_c.addr[1]) = __pyx_v_k1;

  /* "lurrn/sparsmat.pyx":1998
 *         c.addr[0]=k0
 *         c.addr[1]=k1
 *         c.addr[2]=k2             # <<<<<<<<<<<<<<
 *         c.item=item
 *         self.vec.push_back(c)
 */
  (__pyx_v_c.addr[2]) = __pyx_v_k2;

  /* "lurrn/sparsmat.pyx":1999
 *         c.addr[1]=k1
 *         c.addr[2]=k2
 *         c.item=item             # <<<<<<<<<<<<<<
 *         self.vec.push_back(c)
 *         self.is_compact=False
 */
  __pyx_v_c.item = __pyx_v_item;

  /* "lurrn/sparsmat.pyx":2000
 *         c.addr[2]=k2
 *         c.item=item
 *         self.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 */
  __pyx_v_self->vec.push_back(__pyx_v_c);

  /* "lurrn/sparsmat.pyx":2001
 *         c.item=item
 *         self.vec.push_back(c)
 *         self.is_compact=False             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.c_add(k0,k1,k2, item)
 */
  __pyx_v_self->is_compact = 0;

  /* "lurrn/sparsmat.pyx":1994
 *         ci.addr[2]=k2
 *         return c_get_countI3(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, int item):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI3 c
 *         c.addr[0]=k0
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":2002
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1,k2, item)
 *     def __add__(VecI3 self, VecI3 other):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  PyObject *__pyx_v_item = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,&__pyx_n_s_k2,&__pyx_n_s_item,0};
    PyObject* values[4] = {0,0,0,0};
    values[3] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 0, 3, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 0, 3, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_item);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k2 = __Pyx_PyInt_As_coordinate_t(values[2]); if (unlikely((__pyx_v_k2 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_item = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI3_12add_count(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1, __pyx_v_k2, __pyx_v_item);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":2003
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.c_add(k0,k1,k2, item)             # <<<<<<<<<<<<<<
 *     def __add__(VecI3 self, VecI3 other):
 *         cdef c_CItemI3 c1, c2
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_item); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI3 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_v_k0, __pyx_v_k1, __pyx_v_k2, __pyx_t_1);

  /* "lurrn/sparsmat.pyx":2002
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1,k2, item)
 *     def __add__(VecI3 self, VecI3 other):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2004
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.c_add(k0,k1,k2, item)
 *     def __add__(VecI3 self, VecI3 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI3 c1, c2
 *         cdef unsigned int i1, i2
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_VecI3, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_VecI3, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI3_14__add__(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_other) {
  struct CountItem<3,int> __pyx_v_c1;
  struct CountItem<3,int> __pyx_v_c2;
  unsigned int __pyx_v_i1;
  unsigned int __pyx_v_i2;
  int __pyx_v_k;
  int __pyx_v_delta;
  struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":2009
 *         cdef int k, delta
 *         cdef VecI3 result
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         other.ensure_compact()
 *         result=VecI3()
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":2010
 *         cdef VecI3 result
 *         self.ensure_compact()
 *         other.ensure_compact()             # <<<<<<<<<<<<<<
 *         result=VecI3()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI3 *)__pyx_v_other->__pyx_vtab)->ensure_compact(__pyx_v_other);

  /* "lurrn/sparsmat.pyx":2011
 *         self.ensure_compact()
 *         other.ensure_compact()
 *         result=VecI3()             # <<<<<<<<<<<<<<
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2012
 *         other.ensure_compact()
 *         result=VecI3()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))             # <<<<<<<<<<<<<<
 *         i1=0
 *         i2=0
 */
  __pyx_t_2 = __pyx_v_other->vec.size();
  __pyx_t_3 = __pyx_v_self->vec.size();
  if (((__pyx_t_2 > __pyx_t_3) != 0)) {
    __pyx_t_4 = __pyx_t_2;
  } else {
    __pyx_t_4 = __pyx_t_3;
  }
  __pyx_v_result->vec.reserve(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":2013
 *         result=VecI3()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0             # <<<<<<<<<<<<<<
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 */
  __pyx_v_i1 = 0;

  /* "lurrn/sparsmat.pyx":2014
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 *         i2=0             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 */
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":2015
 *         i1=0
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 */
  while (1) {
    __pyx_t_6 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_6 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":2016
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             delta=0
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":2017
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             delta=0
 *             for k from 0<=k<3:
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":2018
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 *             delta=0             # <<<<<<<<<<<<<<
 *             for k from 0<=k<3:
 *                 if c1.addr[k]<c2.addr[k]:
 */
    __pyx_v_delta = 0;

    /* "lurrn/sparsmat.pyx":2019
 *             c2=other.vec.at(i2)
 *             delta=0
 *             for k from 0<=k<3:             # <<<<<<<<<<<<<<
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 */
    for (__pyx_v_k = 0; __pyx_v_k < 3; __pyx_v_k++) {

      /* "lurrn/sparsmat.pyx":2020
 *             delta=0
 *             for k from 0<=k<3:
 *                 if c1.addr[k]<c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=-1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) < (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":2021
 *             for k from 0<=k<3:
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1             # <<<<<<<<<<<<<<
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 */
        __pyx_v_delta = -1;

        /* "lurrn/sparsmat.pyx":2022
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 *                     break             # <<<<<<<<<<<<<<
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 */
        goto __pyx_L8_break;
      }

      /* "lurrn/sparsmat.pyx":2023
 *                     delta=-1
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) > (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":2024
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1             # <<<<<<<<<<<<<<
 *                     break
 *             if delta==0:
 */
        __pyx_v_delta = 1;

        /* "lurrn/sparsmat.pyx":2025
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 *                     break             # <<<<<<<<<<<<<<
 *             if delta==0:
 *                 c1.item+=c2.item
 */
        goto __pyx_L8_break;
      }
    }
    __pyx_L8_break:;

    /* "lurrn/sparsmat.pyx":2031
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
    switch (__pyx_v_delta) {

      /* "lurrn/sparsmat.pyx":2026
 *                     delta=1
 *                     break
 *             if delta==0:             # <<<<<<<<<<<<<<
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)
 */
      case 0:

      /* "lurrn/sparsmat.pyx":2027
 *                     break
 *             if delta==0:
 *                 c1.item+=c2.item             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      __pyx_v_c1.item = (__pyx_v_c1.item + __pyx_v_c2.item);

      /* "lurrn/sparsmat.pyx":2028
 *             if delta==0:
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *                 i2+=1
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":2029
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *                 i2+=1
 *             elif delta==-1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);

      /* "lurrn/sparsmat.pyx":2030
 *                 result.vec.push_back(c1)
 *                 i1+=1
 *                 i2+=1             # <<<<<<<<<<<<<<
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;

      /* "lurrn/sparsmat.pyx":2031
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      case -1:

      /* "lurrn/sparsmat.pyx":2032
 *                 i2+=1
 *             elif delta==-1:
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             else:
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":2033
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             else:
 *                 result.vec.push_back(c2)
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      break;
      default:

      /* "lurrn/sparsmat.pyx":2035
 *                 i1+=1
 *             else:
 *                 result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *                 i2+=1
 *         while i1<self.vec.size():
 */
      __pyx_v_result->vec.push_back(__pyx_v_c2);

      /* "lurrn/sparsmat.pyx":2036
 *             else:
 *                 result.vec.push_back(c2)
 *                 i2+=1             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;
    }
  }

  /* "lurrn/sparsmat.pyx":2037
 *                 result.vec.push_back(c2)
 *                 i2+=1
 *         while i1<self.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":2038
 *                 i2+=1
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c1)
 *             i1+=1
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":2039
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *             i1+=1
 *         while i2<other.vec.size():
 */
    __pyx_v_result->vec.push_back(__pyx_v_c1);

    /* "lurrn/sparsmat.pyx":2040
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 *             i1+=1             # <<<<<<<<<<<<<<
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);
  }

  /* "lurrn/sparsmat.pyx":2041
 *             result.vec.push_back(c1)
 *             i1+=1
 *         while i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":2042
 *             i1+=1
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c2)
 *             i2+=1
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":2043
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *             i2+=1
 *         return result
 */
    __pyx_v_result->vec.push_back(__pyx_v_c2);

    /* "lurrn/sparsmat.pyx":2044
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 *             i2+=1             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_v_i2 = (__pyx_v_i2 + 1);
  }

  /* "lurrn/sparsmat.pyx":2045
 *             result.vec.push_back(c2)
 *             i2+=1
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def tofile(self, f):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2004
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.c_add(k0,k1,k2, item)
 *     def __add__(VecI3 self, VecI3 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemI3 c1, c2
 *         cdef unsigned int i1, i2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2047
 *         return result
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_17tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_17tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tofile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI3_16tofile(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_16tofile(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  long __pyx_v_k;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  long __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("tofile", 0);

  /* "lurrn/sparsmat.pyx":2049
 *     def tofile(self, f):
 *         cdef long i, n, k, k_max
 *         n=self.get_size()             # <<<<<<<<<<<<<<
 *         f.write('I3 %d\n'%(n,))
 *         k=0
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":2050
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 *         f.write('I3 %d\n'%(n,))             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_I3_d, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2051
 *         n=self.get_size()
 *         f.write('I3 %d\n'%(n,))
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecI3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemI3))
 */
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":2052
 *         f.write('I3 %d\n'%(n,))
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecI3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemI3))
 *             f.write(s)
 */
  __pyx_t_4 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2053
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecI3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemI3))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *             k+=CHUNK_SIZE
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), (256 * (sizeof(struct CountItem<3,int>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":2054
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecI3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemI3))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":2055
 *             s=PyString_FromStringAndSize(<char *>c_VecI3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemI3))
 *             f.write(s)
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecI3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemI3))
 */
    __pyx_v_k = (__pyx_v_k + 256);
  }

  /* "lurrn/sparsmat.pyx":2056
 *             f.write(s)
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecI3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemI3))
 *             f.write(s)
 */
  __pyx_t_7 = ((__pyx_v_k < __pyx_v_n) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":2057
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecI3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemI3))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *     def fromfile(self, f):
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), ((__pyx_v_n - __pyx_v_k) * (sizeof(struct CountItem<3,int>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":2058
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecI3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemI3))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *     def fromfile(self, f):
 *         cdef long i, n
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":2047
 *         return result
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.tofile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2059
 *             s=PyString_FromStringAndSize(<char *>c_VecI3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemI3))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_19fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_19fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fromfile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI3_18fromfile(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_18fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  PyObject *__pyx_v_line = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  long __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  size_t __pyx_t_9;
  char *__pyx_t_10;
  size_t __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromfile", 0);

  /* "lurrn/sparsmat.pyx":2061
 *     def fromfile(self, f):
 *         cdef long i, n
 *         line=f.readline().strip().split()             # <<<<<<<<<<<<<<
 *         assert line[0]=='I3'
 *         n=long(line[1])
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_readline); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_line = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2062
 *         cdef long i, n
 *         line=f.readline().strip().split()
 *         assert line[0]=='I3'             # <<<<<<<<<<<<<<
 *         n=long(line[1])
 *         self.clear()
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2062; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_I3, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_6)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":2063
 *         line=f.readline().strip().split()
 *         assert line[0]=='I3'
 *         n=long(line[1])             # <<<<<<<<<<<<<<
 *         self.clear()
 *         self.vec.resize(n)
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyLong_Type))), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_7;

  /* "lurrn/sparsmat.pyx":2064
 *         assert line[0]=='I3'
 *         n=long(line[1])
 *         self.clear()             # <<<<<<<<<<<<<<
 *         self.vec.resize(n)
 *         k=0
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clear); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2065
 *         n=long(line[1])
 *         self.clear()
 *         self.vec.resize(n)             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_v_self->vec.resize(__pyx_v_n);

  /* "lurrn/sparsmat.pyx":2066
 *         self.clear()
 *         self.vec.resize(n)
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemI3))
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_k = __pyx_int_0;

  /* "lurrn/sparsmat.pyx":2067
 *         self.vec.resize(n)
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemI3))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemI3)
 */
  __pyx_t_7 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2068
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemI3))             # <<<<<<<<<<<<<<
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemI3)
 *             memcpy(<void *>c_VecI3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemI3))
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyInt_FromSize_t((256 * (sizeof(struct CountItem<3,int>)))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":2069
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemI3))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemI3)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecI3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemI3))
 *             k+=CHUNK_SIZE
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!((__pyx_t_8 == (256 * (sizeof(struct CountItem<3,int>)))) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":2070
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemI3))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemI3)
 *             memcpy(<void *>c_VecI3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemI3))             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), (256 * (sizeof(struct CountItem<3,int>))));

    /* "lurrn/sparsmat.pyx":2071
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemI3)
 *             memcpy(<void *>c_VecI3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemI3))
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemI3))
 */
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_k, __pyx_int_256); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_1);
    __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2072
 *             memcpy(<void *>c_VecI3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemI3))
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=f.read((n-k)*sizeof(c_CItemI3))
 *             assert len(s)==(n-k)*sizeof(c_CItemI3)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":2073
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemI3))             # <<<<<<<<<<<<<<
 *             assert len(s)==(n-k)*sizeof(c_CItemI3)
 *             memcpy(<void *>c_VecI3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemI3))
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_5, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<3,int>))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":2074
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemI3))
 *             assert len(s)==(n-k)*sizeof(c_CItemI3)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecI3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemI3))
 *     cpdef int get_maxcol(self, int k=0):
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<3,int>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_6)) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":2075
 *             s=f.read((n-k)*sizeof(c_CItemI3))
 *             assert len(s)==(n-k)*sizeof(c_CItemI3)
 *             memcpy(<void *>c_VecI3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemI3))             # <<<<<<<<<<<<<<
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<3,int>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), __pyx_t_11);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":2059
 *             s=PyString_FromStringAndSize(<char *>c_VecI3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemI3))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.fromfile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_line);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2076
 *             assert len(s)==(n-k)*sizeof(c_CItemI3)
 *             memcpy(<void *>c_VecI3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemI3))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<3
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_21get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecI3_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI3_get_maxcol *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_i;
  int __pyx_v_n;
  int __pyx_v_new_val;
  int __pyx_v_col;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_maxcol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI3_21get_maxcol)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2078
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<3             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         if n==0:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_9 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_9 = ((__pyx_v_k < 3) != 0);
    __pyx_t_8 = __pyx_t_9;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_8)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":2079
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<3
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         if n==0:
 *             return -1
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":2080
 *         assert k>=0 and k<3
 *         n=self.vec.size()
 *         if n==0:             # <<<<<<<<<<<<<<
 *             return -1
 *         if k==0:
 */
  __pyx_t_8 = ((__pyx_v_n == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":2081
 *         n=self.vec.size()
 *         if n==0:
 *             return -1             # <<<<<<<<<<<<<<
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 */
    __pyx_r = -1;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":2082
 *         if n==0:
 *             return -1
 *         if k==0:             # <<<<<<<<<<<<<<
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 */
  __pyx_t_8 = ((__pyx_v_k == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":2083
 *             return -1
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]             # <<<<<<<<<<<<<<
 *         col=-1
 *         n=self.vec.size()
 */
    __pyx_r = (__pyx_v_self->vec.at((__pyx_v_n - 1)).addr[0]);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":2084
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 *         col=-1             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_v_col = -1;

  /* "lurrn/sparsmat.pyx":2085
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":2086
 *         col=-1
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 */
  __pyx_t_7 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2087
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             if new_val>col:
 *                 col=new_val
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":2088
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:             # <<<<<<<<<<<<<<
 *                 col=new_val
 *         return col
 */
    __pyx_t_8 = ((__pyx_v_new_val > __pyx_v_col) != 0);
    if (__pyx_t_8) {

      /* "lurrn/sparsmat.pyx":2089
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 *                 col=new_val             # <<<<<<<<<<<<<<
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 */
      __pyx_v_col = __pyx_v_new_val;
      goto __pyx_L9;
    }
    __pyx_L9:;
  }

  /* "lurrn/sparsmat.pyx":2090
 *             if new_val>col:
 *                 col=new_val
 *         return col             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 *         cdef int old_val, new_val, i, n, count
 */
  __pyx_r = __pyx_v_col;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2076
 *             assert len(s)==(n-k)*sizeof(c_CItemI3)
 *             memcpy(<void *>c_VecI3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemI3))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<3
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecI3.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_21get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_21get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_maxcol (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_maxcol") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2076; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2076; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_maxcol", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2076; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI3_20get_maxcol(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_20get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecI3_get_maxcol __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = __pyx_vtabptr_5lurrn_8sparsmat_VecI3->get_maxcol(__pyx_v_self, 1, &__pyx_t_2); 
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2091
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_23get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecI3_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI3_get_type_counts *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_new_val;
  int __pyx_v_i;
  int __pyx_v_n;
  PyArrayObject *__pyx_v_result = 0;
  long __pyx_v_n_types;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecI3_get_maxcol __pyx_t_11;
  PyArrayObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI3_23get_type_counts)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2094
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<3             # <<<<<<<<<<<<<<
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_8 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_k < 3) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_7)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":2095
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<3
 *         if self.vec.size()==0:             # <<<<<<<<<<<<<<
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 */
  __pyx_t_7 = ((__pyx_v_self->vec.size() == 0) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":2096
 *         assert k>=0 and k<3
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_9 = 1;
      }
    }
    __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_2) {
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":2097
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":2098
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1             # <<<<<<<<<<<<<<
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 */
  __pyx_t_11.__pyx_n = 1;
  __pyx_t_11.k = __pyx_v_k;
  __pyx_t_10 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI3 *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0, &__pyx_t_11); 
  __pyx_v_n_types = (__pyx_t_10 + 1);

  /* "lurrn/sparsmat.pyx":2099
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_n_types); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_9 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_6) {
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_12 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
    }
    __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_12 = 0;
  __pyx_v_result = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2100
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":2101
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2102
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             result[new_val]+=1
 *         return result
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":2103
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1             # <<<<<<<<<<<<<<
 *         return result
 *     cpdef VecI3 remap(self, int k, numpy.ndarray filt):
 */
    __pyx_t_16 = __pyx_v_new_val;
    __pyx_t_17 = -1;
    if (__pyx_t_16 < 0) {
      __pyx_t_16 += __pyx_pybuffernd_result.diminfo[0].shape;
      if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 0;
    } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_17 = 0;
    if (unlikely(__pyx_t_17 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_17);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_result.diminfo[0].strides) += 1;
  }

  /* "lurrn/sparsmat.pyx":2104
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 *         return result             # <<<<<<<<<<<<<<
 *     cpdef VecI3 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyArrayObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2091
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_23get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_23get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI3_22get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_22get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecI3_get_type_counts __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_5lurrn_8sparsmat_VecI3->get_type_counts(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2105
 *             result[new_val]+=1
 *         return result
 *     cpdef VecI3 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_25remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_f_5lurrn_8sparsmat_5VecI3_remap(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_wanted = 0;
  PyArrayObject *__pyx_v_target = 0;
  int __pyx_v_n;
  int __pyx_v_i;
  struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_result = 0;
  struct CountItem<3,int> __pyx_v_c;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_target;
  __Pyx_Buffer __pyx_pybuffer_target;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_wanted;
  __Pyx_Buffer __pyx_pybuffer_wanted;
  struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __pyx_pybuffer_wanted.pybuffer.buf = NULL;
  __pyx_pybuffer_wanted.refcount = 0;
  __pyx_pybuffernd_wanted.data = NULL;
  __pyx_pybuffernd_wanted.rcbuffer = &__pyx_pybuffer_wanted;
  __pyx_pybuffer_target.pybuffer.buf = NULL;
  __pyx_pybuffer_target.refcount = 0;
  __pyx_pybuffernd_target.data = NULL;
  __pyx_pybuffernd_target.rcbuffer = &__pyx_pybuffer_target;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_remap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI3_25remap)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_filt));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_filt));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_filt));
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_VecI3))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2106
 *         return result
 *     cpdef VecI3 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_wanted = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_wanted.diminfo[0].strides = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_wanted.diminfo[0].shape = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_8 = 0;
  __pyx_v_wanted = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":2107
 *     cpdef VecI3 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_cumsum); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Subtract(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_target = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_target.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_target.diminfo[0].strides = __pyx_pybuffernd_target.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_target.diminfo[0].shape = __pyx_pybuffernd_target.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_9 = 0;
  __pyx_v_target = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2108
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         cdef int n=self.vec.size()
 *         cdef int i
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":2109
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()             # <<<<<<<<<<<<<<
 *         cdef int i
 *         cdef VecI3 result=VecI3()
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":2111
 *         cdef int n=self.vec.size()
 *         cdef int i
 *         cdef VecI3 result=VecI3()             # <<<<<<<<<<<<<<
 *         cdef c_CItemI3 c
 *         for i from 0<=i<n:
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2113
 *         cdef VecI3 result=VecI3()
 *         cdef c_CItemI3 c
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2114
 *         cdef c_CItemI3 c
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)             # <<<<<<<<<<<<<<
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 */
    __pyx_v_c = __pyx_v_self->vec.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":2115
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:             # <<<<<<<<<<<<<<
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 */
    __pyx_t_11 = (__pyx_v_c.addr[__pyx_v_k]);
    __pyx_t_12 = -1;
    if (__pyx_t_11 < 0) {
      __pyx_t_11 += __pyx_pybuffernd_wanted.diminfo[0].shape;
      if (unlikely(__pyx_t_11 < 0)) __pyx_t_12 = 0;
    } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_wanted.diminfo[0].shape)) __pyx_t_12 = 0;
    if (unlikely(__pyx_t_12 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_12);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_wanted.diminfo[0].strides)) != 0);
    if (__pyx_t_13) {

      /* "lurrn/sparsmat.pyx":2116
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c)
 *         return result
 */
      __pyx_t_12 = (__pyx_v_c.addr[__pyx_v_k]);
      __pyx_t_14 = -1;
      if (__pyx_t_12 < 0) {
        __pyx_t_12 += __pyx_pybuffernd_target.diminfo[0].shape;
        if (unlikely(__pyx_t_12 < 0)) __pyx_t_14 = 0;
      } else if (unlikely(__pyx_t_12 >= __pyx_pybuffernd_target.diminfo[0].shape)) __pyx_t_14 = 0;
      if (unlikely(__pyx_t_14 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_14);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      (__pyx_v_c.addr[__pyx_v_k]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_target.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_target.diminfo[0].strides));

      /* "lurrn/sparsmat.pyx":2117
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         return result
 *     def append(self,tup):
 */
      __pyx_v_result->vec.push_back(__pyx_v_c);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "lurrn/sparsmat.pyx":2118
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 *         return result             # <<<<<<<<<<<<<<
 *     def append(self,tup):
 *         k0,k1,k2,val=tup
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2105
 *             result[new_val]+=1
 *         return result
 *     cpdef VecI3 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_wanted);
  __Pyx_XDECREF((PyObject *)__pyx_v_target);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_25remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_25remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_filt = ((PyArrayObject *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_filt), __pyx_ptype_5numpy_ndarray, 1, "filt", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI3_24remap(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_24remap(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_5VecI3_remap(__pyx_v_self, __pyx_v_k, __pyx_v_filt, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2119
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,k1,k2,val=tup
 *         self.c_add(k0,k1,k2,val)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_27append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_27append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("append (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI3_26append(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self), ((PyObject *)__pyx_v_tup));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_26append(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_k1 = NULL;
  PyObject *__pyx_v_k2 = NULL;
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  coordinate_t __pyx_t_7;
  coordinate_t __pyx_t_8;
  coordinate_t __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("append", 0);

  /* "lurrn/sparsmat.pyx":2120
 *         return result
 *     def append(self,tup):
 *         k0,k1,k2,val=tup             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1,k2,val)
 *     def extend(self,tups):
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_tup))) || (PyList_CheckExact(__pyx_v_tup))) {
    PyObject* sequence = __pyx_v_tup;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_2,&__pyx_t_3,&__pyx_t_4};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_2,&__pyx_t_3,&__pyx_t_4};
    __pyx_t_5 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_6(__pyx_t_5); if (unlikely(!item)) goto __pyx_L3_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_k0 = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_k1 = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_k2 = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_val = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "lurrn/sparsmat.pyx":2121
 *     def append(self,tup):
 *         k0,k1,k2,val=tup
 *         self.c_add(k0,k1,k2,val)             # <<<<<<<<<<<<<<
 *     def extend(self,tups):
 *         for k0,k1,k2,val in tups:
 */
  __pyx_t_7 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_7 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k1); if (unlikely((__pyx_t_8 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k2); if (unlikely((__pyx_t_9 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_val); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI3 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10);

  /* "lurrn/sparsmat.pyx":2119
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,k1,k2,val=tup
 *         self.c_add(k0,k1,k2,val)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_k1);
  __Pyx_XDECREF(__pyx_v_k2);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2122
 *         k0,k1,k2,val=tup
 *         self.c_add(k0,k1,k2,val)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,k1,k2,val in tups:
 *             self.c_add(k0,k1,k2,val)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_29extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_29extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extend (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI3_28extend(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self), ((PyObject *)__pyx_v_tups));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_28extend(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_k1 = NULL;
  PyObject *__pyx_v_k2 = NULL;
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  coordinate_t __pyx_t_11;
  coordinate_t __pyx_t_12;
  coordinate_t __pyx_t_13;
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("extend", 0);

  /* "lurrn/sparsmat.pyx":2123
 *         self.c_add(k0,k1,k2,val)
 *     def extend(self,tups):
 *         for k0,k1,k2,val in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,k1,k2,val)
 *     def __iter__(self):
 */
  if (likely(PyList_CheckExact(__pyx_v_tups)) || PyTuple_CheckExact(__pyx_v_tups)) {
    __pyx_t_1 = __pyx_v_tups; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_tups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 4)) {
        if (size > 4) __Pyx_RaiseTooManyValuesError(4);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); 
        __pyx_t_8 = PyTuple_GET_ITEM(sequence, 3); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 2); 
        __pyx_t_8 = PyList_GET_ITEM(sequence, 3); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_8);
      #else
      {
        Py_ssize_t i;
        PyObject** temps[4] = {&__pyx_t_5,&__pyx_t_6,&__pyx_t_7,&__pyx_t_8};
        for (i=0; i < 4; i++) {
          PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(item);
          *(temps[i]) = item;
        }
      }
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      PyObject** temps[4] = {&__pyx_t_5,&__pyx_t_6,&__pyx_t_7,&__pyx_t_8};
      __pyx_t_9 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
      for (index=0; index < 4; index++) {
        PyObject* item = __pyx_t_10(__pyx_t_9); if (unlikely(!item)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(item);
        *(temps[index]) = item;
      }
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_10 = NULL;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_10 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_k0, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_k1, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_k2, __pyx_t_7);
    __pyx_t_7 = 0;
    __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "lurrn/sparsmat.pyx":2124
 *     def extend(self,tups):
 *         for k0,k1,k2,val in tups:
 *             self.c_add(k0,k1,k2,val)             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self.item_iter()
 */
    __pyx_t_11 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_11 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_12 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k1); if (unlikely((__pyx_t_12 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_13 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k2); if (unlikely((__pyx_t_13 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_14 = __Pyx_PyInt_As_int(__pyx_v_val); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI3 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_11, __pyx_t_12, __pyx_t_13, __pyx_t_14);

    /* "lurrn/sparsmat.pyx":2123
 *         self.c_add(k0,k1,k2,val)
 *     def extend(self,tups):
 *         for k0,k1,k2,val in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,k1,k2,val)
 *     def __iter__(self):
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2122
 *         k0,k1,k2,val=tup
 *         self.c_add(k0,k1,k2,val)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,k1,k2,val in tups:
 *             self.c_add(k0,k1,k2,val)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.extend", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_k1);
  __Pyx_XDECREF(__pyx_v_k2);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2125
 *         for k0,k1,k2,val in tups:
 *             self.c_add(k0,k1,k2,val)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_31__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_31__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI3_30__iter__(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_30__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":2126
 *             self.c_add(k0,k1,k2,val)
 *     def __iter__(self):
 *         return self.item_iter()             # <<<<<<<<<<<<<<
 *     def __reduce__(self):
 *         return (VecI3,(),(),self.item_iter())
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2125
 *         for k0,k1,k2,val in tups:
 *             self.c_add(k0,k1,k2,val)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2127
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecI3,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_33__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_33__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI3_32__reduce__(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_32__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "lurrn/sparsmat.pyx":2128
 *         return self.item_iter()
 *     def __reduce__(self):
 *         return (VecI3,(),(),self.item_iter())             # <<<<<<<<<<<<<<
 *     def __setstate__(self,state):
 *         pass
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI3)));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI3)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI3)));
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2127
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecI3,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2129
 *     def __reduce__(self):
 *         return (VecI3,(),(),self.item_iter())
 *     def __setstate__(self,state):             # <<<<<<<<<<<<<<
 *         pass
 *     def __repr__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_35__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_35__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI3_34__setstate__(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self), ((PyObject *)__pyx_v_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_34__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2131
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecI3(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_37__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecI3_37__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecI3_36__repr__(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecI3_36__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "lurrn/sparsmat.pyx":2132
 *         pass
 *     def __repr__(self):
 *         return 'VecI3(%s)'%(str(list(self)),)             # <<<<<<<<<<<<<<
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_VecI3_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2131
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecI3(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecI3.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2133
 *     def __repr__(self):
 *         return 'VecI3(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

/* Python wrapper */
static void __pyx_pw_5lurrn_8sparsmat_5VecI3_39__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5lurrn_8sparsmat_5VecI3_39__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5lurrn_8sparsmat_5VecI3_38__dealloc__(((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5lurrn_8sparsmat_5VecI3_38__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lurrn/sparsmat.pyx":2135
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()             # <<<<<<<<<<<<<<
 * 
 * cdef class IVecI3_iter:
 */
  __pyx_v_self->vec.~vector();

  /* "lurrn/sparsmat.pyx":2133
 *     def __repr__(self):
 *         return 'VecI3(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":2141
 *     cdef c_VecI3 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_11IVecI3_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_11IVecI3_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_vec = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_vec,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_vec = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.IVecI3_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecI3_iter___init__(((struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter *)__pyx_v_self), __pyx_v_vec);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_11IVecI3_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter *__pyx_v_self, PyObject *__pyx_v_vec) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":2142
 *     cdef unsigned int k
 *     def __init__(self,vec):
 *         self.vec=vec             # <<<<<<<<<<<<<<
 *         self.vecC=&self.vec.vec
 *         self.k=0
 */
  if (!(likely(((__pyx_v_vec) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_vec, __pyx_ptype_5lurrn_8sparsmat_VecI3))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_vec;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->vec);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->vec));
  __pyx_v_self->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2143
 *     def __init__(self,vec):
 *         self.vec=vec
 *         self.vecC=&self.vec.vec             # <<<<<<<<<<<<<<
 *         self.k=0
 *     def __iter__(self):
 */
  __pyx_v_self->vecC = (&__pyx_v_self->vec->vec);

  /* "lurrn/sparsmat.pyx":2144
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 *         self.k=0             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self
 */
  __pyx_v_self->k = 0;

  /* "lurrn/sparsmat.pyx":2141
 *     cdef c_VecI3 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecI3_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2145
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecI3_iter_3__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecI3_iter_3__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecI3_iter_2__iter__(((struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecI3_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":2146
 *         self.k=0
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2145
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2147
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecI3_iter_5__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecI3_iter_5__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecI3_iter_4__next__(((struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecI3_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter *__pyx_v_self) {
  struct CountItem<3,int> __pyx_v_res;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "lurrn/sparsmat.pyx":2148
 *         return self
 *     def __next__(self):
 *         if self.k>=self.vecC.size():             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         cdef c_CItemI3 res=self.vecC.at(self.k)
 */
  __pyx_t_1 = ((__pyx_v_self->k >= __pyx_v_self->vecC->size()) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":2149
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         cdef c_CItemI3 res=self.vecC.at(self.k)
 *         self.k+=1
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lurrn/sparsmat.pyx":2150
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 *         cdef c_CItemI3 res=self.vecC.at(self.k)             # <<<<<<<<<<<<<<
 *         self.k+=1
 *         return (res.addr[0],
 */
  __pyx_v_res = __pyx_v_self->vecC->at(__pyx_v_self->k);

  /* "lurrn/sparsmat.pyx":2151
 *             raise StopIteration
 *         cdef c_CItemI3 res=self.vecC.at(self.k)
 *         self.k+=1             # <<<<<<<<<<<<<<
 *         return (res.addr[0],
 *                 res.addr[1],
 */
  __pyx_v_self->k = (__pyx_v_self->k + 1);

  /* "lurrn/sparsmat.pyx":2152
 *         cdef c_CItemI3 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.addr[1],
 *                 res.addr[2],
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_res.addr[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "lurrn/sparsmat.pyx":2153
 *         self.k+=1
 *         return (res.addr[0],
 *                 res.addr[1],             # <<<<<<<<<<<<<<
 *                 res.addr[2],
 *                 res.item)
 */
  __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_res.addr[1])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "lurrn/sparsmat.pyx":2154
 *         return (res.addr[0],
 *                 res.addr[1],
 *                 res.addr[2],             # <<<<<<<<<<<<<<
 *                 res.item)
 * 
 */
  __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_res.addr[2])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":2155
 *                 res.addr[1],
 *                 res.addr[2],
 *                 res.item)             # <<<<<<<<<<<<<<
 * 
 * cdef class LargeVecI3:
 */
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_res.item); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "lurrn/sparsmat.pyx":2152
 *         cdef c_CItemI3 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.addr[1],
 *                 res.addr[2],
 */
  __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2147
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecI3_iter.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2160
 *     cdef public object compact
 *     cdef public VecI3 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecI3()
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI3_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI3_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI3___init__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI3___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":2161
 *     cdef public VecI3 loose
 *     def __init__(self):
 *         self.compact=[]             # <<<<<<<<<<<<<<
 *         self.loose=VecI3()
 *         self.loose.vec.reserve(100000)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2162
 *     def __init__(self):
 *         self.compact=[]
 *         self.loose=VecI3()             # <<<<<<<<<<<<<<
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2163
 *         self.compact=[]
 *         self.loose=VecI3()
 *         self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 */
  __pyx_v_self->loose->vec.reserve(100000);

  /* "lurrn/sparsmat.pyx":2160
 *     cdef public object compact
 *     cdef public VecI3 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecI3()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI3.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2164
 *         self.loose=VecI3()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ensure_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_2ensure_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI3_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":2165
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *         self.loose=VecI3()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":2166
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *         self.loose=VecI3()
 *         while len(self.compact)>=2:
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":2167
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 *         self.loose=VecI3()             # <<<<<<<<<<<<<<
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":2168
 *             self.compact.append(self.loose)
 *         self.loose=VecI3()
 *         while len(self.compact)>=2:             # <<<<<<<<<<<<<<
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 */
  while (1) {
    __pyx_t_2 = __pyx_v_self->compact;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = ((__pyx_t_6 >= 2) != 0);
    if (!__pyx_t_4) break;

    /* "lurrn/sparsmat.pyx":2169
 *         self.loose=VecI3()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.loose.c_add(k0,k1,k2, item)
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2169; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2169; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_1, -2, 0, NULL, NULL, &__pyx_slice__19, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2164
 *         self.loose=VecI3()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI3.ensure_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2170
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0,k1,k2, item)
 *         if self.loose.get_size(False)>=100000:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  PyObject *__pyx_v_item = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,&__pyx_n_s_k2,&__pyx_n_s_item,0};
    PyObject* values[4] = {0,0,0,0};
    values[3] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 0, 3, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 0, 3, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_item);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k2 = __Pyx_PyInt_As_coordinate_t(values[2]); if (unlikely((__pyx_v_k2 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_item = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI3.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_4add_count(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1, __pyx_v_k2, __pyx_v_item);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI3_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":2171
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.loose.c_add(k0,k1,k2, item)             # <<<<<<<<<<<<<<
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_item); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI3 *)__pyx_v_self->loose->__pyx_vtab)->c_add(__pyx_v_self->loose, __pyx_v_k0, __pyx_v_k1, __pyx_v_k2, __pyx_t_1);

  /* "lurrn/sparsmat.pyx":2172
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.loose.c_add(k0,k1,k2, item)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_int_100000, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":2173
 *         self.loose.c_add(k0,k1,k2, item)
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *             self.loose=VecI3()
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI3 *)__pyx_v_self->loose->__pyx_vtab)->ensure_compact(__pyx_v_self->loose);

    /* "lurrn/sparsmat.pyx":2174
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *             self.loose=VecI3()
 *             self.loose.vec.reserve(100000)
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lurrn/sparsmat.pyx":2175
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 *             self.loose=VecI3()             # <<<<<<<<<<<<<<
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 */
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->loose);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
    __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":2176
 *             self.compact.append(self.loose)
 *             self.loose=VecI3()
 *             self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 */
    __pyx_v_self->loose->vec.reserve(100000);

    /* "lurrn/sparsmat.pyx":2177
 *             self.loose=VecI3()
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and             # <<<<<<<<<<<<<<
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
    while (1) {
      __pyx_t_2 = __pyx_v_self->compact;
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_7 = ((__pyx_t_6 >= 2) != 0);
      if (__pyx_t_7) {
      } else {
        __pyx_t_4 = __pyx_t_7;
        goto __pyx_L6_bool_binop_done;
      }

      /* "lurrn/sparsmat.pyx":2178
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):             # <<<<<<<<<<<<<<
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 */
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyNumber_Multiply(__pyx_float_0_6, __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_2, __pyx_t_9, Py_GE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_4 = __pyx_t_7;
      __pyx_L6_bool_binop_done:;
      if (!__pyx_t_4) break;

      /* "lurrn/sparsmat.pyx":2179
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2179; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2179; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = PyNumber_Add(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyList_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_9, -2, 0, NULL, NULL, &__pyx_slice__21, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":2170
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0,k1,k2, item)
 *         if self.loose.get_size(False)>=100000:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI3.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2180
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_6get_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI3_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_compact", 0);

  /* "lurrn/sparsmat.pyx":2181
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         if len(self.compact)>0:
 *             return self.compact[0]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2182
 *     def get_compact(self):
 *         self.ensure_compact()
 *         if len(self.compact)>0:             # <<<<<<<<<<<<<<
 *             return self.compact[0]
 *         else:
 */
  __pyx_t_1 = __pyx_v_self->compact;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((__pyx_t_4 > 0) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":2183
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 *             return self.compact[0]             # <<<<<<<<<<<<<<
 *         else:
 *             return VecI3()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2183; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":2185
 *             return self.compact[0]
 *         else:
 *             return VecI3()             # <<<<<<<<<<<<<<
 *     def get_size(self, compactify=True):
 *         cdef int n
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":2180
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI3.get_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2186
 *         else:
 *             return VecI3()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2186; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2186; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI3.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_8get_size(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI3_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  int __pyx_v_n;
  PyObject *__pyx_v_c = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":2188
 *     def get_size(self, compactify=True):
 *         cdef int n
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *             if self.compact:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":2189
 *         cdef int n
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *             if self.compact:
 *                 return self.compact[0].get_size()
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":2190
 *         if compactify:
 *             self.ensure_compact()
 *             if self.compact:             # <<<<<<<<<<<<<<
 *                 return self.compact[0].get_size()
 *             else:
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->compact); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":2191
 *             self.ensure_compact()
 *             if self.compact:
 *                 return self.compact[0].get_size()             # <<<<<<<<<<<<<<
 *             else:
 *                 return 0
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":2193
 *                 return self.compact[0].get_size()
 *             else:
 *                 return 0             # <<<<<<<<<<<<<<
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_int_0);
      __pyx_r = __pyx_int_0;
      goto __pyx_L0;
    }
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":2195
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_v_self->compact)) || PyTuple_CheckExact(__pyx_v_self->compact)) {
      __pyx_t_4 = __pyx_v_self->compact; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_self->compact); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_get_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":2196
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":2197
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)
 *             return n             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         self.ensure_compact()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":2186
 *         else:
 *             return VecI3()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI3.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_c);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2198
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_11__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_11__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_10__iter__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI3_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":2199
 *             return n
 *     def __iter__(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         try:
 *             return iter(self.compact[0])
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2200
 *     def __iter__(self):
 *         self.ensure_compact()
 *         try:             # <<<<<<<<<<<<<<
 *             return iter(self.compact[0])
 *         except IndexError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "lurrn/sparsmat.pyx":2201
 *         self.ensure_compact()
 *         try:
 *             return iter(self.compact[0])             # <<<<<<<<<<<<<<
 *         except IndexError:
 *             return iter([])
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2201; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2201; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L7_try_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":2202
 *         try:
 *             return iter(self.compact[0])
 *         except IndexError:             # <<<<<<<<<<<<<<
 *             return iter([])
 * 
 */
    __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_IndexError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI3.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2202; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_3);

      /* "lurrn/sparsmat.pyx":2203
 *             return iter(self.compact[0])
 *         except IndexError:
 *             return iter([])             # <<<<<<<<<<<<<<
 * 
 *     def get_type_counts(self, k=0):
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2203; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2203; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_r = __pyx_t_9;
      __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":2198
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI3.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2205
 *             return iter([])
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_13get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_13get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2205; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2205; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_12get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI3_12get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);

  /* "lurrn/sparsmat.pyx":2206
 * 
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)             # <<<<<<<<<<<<<<
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_k);
    __Pyx_GIVEREF(__pyx_v_k);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2205
 *             return iter([])
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2207
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_15remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_15remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  PyObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2207; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2207; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = values[0];
    __pyx_v_filt = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2207; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_14remap(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI3_14remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);

  /* "lurrn/sparsmat.pyx":2208
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)             # <<<<<<<<<<<<<<
 * 
 * cdef class SparseVectorI:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_remap); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_v_k);
  PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_k);
  __Pyx_GIVEREF(__pyx_v_k);
  __Pyx_INCREF(__pyx_v_filt);
  PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_filt);
  __Pyx_GIVEREF(__pyx_v_filt);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2207
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2158
 * 
 * cdef class LargeVecI3:
 *     cdef public object compact             # <<<<<<<<<<<<<<
 *     cdef public VecI3 loose
 *     def __init__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_7compact_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_7compact_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_7compact___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI3_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->compact);
  __pyx_r = __pyx_v_self->compact;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI3_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI3_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_7compact_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI3_7compact_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI3_7compact_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_7compact_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2159
 * cdef class LargeVecI3:
 *     cdef public object compact
 *     cdef public VecI3 loose             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *         self.compact=[]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_5loose_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_5loose_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_5loose___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecI3_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->loose));
  __pyx_r = ((PyObject *)__pyx_v_self->loose);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI3_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI3_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_5loose_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5lurrn_8sparsmat_VecI3))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecI3.loose.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI3_5loose_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecI3_5loose_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_5loose_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecI3_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2211
 * 
 * cdef class SparseVectorI:
 *     def __init__(self, pairs=None):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         if pairs is not None:
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pairs = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pairs,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pairs);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2211; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_pairs = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2211; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI___init__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), __pyx_v_pairs);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_13SparseVectorI___init__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, PyObject *__pyx_v_pairs) {
  coordinate_t __pyx_v_i;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_y = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  unsigned int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  coordinate_t __pyx_t_10;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":2213
 *     def __init__(self, pairs=None):
 *         cdef coordinate_t i
 *         if pairs is not None:             # <<<<<<<<<<<<<<
 *             self.my_len=len(pairs)
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 */
  __pyx_t_1 = (__pyx_v_pairs != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lurrn/sparsmat.pyx":2214
 *         cdef coordinate_t i
 *         if pairs is not None:
 *             self.my_len=len(pairs)             # <<<<<<<<<<<<<<
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *             self.vals_ptr=<int *>PyMem_Malloc(self.my_len*sizeof(int))
 */
    __pyx_t_3 = PyObject_Length(__pyx_v_pairs); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_self->my_len = __pyx_t_3;

    /* "lurrn/sparsmat.pyx":2215
 *         if pairs is not None:
 *             self.my_len=len(pairs)
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *             self.vals_ptr=<int *>PyMem_Malloc(self.my_len*sizeof(int))
 *             for i from 0<=i<self.my_len:
 */
    __pyx_v_self->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_self->my_len * (sizeof(coordinate_t)))));

    /* "lurrn/sparsmat.pyx":2216
 *             self.my_len=len(pairs)
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *             self.vals_ptr=<int *>PyMem_Malloc(self.my_len*sizeof(int))             # <<<<<<<<<<<<<<
 *             for i from 0<=i<self.my_len:
 *                 x,y=pairs[i]
 */
    __pyx_v_self->vals_ptr = ((int *)PyMem_Malloc((__pyx_v_self->my_len * (sizeof(int)))));

    /* "lurrn/sparsmat.pyx":2217
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *             self.vals_ptr=<int *>PyMem_Malloc(self.my_len*sizeof(int))
 *             for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *                 x,y=pairs[i]
 *                 self.idx_ptr[i]=x
 */
    __pyx_t_4 = __pyx_v_self->my_len;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":2218
 *             self.vals_ptr=<int *>PyMem_Malloc(self.my_len*sizeof(int))
 *             for i from 0<=i<self.my_len:
 *                 x,y=pairs[i]             # <<<<<<<<<<<<<<
 *                 self.idx_ptr[i]=x
 *                 self.vals_ptr[i]=y
 */
      __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_pairs, __pyx_v_i, coordinate_t, 0, __Pyx_PyInt_From_coordinate_t, 0, 0, 1); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2218; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_5);
      if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
        PyObject* sequence = __pyx_t_5;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        #else
        __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        #endif
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_8 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
        index = 0; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L7_unpacking_done;
        __pyx_L6_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L7_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_6);
      __pyx_t_6 = 0;
      __Pyx_XDECREF_SET(__pyx_v_y, __pyx_t_7);
      __pyx_t_7 = 0;

      /* "lurrn/sparsmat.pyx":2219
 *             for i from 0<=i<self.my_len:
 *                 x,y=pairs[i]
 *                 self.idx_ptr[i]=x             # <<<<<<<<<<<<<<
 *                 self.vals_ptr[i]=y
 *         else:
 */
      __pyx_t_10 = __Pyx_PyInt_As_coordinate_t(__pyx_v_x); if (unlikely((__pyx_t_10 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      (__pyx_v_self->idx_ptr[__pyx_v_i]) = __pyx_t_10;

      /* "lurrn/sparsmat.pyx":2220
 *                 x,y=pairs[i]
 *                 self.idx_ptr[i]=x
 *                 self.vals_ptr[i]=y             # <<<<<<<<<<<<<<
 *         else:
 *             self.my_len=0
 */
      __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_v_y); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      (__pyx_v_self->vals_ptr[__pyx_v_i]) = __pyx_t_11;
    }
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":2222
 *                 self.vals_ptr[i]=y
 *         else:
 *             self.my_len=0             # <<<<<<<<<<<<<<
 *             self.idx_ptr=NULL
 *             self.vals_ptr=NULL
 */
    __pyx_v_self->my_len = 0;

    /* "lurrn/sparsmat.pyx":2223
 *         else:
 *             self.my_len=0
 *             self.idx_ptr=NULL             # <<<<<<<<<<<<<<
 *             self.vals_ptr=NULL
 *     cpdef int from_dense(self, int[:] dense):
 */
    __pyx_v_self->idx_ptr = NULL;

    /* "lurrn/sparsmat.pyx":2224
 *             self.my_len=0
 *             self.idx_ptr=NULL
 *             self.vals_ptr=NULL             # <<<<<<<<<<<<<<
 *     cpdef int from_dense(self, int[:] dense):
 *         cdef int i, k
 */
    __pyx_v_self->vals_ptr = NULL;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":2211
 * 
 * cdef class SparseVectorI:
 *     def __init__(self, pairs=None):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         if pairs is not None:
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2225
 *             self.idx_ptr=NULL
 *             self.vals_ptr=NULL
 *     cpdef int from_dense(self, int[:] dense):             # <<<<<<<<<<<<<<
 *         cdef int i, k
 *         assert self.my_len == 0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_3from_dense(PyObject *__pyx_v_self, PyObject *__pyx_arg_dense); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_13SparseVectorI_from_dense(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, __Pyx_memviewslice __pyx_v_dense, int __pyx_skip_dispatch) {
  int __pyx_v_i;
  int __pyx_v_k;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_dense", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_from_dense); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_3from_dense)) {
      if (unlikely(!__pyx_v_dense.memview)) { __Pyx_RaiseUnboundLocalError("dense"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
      __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dense, 1, (PyObject *(*)(char *)) __pyx_memview_get_int, (int (*)(char *, PyObject *)) __pyx_memview_set_int, 0);; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2227
 *     cpdef int from_dense(self, int[:] dense):
 *         cdef int i, k
 *         assert self.my_len == 0             # <<<<<<<<<<<<<<
 *         k = 0
 *         for i from 0<=i<dense.shape[0]:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_self->my_len == 0) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":2228
 *         cdef int i, k
 *         assert self.my_len == 0
 *         k = 0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<dense.shape[0]:
 *             if dense[i]!=0.0:
 */
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":2229
 *         assert self.my_len == 0
 *         k = 0
 *         for i from 0<=i<dense.shape[0]:             # <<<<<<<<<<<<<<
 *             if dense[i]!=0.0:
 *                 k += 1
 */
  __pyx_t_8 = (__pyx_v_dense.shape[0]);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2230
 *         k = 0
 *         for i from 0<=i<dense.shape[0]:
 *             if dense[i]!=0.0:             # <<<<<<<<<<<<<<
 *                 k += 1
 *         self.my_len = k
 */
    __pyx_t_7 = __pyx_v_i;
    __pyx_t_9 = -1;
    if (__pyx_t_7 < 0) {
      __pyx_t_7 += __pyx_v_dense.shape[0];
      if (unlikely(__pyx_t_7 < 0)) __pyx_t_9 = 0;
    } else if (unlikely(__pyx_t_7 >= __pyx_v_dense.shape[0])) __pyx_t_9 = 0;
    if (unlikely(__pyx_t_9 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_9);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_10 = (((*((int *) ( /* dim=0 */ (__pyx_v_dense.data + __pyx_t_7 * __pyx_v_dense.strides[0]) ))) != 0.0) != 0);
    if (__pyx_t_10) {

      /* "lurrn/sparsmat.pyx":2231
 *         for i from 0<=i<dense.shape[0]:
 *             if dense[i]!=0.0:
 *                 k += 1             # <<<<<<<<<<<<<<
 *         self.my_len = k
 *         self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 */
      __pyx_v_k = (__pyx_v_k + 1);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "lurrn/sparsmat.pyx":2232
 *             if dense[i]!=0.0:
 *                 k += 1
 *         self.my_len = k             # <<<<<<<<<<<<<<
 *         self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *         self.vals_ptr=<int *>PyMem_Malloc(self.my_len*sizeof(int))
 */
  __pyx_v_self->my_len = __pyx_v_k;

  /* "lurrn/sparsmat.pyx":2233
 *                 k += 1
 *         self.my_len = k
 *         self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         self.vals_ptr=<int *>PyMem_Malloc(self.my_len*sizeof(int))
 *         k = 0
 */
  __pyx_v_self->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_self->my_len * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":2234
 *         self.my_len = k
 *         self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *         self.vals_ptr=<int *>PyMem_Malloc(self.my_len*sizeof(int))             # <<<<<<<<<<<<<<
 *         k = 0
 *         for i from 0<=i<dense.shape[0]:
 */
  __pyx_v_self->vals_ptr = ((int *)PyMem_Malloc((__pyx_v_self->my_len * (sizeof(int)))));

  /* "lurrn/sparsmat.pyx":2235
 *         self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *         self.vals_ptr=<int *>PyMem_Malloc(self.my_len*sizeof(int))
 *         k = 0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<dense.shape[0]:
 *             if dense[i] != 0.0:
 */
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":2236
 *         self.vals_ptr=<int *>PyMem_Malloc(self.my_len*sizeof(int))
 *         k = 0
 *         for i from 0<=i<dense.shape[0]:             # <<<<<<<<<<<<<<
 *             if dense[i] != 0.0:
 *                 self.idx_ptr[k] = i
 */
  __pyx_t_8 = (__pyx_v_dense.shape[0]);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2237
 *         k = 0
 *         for i from 0<=i<dense.shape[0]:
 *             if dense[i] != 0.0:             # <<<<<<<<<<<<<<
 *                 self.idx_ptr[k] = i
 *                 self.vals_ptr[k] = dense[i]
 */
    __pyx_t_9 = __pyx_v_i;
    __pyx_t_11 = -1;
    if (__pyx_t_9 < 0) {
      __pyx_t_9 += __pyx_v_dense.shape[0];
      if (unlikely(__pyx_t_9 < 0)) __pyx_t_11 = 0;
    } else if (unlikely(__pyx_t_9 >= __pyx_v_dense.shape[0])) __pyx_t_11 = 0;
    if (unlikely(__pyx_t_11 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_11);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_10 = (((*((int *) ( /* dim=0 */ (__pyx_v_dense.data + __pyx_t_9 * __pyx_v_dense.strides[0]) ))) != 0.0) != 0);
    if (__pyx_t_10) {

      /* "lurrn/sparsmat.pyx":2238
 *         for i from 0<=i<dense.shape[0]:
 *             if dense[i] != 0.0:
 *                 self.idx_ptr[k] = i             # <<<<<<<<<<<<<<
 *                 self.vals_ptr[k] = dense[i]
 *                 k += 1
 */
      (__pyx_v_self->idx_ptr[__pyx_v_k]) = __pyx_v_i;

      /* "lurrn/sparsmat.pyx":2239
 *             if dense[i] != 0.0:
 *                 self.idx_ptr[k] = i
 *                 self.vals_ptr[k] = dense[i]             # <<<<<<<<<<<<<<
 *                 k += 1
 *         return k
 */
      __pyx_t_11 = __pyx_v_i;
      __pyx_t_12 = -1;
      if (__pyx_t_11 < 0) {
        __pyx_t_11 += __pyx_v_dense.shape[0];
        if (unlikely(__pyx_t_11 < 0)) __pyx_t_12 = 0;
      } else if (unlikely(__pyx_t_11 >= __pyx_v_dense.shape[0])) __pyx_t_12 = 0;
      if (unlikely(__pyx_t_12 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_12);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      (__pyx_v_self->vals_ptr[__pyx_v_k]) = (*((int *) ( /* dim=0 */ (__pyx_v_dense.data + __pyx_t_11 * __pyx_v_dense.strides[0]) )));

      /* "lurrn/sparsmat.pyx":2240
 *                 self.idx_ptr[k] = i
 *                 self.vals_ptr[k] = dense[i]
 *                 k += 1             # <<<<<<<<<<<<<<
 *         return k
 *     cpdef int dotSelf(self):
 */
      __pyx_v_k = (__pyx_v_k + 1);
      goto __pyx_L8;
    }
    __pyx_L8:;
  }

  /* "lurrn/sparsmat.pyx":2241
 *                 self.vals_ptr[k] = dense[i]
 *                 k += 1
 *         return k             # <<<<<<<<<<<<<<
 *     cpdef int dotSelf(self):
 *         cdef int s=0
 */
  __pyx_r = __pyx_v_k;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2225
 *             self.idx_ptr=NULL
 *             self.vals_ptr=NULL
 *     cpdef int from_dense(self, int[:] dense):             # <<<<<<<<<<<<<<
 *         cdef int i, k
 *         assert self.my_len == 0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorI.from_dense", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_3from_dense(PyObject *__pyx_v_self, PyObject *__pyx_arg_dense); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_3from_dense(PyObject *__pyx_v_self, PyObject *__pyx_arg_dense) {
  __Pyx_memviewslice __pyx_v_dense = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_dense (wrapper)", 0);
  assert(__pyx_arg_dense); {
    __pyx_v_dense = __Pyx_PyObject_to_MemoryviewSlice_ds_int(__pyx_arg_dense); if (unlikely(!__pyx_v_dense.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2225; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.from_dense", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_2from_dense(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), __pyx_v_dense);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_2from_dense(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, __Pyx_memviewslice __pyx_v_dense) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_dense", 0);
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_v_dense.memview)) { __Pyx_RaiseUnboundLocalError("dense"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_5lurrn_8sparsmat_13SparseVectorI_from_dense(__pyx_v_self, __pyx_v_dense, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.from_dense", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_dense, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2242
 *                 k += 1
 *         return k
 *     cpdef int dotSelf(self):             # <<<<<<<<<<<<<<
 *         cdef int s=0
 *         cdef coordinate_t i
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_5dotSelf(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_13SparseVectorI_dotSelf(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, int __pyx_skip_dispatch) {
  int __pyx_v_s;
  coordinate_t __pyx_v_i;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  unsigned int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotSelf", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dotSelf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_5dotSelf)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_5;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2243
 *         return k
 *     cpdef int dotSelf(self):
 *         cdef int s=0             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_s = 0;

  /* "lurrn/sparsmat.pyx":2245
 *         cdef int s=0
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             s+=self.vals_ptr[i]*self.vals_ptr[i]
 *         return s
 */
  __pyx_t_6 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2246
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 *             s+=self.vals_ptr[i]*self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *         return s
 *     cdef int _dotFull(self, const_int_ptr full_ptr):
 */
    __pyx_v_s = (__pyx_v_s + ((__pyx_v_self->vals_ptr[__pyx_v_i]) * (__pyx_v_self->vals_ptr[__pyx_v_i])));
  }

  /* "lurrn/sparsmat.pyx":2247
 *         for i from 0<=i<self.my_len:
 *             s+=self.vals_ptr[i]*self.vals_ptr[i]
 *         return s             # <<<<<<<<<<<<<<
 *     cdef int _dotFull(self, const_int_ptr full_ptr):
 *         cdef int s=0
 */
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2242
 *                 k += 1
 *         return k
 *     cpdef int dotSelf(self):             # <<<<<<<<<<<<<<
 *         cdef int s=0
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorI.dotSelf", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_5dotSelf(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_5dotSelf(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dotSelf (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_4dotSelf(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_4dotSelf(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotSelf", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_5lurrn_8sparsmat_13SparseVectorI_dotSelf(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.dotSelf", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2248
 *             s+=self.vals_ptr[i]*self.vals_ptr[i]
 *         return s
 *     cdef int _dotFull(self, const_int_ptr full_ptr):             # <<<<<<<<<<<<<<
 *         cdef int s=0
 *         cdef coordinate_t i
 */

static int __pyx_f_5lurrn_8sparsmat_13SparseVectorI__dotFull(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, const int * __pyx_v_full_ptr) {
  int __pyx_v_s;
  coordinate_t __pyx_v_i;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  __Pyx_RefNannySetupContext("_dotFull", 0);

  /* "lurrn/sparsmat.pyx":2249
 *         return s
 *     cdef int _dotFull(self, const_int_ptr full_ptr):
 *         cdef int s=0             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_s = 0;

  /* "lurrn/sparsmat.pyx":2251
 *         cdef int s=0
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2252
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]             # <<<<<<<<<<<<<<
 *         return s
 *     cdef int _dotFull_partial(self, const_int_ptr full_ptr, int my_len):
 */
    __pyx_v_s = (__pyx_v_s + ((__pyx_v_self->vals_ptr[__pyx_v_i]) * (__pyx_v_full_ptr[(__pyx_v_self->idx_ptr[__pyx_v_i])])));
  }

  /* "lurrn/sparsmat.pyx":2253
 *         for i from 0<=i<self.my_len:
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s             # <<<<<<<<<<<<<<
 *     cdef int _dotFull_partial(self, const_int_ptr full_ptr, int my_len):
 *         cdef int s=0
 */
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2248
 *             s+=self.vals_ptr[i]*self.vals_ptr[i]
 *         return s
 *     cdef int _dotFull(self, const_int_ptr full_ptr):             # <<<<<<<<<<<<<<
 *         cdef int s=0
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2254
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s
 *     cdef int _dotFull_partial(self, const_int_ptr full_ptr, int my_len):             # <<<<<<<<<<<<<<
 *         cdef int s=0
 *         cdef coordinate_t i
 */

static int __pyx_f_5lurrn_8sparsmat_13SparseVectorI__dotFull_partial(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, const int * __pyx_v_full_ptr, int __pyx_v_my_len) {
  int __pyx_v_s;
  coordinate_t __pyx_v_i;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_dotFull_partial", 0);

  /* "lurrn/sparsmat.pyx":2255
 *         return s
 *     cdef int _dotFull_partial(self, const_int_ptr full_ptr, int my_len):
 *         cdef int s=0             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<my_len:
 */
  __pyx_v_s = 0;

  /* "lurrn/sparsmat.pyx":2257
 *         cdef int s=0
 *         cdef coordinate_t i
 *         for i from 0<=i<my_len:             # <<<<<<<<<<<<<<
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s
 */
  __pyx_t_1 = __pyx_v_my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2258
 *         cdef coordinate_t i
 *         for i from 0<=i<my_len:
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]             # <<<<<<<<<<<<<<
 *         return s
 *     cpdef double jaccard(self, SparseVectorI other):
 */
    __pyx_v_s = (__pyx_v_s + ((__pyx_v_self->vals_ptr[__pyx_v_i]) * (__pyx_v_full_ptr[(__pyx_v_self->idx_ptr[__pyx_v_i])])));
  }

  /* "lurrn/sparsmat.pyx":2259
 *         for i from 0<=i<my_len:
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s             # <<<<<<<<<<<<<<
 *     cpdef double jaccard(self, SparseVectorI other):
 *         cdef double s_max=0
 */
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2254
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s
 *     cdef int _dotFull_partial(self, const_int_ptr full_ptr, int my_len):             # <<<<<<<<<<<<<<
 *         cdef int s=0
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2260
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s
 *     cpdef double jaccard(self, SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef double s_max=0
 *         cdef double s_min=0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_7jaccard(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorI_jaccard(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other, int __pyx_skip_dispatch) {
  double __pyx_v_s_max;
  double __pyx_v_s_min;
  int __pyx_v_val1;
  int __pyx_v_val2;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("jaccard", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_jaccard); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_7jaccard)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2261
 *         return s
 *     cpdef double jaccard(self, SparseVectorI other):
 *         cdef double s_max=0             # <<<<<<<<<<<<<<
 *         cdef double s_min=0
 *         cdef int val1, val2
 */
  __pyx_v_s_max = 0.0;

  /* "lurrn/sparsmat.pyx":2262
 *     cpdef double jaccard(self, SparseVectorI other):
 *         cdef double s_max=0
 *         cdef double s_min=0             # <<<<<<<<<<<<<<
 *         cdef int val1, val2
 *         cdef coordinate_t i,j, idx_i, idx_j
 */
  __pyx_v_s_min = 0.0;

  /* "lurrn/sparsmat.pyx":2265
 *         cdef int val1, val2
 *         cdef coordinate_t i,j, idx_i, idx_j
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":2266
 *         cdef coordinate_t i,j, idx_i, idx_j
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *             idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":2267
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *             idx_i=self.idx_ptr[i]
 *             idx_j=other.idx_ptr[j]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":2268
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *             idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *             idx_j=other.idx_ptr[j]
 *             if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":2269
 *         while i<self.my_len and j<other.my_len:
 *             idx_i=self.idx_ptr[i]
 *             idx_j=other.idx_ptr[j]             # <<<<<<<<<<<<<<
 *             if idx_i<idx_j:
 *                 s_max+=self.vals_ptr[i]
 */
    __pyx_v_idx_j = (__pyx_v_other->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":2270
 *             idx_i=self.idx_ptr[i]
 *             idx_j=other.idx_ptr[j]
 *             if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *                 s_max+=self.vals_ptr[i]
 *                 i+=1
 */
    __pyx_t_7 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":2271
 *             idx_j=other.idx_ptr[j]
 *             if idx_i<idx_j:
 *                 s_max+=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                 i+=1
 *             elif idx_i>idx_j:
 */
      __pyx_v_s_max = (__pyx_v_s_max + (__pyx_v_self->vals_ptr[__pyx_v_i]));

      /* "lurrn/sparsmat.pyx":2272
 *             if idx_i<idx_j:
 *                 s_max+=self.vals_ptr[i]
 *                 i+=1             # <<<<<<<<<<<<<<
 *             elif idx_i>idx_j:
 *                 s_max+=other.vals_ptr[j]
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":2273
 *                 s_max+=self.vals_ptr[i]
 *                 i+=1
 *             elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *                 s_max+=other.vals_ptr[j]
 *                 j+=1
 */
    __pyx_t_7 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":2274
 *                 i+=1
 *             elif idx_i>idx_j:
 *                 s_max+=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                 j+=1
 *             else:
 */
      __pyx_v_s_max = (__pyx_v_s_max + (__pyx_v_other->vals_ptr[__pyx_v_j]));

      /* "lurrn/sparsmat.pyx":2275
 *             elif idx_i>idx_j:
 *                 s_max+=other.vals_ptr[j]
 *                 j+=1             # <<<<<<<<<<<<<<
 *             else:
 *                 val1=self.vals_ptr[i]
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":2277
 *                 j+=1
 *             else:
 *                 val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                 val2=other.vals_ptr[j]
 *                 if val1>val2:
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":2278
 *             else:
 *                 val1=self.vals_ptr[i]
 *                 val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                 if val1>val2:
 *                     s_max+=val1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":2279
 *                 val1=self.vals_ptr[i]
 *                 val2=other.vals_ptr[j]
 *                 if val1>val2:             # <<<<<<<<<<<<<<
 *                     s_max+=val1
 *                     s_min+=val2
 */
      __pyx_t_7 = ((__pyx_v_val1 > __pyx_v_val2) != 0);
      if (__pyx_t_7) {

        /* "lurrn/sparsmat.pyx":2280
 *                 val2=other.vals_ptr[j]
 *                 if val1>val2:
 *                     s_max+=val1             # <<<<<<<<<<<<<<
 *                     s_min+=val2
 *                 else:
 */
        __pyx_v_s_max = (__pyx_v_s_max + __pyx_v_val1);

        /* "lurrn/sparsmat.pyx":2281
 *                 if val1>val2:
 *                     s_max+=val1
 *                     s_min+=val2             # <<<<<<<<<<<<<<
 *                 else:
 *                     s_max+=val2
 */
        __pyx_v_s_min = (__pyx_v_s_min + __pyx_v_val2);
        goto __pyx_L8;
      }
      /*else*/ {

        /* "lurrn/sparsmat.pyx":2283
 *                     s_min+=val2
 *                 else:
 *                     s_max+=val2             # <<<<<<<<<<<<<<
 *                     s_min+=val1
 *                 i+=1
 */
        __pyx_v_s_max = (__pyx_v_s_max + __pyx_v_val2);

        /* "lurrn/sparsmat.pyx":2284
 *                 else:
 *                     s_max+=val2
 *                     s_min+=val1             # <<<<<<<<<<<<<<
 *                 i+=1
 *                 j+=1
 */
        __pyx_v_s_min = (__pyx_v_s_min + __pyx_v_val1);
      }
      __pyx_L8:;

      /* "lurrn/sparsmat.pyx":2285
 *                     s_max+=val2
 *                     s_min+=val1
 *                 i+=1             # <<<<<<<<<<<<<<
 *                 j+=1
 *         if i<self.my_len:
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":2286
 *                     s_min+=val1
 *                 i+=1
 *                 j+=1             # <<<<<<<<<<<<<<
 *         if i<self.my_len:
 *             while i<self.my_len:
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":2287
 *                 i+=1
 *                 j+=1
 *         if i<self.my_len:             # <<<<<<<<<<<<<<
 *             while i<self.my_len:
 *                 s_max+=self.vals_ptr[i]
 */
  __pyx_t_7 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":2288
 *                 j+=1
 *         if i<self.my_len:
 *             while i<self.my_len:             # <<<<<<<<<<<<<<
 *                 s_max+=self.vals_ptr[i]
 *                 i+=1
 */
    while (1) {
      __pyx_t_7 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
      if (!__pyx_t_7) break;

      /* "lurrn/sparsmat.pyx":2289
 *         if i<self.my_len:
 *             while i<self.my_len:
 *                 s_max+=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                 i+=1
 *         else:
 */
      __pyx_v_s_max = (__pyx_v_s_max + (__pyx_v_self->vals_ptr[__pyx_v_i]));

      /* "lurrn/sparsmat.pyx":2290
 *             while i<self.my_len:
 *                 s_max+=self.vals_ptr[i]
 *                 i+=1             # <<<<<<<<<<<<<<
 *         else:
 *             while j<other.my_len:
 */
      __pyx_v_i = (__pyx_v_i + 1);
    }
    goto __pyx_L9;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":2292
 *                 i+=1
 *         else:
 *             while j<other.my_len:             # <<<<<<<<<<<<<<
 *                 s_max+=other.vals_ptr[j]
 *                 j+=1
 */
    while (1) {
      __pyx_t_7 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
      if (!__pyx_t_7) break;

      /* "lurrn/sparsmat.pyx":2293
 *         else:
 *             while j<other.my_len:
 *                 s_max+=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                 j+=1
 *         if s_max==0:
 */
      __pyx_v_s_max = (__pyx_v_s_max + (__pyx_v_other->vals_ptr[__pyx_v_j]));

      /* "lurrn/sparsmat.pyx":2294
 *             while j<other.my_len:
 *                 s_max+=other.vals_ptr[j]
 *                 j+=1             # <<<<<<<<<<<<<<
 *         if s_max==0:
 *             return 0.0
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
  }
  __pyx_L9:;

  /* "lurrn/sparsmat.pyx":2295
 *                 s_max+=other.vals_ptr[j]
 *                 j+=1
 *         if s_max==0:             # <<<<<<<<<<<<<<
 *             return 0.0
 *         else:
 */
  __pyx_t_7 = ((__pyx_v_s_max == 0.0) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":2296
 *                 j+=1
 *         if s_max==0:
 *             return 0.0             # <<<<<<<<<<<<<<
 *         else:
 *             return s_min/s_max
 */
    __pyx_r = 0.0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":2298
 *             return 0.0
 *         else:
 *             return s_min/s_max             # <<<<<<<<<<<<<<
 *     cpdef int dotSparse(self, SparseVectorI other):
 *         cdef int product=0
 */
    if (unlikely(__pyx_v_s_max == 0)) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      #ifdef WITH_THREAD
      PyGILState_Release(__pyx_gilstate_save);
      #endif
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_r = (__pyx_v_s_min / __pyx_v_s_max);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":2260
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s
 *     cpdef double jaccard(self, SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef double s_max=0
 *         cdef double s_min=0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorI.jaccard", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_7jaccard(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_7jaccard(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("jaccard (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorI, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_6jaccard(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_6jaccard(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("jaccard", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorI_jaccard(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.jaccard", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2299
 *         else:
 *             return s_min/s_max
 *     cpdef int dotSparse(self, SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef int product=0
 *         cdef int val1, val2
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_9dotSparse(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_13SparseVectorI_dotSparse(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other, int __pyx_skip_dispatch) {
  int __pyx_v_product;
  int __pyx_v_val1;
  int __pyx_v_val2;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotSparse", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dotSparse); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_9dotSparse)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2300
 *             return s_min/s_max
 *     cpdef int dotSparse(self, SparseVectorI other):
 *         cdef int product=0             # <<<<<<<<<<<<<<
 *         cdef int val1, val2
 *         cdef coordinate_t i, j, idx_i, idx_j
 */
  __pyx_v_product = 0;

  /* "lurrn/sparsmat.pyx":2303
 *         cdef int val1, val2
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":2304
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":2305
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":2306
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":2307
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]             # <<<<<<<<<<<<<<
 *            if idx_i<idx_j:
 *               i+=1
 */
    __pyx_v_idx_j = (__pyx_v_other->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":2308
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *               i+=1
 *            elif idx_i>idx_j:
 */
    __pyx_t_7 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":2309
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 *               i+=1             # <<<<<<<<<<<<<<
 *            elif idx_i>idx_j:
 *               j+=1
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":2310
 *            if idx_i<idx_j:
 *               i+=1
 *            elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *               j+=1
 *            else:
 */
    __pyx_t_7 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":2311
 *               i+=1
 *            elif idx_i>idx_j:
 *               j+=1             # <<<<<<<<<<<<<<
 *            else:
 *               val1=self.vals_ptr[i]
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":2313
 *               j+=1
 *            else:
 *               val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *               val2=other.vals_ptr[j]
 *               product+=val1*val2
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":2314
 *            else:
 *               val1=self.vals_ptr[i]
 *               val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *               product+=val1*val2
 *               i+=1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":2315
 *               val1=self.vals_ptr[i]
 *               val2=other.vals_ptr[j]
 *               product+=val1*val2             # <<<<<<<<<<<<<<
 *               i+=1
 *               j+=1
 */
      __pyx_v_product = (__pyx_v_product + (__pyx_v_val1 * __pyx_v_val2));

      /* "lurrn/sparsmat.pyx":2316
 *               val2=other.vals_ptr[j]
 *               product+=val1*val2
 *               i+=1             # <<<<<<<<<<<<<<
 *               j+=1
 *         return product
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":2317
 *               product+=val1*val2
 *               i+=1
 *               j+=1             # <<<<<<<<<<<<<<
 *         return product
 *     def count_intersection(self, SparseVectorI other):
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":2318
 *               i+=1
 *               j+=1
 *         return product             # <<<<<<<<<<<<<<
 *     def count_intersection(self, SparseVectorI other):
 *         cdef coordinate_t i, j, idx_i, idx_j
 */
  __pyx_r = __pyx_v_product;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2299
 *         else:
 *             return s_min/s_max
 *     cpdef int dotSparse(self, SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef int product=0
 *         cdef int val1, val2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorI.dotSparse", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_9dotSparse(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_9dotSparse(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dotSparse (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorI, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_8dotSparse(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_8dotSparse(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotSparse", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_5lurrn_8sparsmat_13SparseVectorI_dotSparse(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.dotSparse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2319
 *               j+=1
 *         return product
 *     def count_intersection(self, SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         cdef int n_ab=0
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_11count_intersection(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_11count_intersection(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("count_intersection (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorI, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_10count_intersection(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_10count_intersection(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other) {
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  int __pyx_v_n_ab;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("count_intersection", 0);

  /* "lurrn/sparsmat.pyx":2321
 *     def count_intersection(self, SparseVectorI other):
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         cdef int n_ab=0             # <<<<<<<<<<<<<<
 *         i=0
 *         j=0
 */
  __pyx_v_n_ab = 0;

  /* "lurrn/sparsmat.pyx":2322
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         cdef int n_ab=0
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":2323
 *         cdef int n_ab=0
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":2324
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_1) break;

    /* "lurrn/sparsmat.pyx":2325
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":2326
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]             # <<<<<<<<<<<<<<
 *            if idx_i<idx_j:
 *               i+=1
 */
    __pyx_v_idx_j = (__pyx_v_other->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":2327
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *               i+=1
 *            elif idx_i>idx_j:
 */
    __pyx_t_1 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":2328
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 *               i+=1             # <<<<<<<<<<<<<<
 *            elif idx_i>idx_j:
 *               j+=1
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":2329
 *            if idx_i<idx_j:
 *               i+=1
 *            elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *               j+=1
 *            else:
 */
    __pyx_t_1 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":2330
 *               i+=1
 *            elif idx_i>idx_j:
 *               j+=1             # <<<<<<<<<<<<<<
 *            else:
 *               i+=1
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":2332
 *               j+=1
 *            else:
 *               i+=1             # <<<<<<<<<<<<<<
 *               j+=1
 *               n_ab+=1
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":2333
 *            else:
 *               i+=1
 *               j+=1             # <<<<<<<<<<<<<<
 *               n_ab+=1
 *         return n_ab
 */
      __pyx_v_j = (__pyx_v_j + 1);

      /* "lurrn/sparsmat.pyx":2334
 *               i+=1
 *               j+=1
 *               n_ab+=1             # <<<<<<<<<<<<<<
 *         return n_ab
 *     cpdef double min_sum(self, SparseVectorI other):
 */
      __pyx_v_n_ab = (__pyx_v_n_ab + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":2335
 *               j+=1
 *               n_ab+=1
 *         return n_ab             # <<<<<<<<<<<<<<
 *     cpdef double min_sum(self, SparseVectorI other):
 *         cdef double product=0.0
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n_ab); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2319
 *               j+=1
 *         return product
 *     def count_intersection(self, SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         cdef int n_ab=0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.count_intersection", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2336
 *               n_ab+=1
 *         return n_ab
 *     cpdef double min_sum(self, SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef double product=0.0
 *         cdef int val1, val2
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_13min_sum(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorI_min_sum(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other, int __pyx_skip_dispatch) {
  double __pyx_v_product;
  int __pyx_v_val1;
  int __pyx_v_val2;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("min_sum", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_min_sum); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_13min_sum)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2337
 *         return n_ab
 *     cpdef double min_sum(self, SparseVectorI other):
 *         cdef double product=0.0             # <<<<<<<<<<<<<<
 *         cdef int val1, val2
 *         cdef coordinate_t i, j, idx_i, idx_j
 */
  __pyx_v_product = 0.0;

  /* "lurrn/sparsmat.pyx":2340
 *         cdef int val1, val2
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":2341
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":2342
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":2343
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":2344
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]             # <<<<<<<<<<<<<<
 *            if idx_i<idx_j:
 *               i+=1
 */
    __pyx_v_idx_j = (__pyx_v_other->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":2345
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *               i+=1
 *            elif idx_i>idx_j:
 */
    __pyx_t_7 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":2346
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 *               i+=1             # <<<<<<<<<<<<<<
 *            elif idx_i>idx_j:
 *               j+=1
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":2347
 *            if idx_i<idx_j:
 *               i+=1
 *            elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *               j+=1
 *            else:
 */
    __pyx_t_7 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":2348
 *               i+=1
 *            elif idx_i>idx_j:
 *               j+=1             # <<<<<<<<<<<<<<
 *            else:
 *               val1=self.vals_ptr[i]
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":2350
 *               j+=1
 *            else:
 *               val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *               val2=other.vals_ptr[j]
 *               if val1<val2:
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":2351
 *            else:
 *               val1=self.vals_ptr[i]
 *               val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *               if val1<val2:
 *                   product+=val1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":2352
 *               val1=self.vals_ptr[i]
 *               val2=other.vals_ptr[j]
 *               if val1<val2:             # <<<<<<<<<<<<<<
 *                   product+=val1
 *               else:
 */
      __pyx_t_7 = ((__pyx_v_val1 < __pyx_v_val2) != 0);
      if (__pyx_t_7) {

        /* "lurrn/sparsmat.pyx":2353
 *               val2=other.vals_ptr[j]
 *               if val1<val2:
 *                   product+=val1             # <<<<<<<<<<<<<<
 *               else:
 *                   product+=val2
 */
        __pyx_v_product = (__pyx_v_product + __pyx_v_val1);
        goto __pyx_L8;
      }
      /*else*/ {

        /* "lurrn/sparsmat.pyx":2355
 *                   product+=val1
 *               else:
 *                   product+=val2             # <<<<<<<<<<<<<<
 *               i+=1
 *               j+=1
 */
        __pyx_v_product = (__pyx_v_product + __pyx_v_val2);
      }
      __pyx_L8:;

      /* "lurrn/sparsmat.pyx":2356
 *               else:
 *                   product+=val2
 *               i+=1             # <<<<<<<<<<<<<<
 *               j+=1
 *         return product
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":2357
 *                   product+=val2
 *               i+=1
 *               j+=1             # <<<<<<<<<<<<<<
 *         return product
 *     cpdef double cosine(self, SparseVectorI other):
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":2358
 *               i+=1
 *               j+=1
 *         return product             # <<<<<<<<<<<<<<
 *     cpdef double cosine(self, SparseVectorI other):
 *         cdef double sqsum_self=0.0
 */
  __pyx_r = __pyx_v_product;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2336
 *               n_ab+=1
 *         return n_ab
 *     cpdef double min_sum(self, SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef double product=0.0
 *         cdef int val1, val2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorI.min_sum", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_13min_sum(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_13min_sum(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("min_sum (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorI, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_12min_sum(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_12min_sum(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("min_sum", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorI_min_sum(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.min_sum", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2359
 *               j+=1
 *         return product
 *     cpdef double cosine(self, SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef double sqsum_self=0.0
 *         cdef double sqsum_other=0.0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_15cosine(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorI_cosine(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other, int __pyx_skip_dispatch) {
  double __pyx_v_sqsum_self;
  double __pyx_v_sqsum_other;
  double __pyx_v_product;
  int __pyx_v_val1;
  int __pyx_v_val2;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("cosine", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_cosine); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_15cosine)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2360
 *         return product
 *     cpdef double cosine(self, SparseVectorI other):
 *         cdef double sqsum_self=0.0             # <<<<<<<<<<<<<<
 *         cdef double sqsum_other=0.0
 *         cdef double product=0.0
 */
  __pyx_v_sqsum_self = 0.0;

  /* "lurrn/sparsmat.pyx":2361
 *     cpdef double cosine(self, SparseVectorI other):
 *         cdef double sqsum_self=0.0
 *         cdef double sqsum_other=0.0             # <<<<<<<<<<<<<<
 *         cdef double product=0.0
 *         cdef int val1, val2
 */
  __pyx_v_sqsum_other = 0.0;

  /* "lurrn/sparsmat.pyx":2362
 *         cdef double sqsum_self=0.0
 *         cdef double sqsum_other=0.0
 *         cdef double product=0.0             # <<<<<<<<<<<<<<
 *         cdef int val1, val2
 *         cdef coordinate_t i, j, idx_i, idx_j
 */
  __pyx_v_product = 0.0;

  /* "lurrn/sparsmat.pyx":2365
 *         cdef int val1, val2
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":2366
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":2367
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":2368
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":2369
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]             # <<<<<<<<<<<<<<
 *            if idx_i<idx_j:
 *               val1=self.vals_ptr[i]
 */
    __pyx_v_idx_j = (__pyx_v_other->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":2370
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *               val1=self.vals_ptr[i]
 *               sqsum_self+=val1*val1
 */
    __pyx_t_7 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":2371
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 *               val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *               sqsum_self+=val1*val1
 *               i+=1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":2372
 *            if idx_i<idx_j:
 *               val1=self.vals_ptr[i]
 *               sqsum_self+=val1*val1             # <<<<<<<<<<<<<<
 *               i+=1
 *            elif idx_i>idx_j:
 */
      __pyx_v_sqsum_self = (__pyx_v_sqsum_self + (__pyx_v_val1 * __pyx_v_val1));

      /* "lurrn/sparsmat.pyx":2373
 *               val1=self.vals_ptr[i]
 *               sqsum_self+=val1*val1
 *               i+=1             # <<<<<<<<<<<<<<
 *            elif idx_i>idx_j:
 *               val2=other.vals_ptr[j]
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":2374
 *               sqsum_self+=val1*val1
 *               i+=1
 *            elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *               val2=other.vals_ptr[j]
 *               sqsum_other+=val2*val2
 */
    __pyx_t_7 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":2375
 *               i+=1
 *            elif idx_i>idx_j:
 *               val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *               sqsum_other+=val2*val2
 *               j+=1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":2376
 *            elif idx_i>idx_j:
 *               val2=other.vals_ptr[j]
 *               sqsum_other+=val2*val2             # <<<<<<<<<<<<<<
 *               j+=1
 *            else:
 */
      __pyx_v_sqsum_other = (__pyx_v_sqsum_other + (__pyx_v_val2 * __pyx_v_val2));

      /* "lurrn/sparsmat.pyx":2377
 *               val2=other.vals_ptr[j]
 *               sqsum_other+=val2*val2
 *               j+=1             # <<<<<<<<<<<<<<
 *            else:
 *               val1=self.vals_ptr[i]
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":2379
 *               j+=1
 *            else:
 *               val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *               val2=other.vals_ptr[j]
 *               sqsum_self+=val1*val1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":2380
 *            else:
 *               val1=self.vals_ptr[i]
 *               val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *               sqsum_self+=val1*val1
 *               sqsum_other+=val2*val2
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":2381
 *               val1=self.vals_ptr[i]
 *               val2=other.vals_ptr[j]
 *               sqsum_self+=val1*val1             # <<<<<<<<<<<<<<
 *               sqsum_other+=val2*val2
 *               product+=val1*val2
 */
      __pyx_v_sqsum_self = (__pyx_v_sqsum_self + (__pyx_v_val1 * __pyx_v_val1));

      /* "lurrn/sparsmat.pyx":2382
 *               val2=other.vals_ptr[j]
 *               sqsum_self+=val1*val1
 *               sqsum_other+=val2*val2             # <<<<<<<<<<<<<<
 *               product+=val1*val2
 *               i+=1
 */
      __pyx_v_sqsum_other = (__pyx_v_sqsum_other + (__pyx_v_val2 * __pyx_v_val2));

      /* "lurrn/sparsmat.pyx":2383
 *               sqsum_self+=val1*val1
 *               sqsum_other+=val2*val2
 *               product+=val1*val2             # <<<<<<<<<<<<<<
 *               i+=1
 *               j+=1
 */
      __pyx_v_product = (__pyx_v_product + (__pyx_v_val1 * __pyx_v_val2));

      /* "lurrn/sparsmat.pyx":2384
 *               sqsum_other+=val2*val2
 *               product+=val1*val2
 *               i+=1             # <<<<<<<<<<<<<<
 *               j+=1
 *         if i<self.my_len:
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":2385
 *               product+=val1*val2
 *               i+=1
 *               j+=1             # <<<<<<<<<<<<<<
 *         if i<self.my_len:
 *             while i<self.my_len:
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":2386
 *               i+=1
 *               j+=1
 *         if i<self.my_len:             # <<<<<<<<<<<<<<
 *             while i<self.my_len:
 *                 val1=self.vals_ptr[i]
 */
  __pyx_t_7 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":2387
 *               j+=1
 *         if i<self.my_len:
 *             while i<self.my_len:             # <<<<<<<<<<<<<<
 *                 val1=self.vals_ptr[i]
 *                 sqsum_self+=val1*val1
 */
    while (1) {
      __pyx_t_7 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
      if (!__pyx_t_7) break;

      /* "lurrn/sparsmat.pyx":2388
 *         if i<self.my_len:
 *             while i<self.my_len:
 *                 val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                 sqsum_self+=val1*val1
 *                 i+=1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":2389
 *             while i<self.my_len:
 *                 val1=self.vals_ptr[i]
 *                 sqsum_self+=val1*val1             # <<<<<<<<<<<<<<
 *                 i+=1
 *         else:
 */
      __pyx_v_sqsum_self = (__pyx_v_sqsum_self + (__pyx_v_val1 * __pyx_v_val1));

      /* "lurrn/sparsmat.pyx":2390
 *                 val1=self.vals_ptr[i]
 *                 sqsum_self+=val1*val1
 *                 i+=1             # <<<<<<<<<<<<<<
 *         else:
 *             while j<other.my_len:
 */
      __pyx_v_i = (__pyx_v_i + 1);
    }
    goto __pyx_L8;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":2392
 *                 i+=1
 *         else:
 *             while j<other.my_len:             # <<<<<<<<<<<<<<
 *                 val2=other.vals_ptr[j]
 *                 sqsum_other+=val2*val2
 */
    while (1) {
      __pyx_t_7 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
      if (!__pyx_t_7) break;

      /* "lurrn/sparsmat.pyx":2393
 *         else:
 *             while j<other.my_len:
 *                 val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                 sqsum_other+=val2*val2
 *                 j+=1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":2394
 *             while j<other.my_len:
 *                 val2=other.vals_ptr[j]
 *                 sqsum_other+=val2*val2             # <<<<<<<<<<<<<<
 *                 j+=1
 *         return product/sqrt(sqsum_self*sqsum_other)
 */
      __pyx_v_sqsum_other = (__pyx_v_sqsum_other + (__pyx_v_val2 * __pyx_v_val2));

      /* "lurrn/sparsmat.pyx":2395
 *                 val2=other.vals_ptr[j]
 *                 sqsum_other+=val2*val2
 *                 j+=1             # <<<<<<<<<<<<<<
 *         return product/sqrt(sqsum_self*sqsum_other)
 *     cpdef double jsd_unnorm(self, SparseVectorI other):
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
  }
  __pyx_L8:;

  /* "lurrn/sparsmat.pyx":2396
 *                 sqsum_other+=val2*val2
 *                 j+=1
 *         return product/sqrt(sqsum_self*sqsum_other)             # <<<<<<<<<<<<<<
 *     cpdef double jsd_unnorm(self, SparseVectorI other):
 *         cdef double sum=0.0
 */
  __pyx_t_6 = sqrt((__pyx_v_sqsum_self * __pyx_v_sqsum_other));
  if (unlikely(__pyx_t_6 == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_r = (__pyx_v_product / __pyx_t_6);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2359
 *               j+=1
 *         return product
 *     cpdef double cosine(self, SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef double sqsum_self=0.0
 *         cdef double sqsum_other=0.0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorI.cosine", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_15cosine(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_15cosine(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("cosine (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorI, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_14cosine(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_14cosine(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("cosine", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorI_cosine(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.cosine", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2397
 *                 j+=1
 *         return product/sqrt(sqsum_self*sqsum_other)
 *     cpdef double jsd_unnorm(self, SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef double val1, val2, avg
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_17jsd_unnorm(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorI_jsd_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other, int __pyx_skip_dispatch) {
  double __pyx_v_sum;
  double __pyx_v_val1;
  double __pyx_v_val2;
  double __pyx_v_avg;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("jsd_unnorm", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_jsd_unnorm); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_17jsd_unnorm)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2398
 *         return product/sqrt(sqsum_self*sqsum_other)
 *     cpdef double jsd_unnorm(self, SparseVectorI other):
 *         cdef double sum=0.0             # <<<<<<<<<<<<<<
 *         cdef double val1, val2, avg
 *         cdef coordinate_t i, j, idx_i, idx_j
 */
  __pyx_v_sum = 0.0;

  /* "lurrn/sparsmat.pyx":2401
 *         cdef double val1, val2, avg
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":2402
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":2403
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":2404
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":2405
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]             # <<<<<<<<<<<<<<
 *            if idx_i<idx_j:
 *                val1=self.vals_ptr[i]
 */
    __pyx_v_idx_j = (__pyx_v_other->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":2406
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *                val1=self.vals_ptr[i]
 *                sum+=val1*M_LN2
 */
    __pyx_t_7 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":2407
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 *                val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                sum+=val1*M_LN2
 *                i+=1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":2408
 *            if idx_i<idx_j:
 *                val1=self.vals_ptr[i]
 *                sum+=val1*M_LN2             # <<<<<<<<<<<<<<
 *                i+=1
 *            elif idx_i>idx_j:
 */
      __pyx_v_sum = (__pyx_v_sum + (__pyx_v_val1 * M_LN2));

      /* "lurrn/sparsmat.pyx":2409
 *                val1=self.vals_ptr[i]
 *                sum+=val1*M_LN2
 *                i+=1             # <<<<<<<<<<<<<<
 *            elif idx_i>idx_j:
 *                val2=other.vals_ptr[j]
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":2410
 *                sum+=val1*M_LN2
 *                i+=1
 *            elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *                val2=other.vals_ptr[j]
 *                sum+=val2*M_LN2
 */
    __pyx_t_7 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":2411
 *                i+=1
 *            elif idx_i>idx_j:
 *                val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                sum+=val2*M_LN2
 *                j+=1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":2412
 *            elif idx_i>idx_j:
 *                val2=other.vals_ptr[j]
 *                sum+=val2*M_LN2             # <<<<<<<<<<<<<<
 *                j+=1
 *            else:
 */
      __pyx_v_sum = (__pyx_v_sum + (__pyx_v_val2 * M_LN2));

      /* "lurrn/sparsmat.pyx":2413
 *                val2=other.vals_ptr[j]
 *                sum+=val2*M_LN2
 *                j+=1             # <<<<<<<<<<<<<<
 *            else:
 *                val1=self.vals_ptr[i]
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":2415
 *                j+=1
 *            else:
 *                val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                val2=other.vals_ptr[j]
 *                i+=1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":2416
 *            else:
 *                val1=self.vals_ptr[i]
 *                val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                i+=1
 *                j+=1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":2417
 *                val1=self.vals_ptr[i]
 *                val2=other.vals_ptr[j]
 *                i+=1             # <<<<<<<<<<<<<<
 *                j+=1
 *                avg=(val1+val2)/2.0
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":2418
 *                val2=other.vals_ptr[j]
 *                i+=1
 *                j+=1             # <<<<<<<<<<<<<<
 *                avg=(val1+val2)/2.0
 *                sum+=val1*log(val1/avg)+val2*log(val2/avg)
 */
      __pyx_v_j = (__pyx_v_j + 1);

      /* "lurrn/sparsmat.pyx":2419
 *                i+=1
 *                j+=1
 *                avg=(val1+val2)/2.0             # <<<<<<<<<<<<<<
 *                sum+=val1*log(val1/avg)+val2*log(val2/avg)
 *         while i<self.my_len:
 */
      __pyx_v_avg = ((__pyx_v_val1 + __pyx_v_val2) / 2.0);

      /* "lurrn/sparsmat.pyx":2420
 *                j+=1
 *                avg=(val1+val2)/2.0
 *                sum+=val1*log(val1/avg)+val2*log(val2/avg)             # <<<<<<<<<<<<<<
 *         while i<self.my_len:
 *            val1=self.vals_ptr[i]
 */
      if (unlikely(__pyx_v_avg == 0)) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        #ifdef WITH_THREAD
        PyGILState_Release(__pyx_gilstate_save);
        #endif
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      if (unlikely(__pyx_v_avg == 0)) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        #ifdef WITH_THREAD
        PyGILState_Release(__pyx_gilstate_save);
        #endif
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_v_sum = (__pyx_v_sum + ((__pyx_v_val1 * log((__pyx_v_val1 / __pyx_v_avg))) + (__pyx_v_val2 * log((__pyx_v_val2 / __pyx_v_avg)))));
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":2421
 *                avg=(val1+val2)/2.0
 *                sum+=val1*log(val1/avg)+val2*log(val2/avg)
 *         while i<self.my_len:             # <<<<<<<<<<<<<<
 *            val1=self.vals_ptr[i]
 *            i+=1
 */
  while (1) {
    __pyx_t_7 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":2422
 *                sum+=val1*log(val1/avg)+val2*log(val2/avg)
 *         while i<self.my_len:
 *            val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *            i+=1
 *            sum+=val1*M_LN2
 */
    __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":2423
 *         while i<self.my_len:
 *            val1=self.vals_ptr[i]
 *            i+=1             # <<<<<<<<<<<<<<
 *            sum+=val1*M_LN2
 *         while j<other.my_len:
 */
    __pyx_v_i = (__pyx_v_i + 1);

    /* "lurrn/sparsmat.pyx":2424
 *            val1=self.vals_ptr[i]
 *            i+=1
 *            sum+=val1*M_LN2             # <<<<<<<<<<<<<<
 *         while j<other.my_len:
 *            val2=other.vals_ptr[j]
 */
    __pyx_v_sum = (__pyx_v_sum + (__pyx_v_val1 * M_LN2));
  }

  /* "lurrn/sparsmat.pyx":2425
 *            i+=1
 *            sum+=val1*M_LN2
 *         while j<other.my_len:             # <<<<<<<<<<<<<<
 *            val2=other.vals_ptr[j]
 *            j+=1
 */
  while (1) {
    __pyx_t_7 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":2426
 *            sum+=val1*M_LN2
 *         while j<other.my_len:
 *            val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *            j+=1
 *            sum+=val2*M_LN2
 */
    __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":2427
 *         while j<other.my_len:
 *            val2=other.vals_ptr[j]
 *            j+=1             # <<<<<<<<<<<<<<
 *            sum+=val2*M_LN2
 *         return sum/(2.0*M_LN2)
 */
    __pyx_v_j = (__pyx_v_j + 1);

    /* "lurrn/sparsmat.pyx":2428
 *            val2=other.vals_ptr[j]
 *            j+=1
 *            sum+=val2*M_LN2             # <<<<<<<<<<<<<<
 *         return sum/(2.0*M_LN2)
 *     cpdef double skew_unnorm(self, SparseVectorI other, double alpha):
 */
    __pyx_v_sum = (__pyx_v_sum + (__pyx_v_val2 * M_LN2));
  }

  /* "lurrn/sparsmat.pyx":2429
 *            j+=1
 *            sum+=val2*M_LN2
 *         return sum/(2.0*M_LN2)             # <<<<<<<<<<<<<<
 *     cpdef double skew_unnorm(self, SparseVectorI other, double alpha):
 *         cdef double sum=0.0
 */
  __pyx_t_6 = (2.0 * M_LN2);
  if (unlikely(__pyx_t_6 == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_r = (__pyx_v_sum / __pyx_t_6);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2397
 *                 j+=1
 *         return product/sqrt(sqsum_self*sqsum_other)
 *     cpdef double jsd_unnorm(self, SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef double val1, val2, avg
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorI.jsd_unnorm", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_17jsd_unnorm(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_17jsd_unnorm(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("jsd_unnorm (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorI, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_16jsd_unnorm(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_16jsd_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("jsd_unnorm", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorI_jsd_unnorm(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.jsd_unnorm", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2430
 *            sum+=val2*M_LN2
 *         return sum/(2.0*M_LN2)
 *     cpdef double skew_unnorm(self, SparseVectorI other, double alpha):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef double beta=1.0-alpha
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_19skew_unnorm(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorI_skew_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other, double __pyx_v_alpha, int __pyx_skip_dispatch) {
  double __pyx_v_sum;
  double __pyx_v_beta;
  double __pyx_v_val1;
  double __pyx_v_val2;
  double __pyx_v_avg;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  double __pyx_v_log_invbeta;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  double __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("skew_unnorm", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_skew_unnorm); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_19skew_unnorm)) {
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_alpha); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_other));
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_other));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_8;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2431
 *         return sum/(2.0*M_LN2)
 *     cpdef double skew_unnorm(self, SparseVectorI other, double alpha):
 *         cdef double sum=0.0             # <<<<<<<<<<<<<<
 *         cdef double beta=1.0-alpha
 *         cdef double val1, val2, avg
 */
  __pyx_v_sum = 0.0;

  /* "lurrn/sparsmat.pyx":2432
 *     cpdef double skew_unnorm(self, SparseVectorI other, double alpha):
 *         cdef double sum=0.0
 *         cdef double beta=1.0-alpha             # <<<<<<<<<<<<<<
 *         cdef double val1, val2, avg
 *         cdef coordinate_t i, j, idx_i, idx_j
 */
  __pyx_v_beta = (1.0 - __pyx_v_alpha);

  /* "lurrn/sparsmat.pyx":2435
 *         cdef double val1, val2, avg
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         cdef double log_invbeta=log(1.0/beta)             # <<<<<<<<<<<<<<
 *         i=0
 *         j=0
 */
  if (unlikely(__pyx_v_beta == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_log_invbeta = log((1.0 / __pyx_v_beta));

  /* "lurrn/sparsmat.pyx":2436
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         cdef double log_invbeta=log(1.0/beta)
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":2437
 *         cdef double log_invbeta=log(1.0/beta)
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":2438
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *            idx_i=self.idx_ptr[i]
 *            idx_j=self.idx_ptr[j]
 */
  while (1) {
    __pyx_t_10 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_10) {
    } else {
      __pyx_t_9 = __pyx_t_10;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_10 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_9 = __pyx_t_10;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_9) break;

    /* "lurrn/sparsmat.pyx":2439
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *            idx_j=self.idx_ptr[j]
 *            if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":2440
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 *            idx_j=self.idx_ptr[j]             # <<<<<<<<<<<<<<
 *            if idx_i<idx_j:
 *                val1=self.vals_ptr[i]
 */
    __pyx_v_idx_j = (__pyx_v_self->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":2441
 *            idx_i=self.idx_ptr[i]
 *            idx_j=self.idx_ptr[j]
 *            if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *                val1=self.vals_ptr[i]
 *                sum+=val1*log_invbeta
 */
    __pyx_t_9 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_9) {

      /* "lurrn/sparsmat.pyx":2442
 *            idx_j=self.idx_ptr[j]
 *            if idx_i<idx_j:
 *                val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                sum+=val1*log_invbeta
 *                i+=1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":2443
 *            if idx_i<idx_j:
 *                val1=self.vals_ptr[i]
 *                sum+=val1*log_invbeta             # <<<<<<<<<<<<<<
 *                i+=1
 *            elif idx_i>idx_j:
 */
      __pyx_v_sum = (__pyx_v_sum + (__pyx_v_val1 * __pyx_v_log_invbeta));

      /* "lurrn/sparsmat.pyx":2444
 *                val1=self.vals_ptr[i]
 *                sum+=val1*log_invbeta
 *                i+=1             # <<<<<<<<<<<<<<
 *            elif idx_i>idx_j:
 *                j+=1
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":2445
 *                sum+=val1*log_invbeta
 *                i+=1
 *            elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *                j+=1
 *            else:
 */
    __pyx_t_9 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_9) {

      /* "lurrn/sparsmat.pyx":2446
 *                i+=1
 *            elif idx_i>idx_j:
 *                j+=1             # <<<<<<<<<<<<<<
 *            else:
 *                val1=self.vals_ptr[i]
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":2448
 *                j+=1
 *            else:
 *                val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                val2=other.vals_ptr[j]
 *                avg=alpha*val2+beta*val1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":2449
 *            else:
 *                val1=self.vals_ptr[i]
 *                val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                avg=alpha*val2+beta*val1
 *                sum+=log(val1/avg)
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":2450
 *                val1=self.vals_ptr[i]
 *                val2=other.vals_ptr[j]
 *                avg=alpha*val2+beta*val1             # <<<<<<<<<<<<<<
 *                sum+=log(val1/avg)
 *                i+=1
 */
      __pyx_v_avg = ((__pyx_v_alpha * __pyx_v_val2) + (__pyx_v_beta * __pyx_v_val1));

      /* "lurrn/sparsmat.pyx":2451
 *                val2=other.vals_ptr[j]
 *                avg=alpha*val2+beta*val1
 *                sum+=log(val1/avg)             # <<<<<<<<<<<<<<
 *                i+=1
 *                j+=1
 */
      if (unlikely(__pyx_v_avg == 0)) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        #ifdef WITH_THREAD
        PyGILState_Release(__pyx_gilstate_save);
        #endif
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_v_sum = (__pyx_v_sum + log((__pyx_v_val1 / __pyx_v_avg)));

      /* "lurrn/sparsmat.pyx":2452
 *                avg=alpha*val2+beta*val1
 *                sum+=log(val1/avg)
 *                i+=1             # <<<<<<<<<<<<<<
 *                j+=1
 *         return sum
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":2453
 *                sum+=log(val1/avg)
 *                i+=1
 *                j+=1             # <<<<<<<<<<<<<<
 *         return sum
 *     cpdef double norm_l1(self):
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":2454
 *                i+=1
 *                j+=1
 *         return sum             # <<<<<<<<<<<<<<
 *     cpdef double norm_l1(self):
 *         cdef double sum=0.0
 */
  __pyx_r = __pyx_v_sum;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2430
 *            sum+=val2*M_LN2
 *         return sum/(2.0*M_LN2)
 *     cpdef double skew_unnorm(self, SparseVectorI other, double alpha):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef double beta=1.0-alpha
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorI.skew_unnorm", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_19skew_unnorm(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_19skew_unnorm(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other = 0;
  double __pyx_v_alpha;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("skew_unnorm (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_other,&__pyx_n_s_alpha,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_other)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alpha)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("skew_unnorm", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2430; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "skew_unnorm") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2430; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_other = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)values[0]);
    __pyx_v_alpha = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_alpha == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2430; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("skew_unnorm", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2430; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.skew_unnorm", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorI, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_18skew_unnorm(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), __pyx_v_other, __pyx_v_alpha);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_18skew_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other, double __pyx_v_alpha) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("skew_unnorm", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorI_skew_unnorm(__pyx_v_self, __pyx_v_other, __pyx_v_alpha, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.skew_unnorm", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2455
 *                j+=1
 *         return sum
 *     cpdef double norm_l1(self):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef unsigned int i
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_21norm_l1(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorI_norm_l1(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, int __pyx_skip_dispatch) {
  double __pyx_v_sum;
  unsigned int __pyx_v_i;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  double __pyx_t_5;
  unsigned int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("norm_l1", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_norm_l1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_21norm_l1)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_5;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2456
 *         return sum
 *     cpdef double norm_l1(self):
 *         cdef double sum=0.0             # <<<<<<<<<<<<<<
 *         cdef unsigned int i
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_sum = 0.0;

  /* "lurrn/sparsmat.pyx":2458
 *         cdef double sum=0.0
 *         cdef unsigned int i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             sum+=fabs(self.vals_ptr[i])
 *         return sum
 */
  __pyx_t_6 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2459
 *         cdef unsigned int i
 *         for i from 0<=i<self.my_len:
 *             sum+=fabs(self.vals_ptr[i])             # <<<<<<<<<<<<<<
 *         return sum
 *     cpdef double norm_l2(self):
 */
    __pyx_v_sum = (__pyx_v_sum + fabs((__pyx_v_self->vals_ptr[__pyx_v_i])));
  }

  /* "lurrn/sparsmat.pyx":2460
 *         for i from 0<=i<self.my_len:
 *             sum+=fabs(self.vals_ptr[i])
 *         return sum             # <<<<<<<<<<<<<<
 *     cpdef double norm_l2(self):
 *         cdef double sum=0.0
 */
  __pyx_r = __pyx_v_sum;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2455
 *                j+=1
 *         return sum
 *     cpdef double norm_l1(self):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef unsigned int i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorI.norm_l1", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_21norm_l1(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_21norm_l1(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("norm_l1 (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_20norm_l1(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_20norm_l1(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("norm_l1", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorI_norm_l1(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.norm_l1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2461
 *             sum+=fabs(self.vals_ptr[i])
 *         return sum
 *     cpdef double norm_l2(self):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef double val
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_23norm_l2(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorI_norm_l2(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, int __pyx_skip_dispatch) {
  double __pyx_v_sum;
  double __pyx_v_val;
  unsigned int __pyx_v_i;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  double __pyx_t_5;
  unsigned int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("norm_l2", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_norm_l2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_23norm_l2)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_5;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2462
 *         return sum
 *     cpdef double norm_l2(self):
 *         cdef double sum=0.0             # <<<<<<<<<<<<<<
 *         cdef double val
 *         cdef unsigned int i
 */
  __pyx_v_sum = 0.0;

  /* "lurrn/sparsmat.pyx":2465
 *         cdef double val
 *         cdef unsigned int i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             val=self.vals_ptr[i];
 *             sum+=val*val
 */
  __pyx_t_6 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2466
 *         cdef unsigned int i
 *         for i from 0<=i<self.my_len:
 *             val=self.vals_ptr[i];             # <<<<<<<<<<<<<<
 *             sum+=val*val
 *         return sqrt(sum)
 */
    __pyx_v_val = (__pyx_v_self->vals_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":2467
 *         for i from 0<=i<self.my_len:
 *             val=self.vals_ptr[i];
 *             sum+=val*val             # <<<<<<<<<<<<<<
 *         return sqrt(sum)
 *     cpdef double norm_lp(self, double p):
 */
    __pyx_v_sum = (__pyx_v_sum + (__pyx_v_val * __pyx_v_val));
  }

  /* "lurrn/sparsmat.pyx":2468
 *             val=self.vals_ptr[i];
 *             sum+=val*val
 *         return sqrt(sum)             # <<<<<<<<<<<<<<
 *     cpdef double norm_lp(self, double p):
 *         cdef double sum=0.0
 */
  __pyx_r = sqrt(__pyx_v_sum);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2461
 *             sum+=fabs(self.vals_ptr[i])
 *         return sum
 *     cpdef double norm_l2(self):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef double val
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorI.norm_l2", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_23norm_l2(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_23norm_l2(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("norm_l2 (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_22norm_l2(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_22norm_l2(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("norm_l2", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorI_norm_l2(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.norm_l2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2469
 *             sum+=val*val
 *         return sqrt(sum)
 *     cpdef double norm_lp(self, double p):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef int i
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_25norm_lp(PyObject *__pyx_v_self, PyObject *__pyx_arg_p); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorI_norm_lp(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, double __pyx_v_p, int __pyx_skip_dispatch) {
  double __pyx_v_sum;
  int __pyx_v_i;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  double __pyx_t_7;
  unsigned int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("norm_lp", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_norm_lp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_25norm_lp)) {
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_p); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2470
 *         return sqrt(sum)
 *     cpdef double norm_lp(self, double p):
 *         cdef double sum=0.0             # <<<<<<<<<<<<<<
 *         cdef int i
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_sum = 0.0;

  /* "lurrn/sparsmat.pyx":2472
 *         cdef double sum=0.0
 *         cdef int i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             sum+=pow(fabs(self.vals_ptr[i]),p)
 *         return pow(sum,1.0/p)
 */
  __pyx_t_8 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2473
 *         cdef int i
 *         for i from 0<=i<self.my_len:
 *             sum+=pow(fabs(self.vals_ptr[i]),p)             # <<<<<<<<<<<<<<
 *         return pow(sum,1.0/p)
 *     def dotFull(self, numpy.ndarray[int,ndim=1] full):
 */
    __pyx_v_sum = (__pyx_v_sum + pow(fabs((__pyx_v_self->vals_ptr[__pyx_v_i])), __pyx_v_p));
  }

  /* "lurrn/sparsmat.pyx":2474
 *         for i from 0<=i<self.my_len:
 *             sum+=pow(fabs(self.vals_ptr[i]),p)
 *         return pow(sum,1.0/p)             # <<<<<<<<<<<<<<
 *     def dotFull(self, numpy.ndarray[int,ndim=1] full):
 *         cdef int *full_ptr
 */
  if (unlikely(__pyx_v_p == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_r = pow(__pyx_v_sum, (1.0 / __pyx_v_p));
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2469
 *             sum+=val*val
 *         return sqrt(sum)
 *     cpdef double norm_lp(self, double p):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef int i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorI.norm_lp", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_25norm_lp(PyObject *__pyx_v_self, PyObject *__pyx_arg_p); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_25norm_lp(PyObject *__pyx_v_self, PyObject *__pyx_arg_p) {
  double __pyx_v_p;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("norm_lp (wrapper)", 0);
  assert(__pyx_arg_p); {
    __pyx_v_p = __pyx_PyFloat_AsDouble(__pyx_arg_p); if (unlikely((__pyx_v_p == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2469; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.norm_lp", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_24norm_lp(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((double)__pyx_v_p));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_24norm_lp(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, double __pyx_v_p) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("norm_lp", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorI_norm_lp(__pyx_v_self, __pyx_v_p, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.norm_lp", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2475
 *             sum+=pow(fabs(self.vals_ptr[i]),p)
 *         return pow(sum,1.0/p)
 *     def dotFull(self, numpy.ndarray[int,ndim=1] full):             # <<<<<<<<<<<<<<
 *         cdef int *full_ptr
 *         cdef unsigned int my_len=self.my_len
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_27dotFull(PyObject *__pyx_v_self, PyObject *__pyx_v_full); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_27dotFull(PyObject *__pyx_v_self, PyObject *__pyx_v_full) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dotFull (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_full), __pyx_ptype_5numpy_ndarray, 1, "full", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_26dotFull(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((PyArrayObject *)__pyx_v_full));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_26dotFull(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, PyArrayObject *__pyx_v_full) {
  int *__pyx_v_full_ptr;
  unsigned int __pyx_v_my_len;
  unsigned int __pyx_v_full_len;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_full;
  __Pyx_Buffer __pyx_pybuffer_full;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotFull", 0);
  __pyx_pybuffer_full.pybuffer.buf = NULL;
  __pyx_pybuffer_full.refcount = 0;
  __pyx_pybuffernd_full.data = NULL;
  __pyx_pybuffernd_full.rcbuffer = &__pyx_pybuffer_full;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_full.rcbuffer->pybuffer, (PyObject*)__pyx_v_full, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_full.diminfo[0].strides = __pyx_pybuffernd_full.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_full.diminfo[0].shape = __pyx_pybuffernd_full.rcbuffer->pybuffer.shape[0];

  /* "lurrn/sparsmat.pyx":2477
 *     def dotFull(self, numpy.ndarray[int,ndim=1] full):
 *         cdef int *full_ptr
 *         cdef unsigned int my_len=self.my_len             # <<<<<<<<<<<<<<
 *         cdef unsigned int full_len=len(full)
 *         # treat nonpresent values as 0
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  __pyx_v_my_len = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":2478
 *         cdef int *full_ptr
 *         cdef unsigned int my_len=self.my_len
 *         cdef unsigned int full_len=len(full)             # <<<<<<<<<<<<<<
 *         # treat nonpresent values as 0
 *         while my_len>0 and self.idx_ptr[my_len-1]>full_len:
 */
  __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_full)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_full_len = __pyx_t_2;

  /* "lurrn/sparsmat.pyx":2480
 *         cdef unsigned int full_len=len(full)
 *         # treat nonpresent values as 0
 *         while my_len>0 and self.idx_ptr[my_len-1]>full_len:             # <<<<<<<<<<<<<<
 *             my_len-=1
 *         full_ptr=<int*>full.data
 */
  while (1) {
    __pyx_t_4 = ((__pyx_v_my_len > 0) != 0);
    if (__pyx_t_4) {
    } else {
      __pyx_t_3 = __pyx_t_4;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_4 = (((__pyx_v_self->idx_ptr[(__pyx_v_my_len - 1)]) > __pyx_v_full_len) != 0);
    __pyx_t_3 = __pyx_t_4;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_3) break;

    /* "lurrn/sparsmat.pyx":2481
 *         # treat nonpresent values as 0
 *         while my_len>0 and self.idx_ptr[my_len-1]>full_len:
 *             my_len-=1             # <<<<<<<<<<<<<<
 *         full_ptr=<int*>full.data
 *         return self._dotFull_partial(full_ptr,my_len)
 */
    __pyx_v_my_len = (__pyx_v_my_len - 1);
  }

  /* "lurrn/sparsmat.pyx":2482
 *         while my_len>0 and self.idx_ptr[my_len-1]>full_len:
 *             my_len-=1
 *         full_ptr=<int*>full.data             # <<<<<<<<<<<<<<
 *         return self._dotFull_partial(full_ptr,my_len)
 *     def dotFull_check(self, numpy.ndarray[int,ndim=1] full):
 */
  __pyx_v_full_ptr = ((int *)__pyx_v_full->data);

  /* "lurrn/sparsmat.pyx":2483
 *             my_len-=1
 *         full_ptr=<int*>full.data
 *         return self._dotFull_partial(full_ptr,my_len)             # <<<<<<<<<<<<<<
 *     def dotFull_check(self, numpy.ndarray[int,ndim=1] full):
 *         cdef int *full_ptr
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __Pyx_PyInt_From_int(((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self->__pyx_vtab)->_dotFull_partial(__pyx_v_self, __pyx_v_full_ptr, __pyx_v_my_len)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2475
 *             sum+=pow(fabs(self.vals_ptr[i]),p)
 *         return pow(sum,1.0/p)
 *     def dotFull(self, numpy.ndarray[int,ndim=1] full):             # <<<<<<<<<<<<<<
 *         cdef int *full_ptr
 *         cdef unsigned int my_len=self.my_len
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_full.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.dotFull", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_full.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2484
 *         full_ptr=<int*>full.data
 *         return self._dotFull_partial(full_ptr,my_len)
 *     def dotFull_check(self, numpy.ndarray[int,ndim=1] full):             # <<<<<<<<<<<<<<
 *         cdef int *full_ptr
 *         cdef int my_len=self.my_len
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_29dotFull_check(PyObject *__pyx_v_self, PyObject *__pyx_v_full); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_29dotFull_check(PyObject *__pyx_v_self, PyObject *__pyx_v_full) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dotFull_check (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_full), __pyx_ptype_5numpy_ndarray, 1, "full", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_28dotFull_check(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((PyArrayObject *)__pyx_v_full));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_28dotFull_check(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, PyArrayObject *__pyx_v_full) {
  int *__pyx_v_full_ptr;
  CYTHON_UNUSED int __pyx_v_my_len;
  CYTHON_UNUSED int __pyx_v_full_len;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_full;
  __Pyx_Buffer __pyx_pybuffer_full;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  coordinate_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotFull_check", 0);
  __pyx_pybuffer_full.pybuffer.buf = NULL;
  __pyx_pybuffer_full.refcount = 0;
  __pyx_pybuffernd_full.data = NULL;
  __pyx_pybuffernd_full.rcbuffer = &__pyx_pybuffer_full;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_full.rcbuffer->pybuffer, (PyObject*)__pyx_v_full, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_full.diminfo[0].strides = __pyx_pybuffernd_full.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_full.diminfo[0].shape = __pyx_pybuffernd_full.rcbuffer->pybuffer.shape[0];

  /* "lurrn/sparsmat.pyx":2486
 *     def dotFull_check(self, numpy.ndarray[int,ndim=1] full):
 *         cdef int *full_ptr
 *         cdef int my_len=self.my_len             # <<<<<<<<<<<<<<
 *         cdef int full_len=len(full)
 *         # boundary check
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  __pyx_v_my_len = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":2487
 *         cdef int *full_ptr
 *         cdef int my_len=self.my_len
 *         cdef int full_len=len(full)             # <<<<<<<<<<<<<<
 *         # boundary check
 *         full[self.idx_ptr[self.my_len-1]]
 */
  __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_full)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_full_len = __pyx_t_2;

  /* "lurrn/sparsmat.pyx":2489
 *         cdef int full_len=len(full)
 *         # boundary check
 *         full[self.idx_ptr[self.my_len-1]]             # <<<<<<<<<<<<<<
 *         full_ptr=<int*>full.data
 *         return self._dotFull(full_ptr)
 */
  __pyx_t_3 = (__pyx_v_self->idx_ptr[(__pyx_v_self->my_len - 1)]);
  __pyx_t_4 = -1;
  if (unlikely(__pyx_t_3 >= (size_t)__pyx_pybuffernd_full.diminfo[0].shape)) __pyx_t_4 = 0;
  if (unlikely(__pyx_t_4 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_4);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  (*__Pyx_BufPtrStrided1d(int *, __pyx_pybuffernd_full.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_full.diminfo[0].strides));

  /* "lurrn/sparsmat.pyx":2490
 *         # boundary check
 *         full[self.idx_ptr[self.my_len-1]]
 *         full_ptr=<int*>full.data             # <<<<<<<<<<<<<<
 *         return self._dotFull(full_ptr)
 *     def dotMatrix(self, numpy.ndarray[int,ndim=2] full):
 */
  __pyx_v_full_ptr = ((int *)__pyx_v_full->data);

  /* "lurrn/sparsmat.pyx":2491
 *         full[self.idx_ptr[self.my_len-1]]
 *         full_ptr=<int*>full.data
 *         return self._dotFull(full_ptr)             # <<<<<<<<<<<<<<
 *     def dotMatrix(self, numpy.ndarray[int,ndim=2] full):
 *         cdef numpy.ndarray[int,ndim=1] result
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __Pyx_PyInt_From_int(((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self->__pyx_vtab)->_dotFull(__pyx_v_self, __pyx_v_full_ptr)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2484
 *         full_ptr=<int*>full.data
 *         return self._dotFull_partial(full_ptr,my_len)
 *     def dotFull_check(self, numpy.ndarray[int,ndim=1] full):             # <<<<<<<<<<<<<<
 *         cdef int *full_ptr
 *         cdef int my_len=self.my_len
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_full.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.dotFull_check", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_full.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2492
 *         full_ptr=<int*>full.data
 *         return self._dotFull(full_ptr)
 *     def dotMatrix(self, numpy.ndarray[int,ndim=2] full):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[int,ndim=1] result
 *         result = numpy.zeros(full.shape[1], numpy.int32)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_31dotMatrix(PyObject *__pyx_v_self, PyObject *__pyx_v_full); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_31dotMatrix(PyObject *__pyx_v_self, PyObject *__pyx_v_full) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dotMatrix (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_full), __pyx_ptype_5numpy_ndarray, 1, "full", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_30dotMatrix(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((PyArrayObject *)__pyx_v_full));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_30dotMatrix(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, PyArrayObject *__pyx_v_full) {
  PyArrayObject *__pyx_v_result = 0;
  long __pyx_v_i;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_full;
  __Pyx_Buffer __pyx_pybuffer_full;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  unsigned int __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotMatrix", 0);
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
  __pyx_pybuffer_full.pybuffer.buf = NULL;
  __pyx_pybuffer_full.refcount = 0;
  __pyx_pybuffernd_full.data = NULL;
  __pyx_pybuffernd_full.rcbuffer = &__pyx_pybuffer_full;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_full.rcbuffer->pybuffer, (PyObject*)__pyx_v_full, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_full.diminfo[0].strides = __pyx_pybuffernd_full.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_full.diminfo[0].shape = __pyx_pybuffernd_full.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_full.diminfo[1].strides = __pyx_pybuffernd_full.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_full.diminfo[1].shape = __pyx_pybuffernd_full.rcbuffer->pybuffer.shape[1];

  /* "lurrn/sparsmat.pyx":2494
 *     def dotMatrix(self, numpy.ndarray[int,ndim=2] full):
 *         cdef numpy.ndarray[int,ndim=1] result
 *         result = numpy.zeros(full.shape[1], numpy.int32)             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result += full[self.idx_ptr[i]] * self.vals_ptr[i]
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_full->dimensions[1])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __pyx_v_result = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2495
 *         cdef numpy.ndarray[int,ndim=1] result
 *         result = numpy.zeros(full.shape[1], numpy.int32)
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result += full[self.idx_ptr[i]] * self.vals_ptr[i]
 *         return result
 */
  __pyx_t_13 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_13; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2496
 *         result = numpy.zeros(full.shape[1], numpy.int32)
 *         for i from 0<=i<self.my_len:
 *             result += full[self.idx_ptr[i]] * self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *         return result
 *     cdef void _axpy(self, int *x_ptr, int a):
 */
    __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_full), (__pyx_v_self->idx_ptr[__pyx_v_i]), coordinate_t, 0, __Pyx_PyInt_From_coordinate_t, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2496; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_self->vals_ptr[__pyx_v_i])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = PyNumber_Multiply(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), __pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = ((PyArrayObject *)__pyx_t_3);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
      __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_9 < 0)) {
        PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_12, __pyx_t_11, __pyx_t_10);
        }
      }
      __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_8 = 0;
    __Pyx_DECREF_SET(__pyx_v_result, ((PyArrayObject *)__pyx_t_3));
    __pyx_t_3 = 0;
  }

  /* "lurrn/sparsmat.pyx":2497
 *         for i from 0<=i<self.my_len:
 *             result += full[self.idx_ptr[i]] * self.vals_ptr[i]
 *         return result             # <<<<<<<<<<<<<<
 *     cdef void _axpy(self, int *x_ptr, int a):
 *         for i from 0<=i<self.my_len:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2492
 *         full_ptr=<int*>full.data
 *         return self._dotFull(full_ptr)
 *     def dotMatrix(self, numpy.ndarray[int,ndim=2] full):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[int,ndim=1] result
 *         result = numpy.zeros(full.shape[1], numpy.int32)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_full.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.dotMatrix", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_full.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2498
 *             result += full[self.idx_ptr[i]] * self.vals_ptr[i]
 *         return result
 *     cdef void _axpy(self, int *x_ptr, int a):             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             x_ptr[self.idx_ptr[i]]+=a*self.vals_ptr[i]
 */

static void __pyx_f_5lurrn_8sparsmat_13SparseVectorI__axpy(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, int *__pyx_v_x_ptr, int __pyx_v_a) {
  long __pyx_v_i;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  coordinate_t __pyx_t_2;
  __Pyx_RefNannySetupContext("_axpy", 0);

  /* "lurrn/sparsmat.pyx":2499
 *         return result
 *     cdef void _axpy(self, int *x_ptr, int a):
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             x_ptr[self.idx_ptr[i]]+=a*self.vals_ptr[i]
 *     def axpy(self, numpy.ndarray[int,ndim=1] x, int a=1):
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2500
 *     cdef void _axpy(self, int *x_ptr, int a):
 *         for i from 0<=i<self.my_len:
 *             x_ptr[self.idx_ptr[i]]+=a*self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *     def axpy(self, numpy.ndarray[int,ndim=1] x, int a=1):
 *         # boundary check
 */
    __pyx_t_2 = (__pyx_v_self->idx_ptr[__pyx_v_i]);
    (__pyx_v_x_ptr[__pyx_t_2]) = ((__pyx_v_x_ptr[__pyx_t_2]) + (__pyx_v_a * (__pyx_v_self->vals_ptr[__pyx_v_i])));
  }

  /* "lurrn/sparsmat.pyx":2498
 *             result += full[self.idx_ptr[i]] * self.vals_ptr[i]
 *         return result
 *     cdef void _axpy(self, int *x_ptr, int a):             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             x_ptr[self.idx_ptr[i]]+=a*self.vals_ptr[i]
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":2501
 *         for i from 0<=i<self.my_len:
 *             x_ptr[self.idx_ptr[i]]+=a*self.vals_ptr[i]
 *     def axpy(self, numpy.ndarray[int,ndim=1] x, int a=1):             # <<<<<<<<<<<<<<
 *         # boundary check
 *         x[self.idx_ptr[self.my_len-1]]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_33axpy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_33axpy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_x = 0;
  int __pyx_v_a;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("axpy (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_a,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "axpy") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2501; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_x = ((PyArrayObject *)values[0]);
    if (values[1]) {
      __pyx_v_a = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_a == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2501; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_a = ((int)1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("axpy", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2501; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.axpy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_32axpy(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), __pyx_v_x, __pyx_v_a);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_32axpy(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, PyArrayObject *__pyx_v_x, int __pyx_v_a) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_x;
  __Pyx_Buffer __pyx_pybuffer_x;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  coordinate_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("axpy", 0);
  __pyx_pybuffer_x.pybuffer.buf = NULL;
  __pyx_pybuffer_x.refcount = 0;
  __pyx_pybuffernd_x.data = NULL;
  __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0];

  /* "lurrn/sparsmat.pyx":2503
 *     def axpy(self, numpy.ndarray[int,ndim=1] x, int a=1):
 *         # boundary check
 *         x[self.idx_ptr[self.my_len-1]]             # <<<<<<<<<<<<<<
 *         self._axpy(<int *>x.data,a)
 *     cpdef int sqdist(self, SparseVectorI other):
 */
  __pyx_t_1 = (__pyx_v_self->idx_ptr[(__pyx_v_self->my_len - 1)]);
  __pyx_t_2 = -1;
  if (unlikely(__pyx_t_1 >= (size_t)__pyx_pybuffernd_x.diminfo[0].shape)) __pyx_t_2 = 0;
  if (unlikely(__pyx_t_2 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_2);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  (*__Pyx_BufPtrStrided1d(int *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_x.diminfo[0].strides));

  /* "lurrn/sparsmat.pyx":2504
 *         # boundary check
 *         x[self.idx_ptr[self.my_len-1]]
 *         self._axpy(<int *>x.data,a)             # <<<<<<<<<<<<<<
 *     cpdef int sqdist(self, SparseVectorI other):
 *         """computes ||x-y||^2"""
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self->__pyx_vtab)->_axpy(__pyx_v_self, ((int *)__pyx_v_x->data), __pyx_v_a);

  /* "lurrn/sparsmat.pyx":2501
 *         for i from 0<=i<self.my_len:
 *             x_ptr[self.idx_ptr[i]]+=a*self.vals_ptr[i]
 *     def axpy(self, numpy.ndarray[int,ndim=1] x, int a=1):             # <<<<<<<<<<<<<<
 *         # boundary check
 *         x[self.idx_ptr[self.my_len-1]]
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.axpy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2505
 *         x[self.idx_ptr[self.my_len-1]]
 *         self._axpy(<int *>x.data,a)
 *     cpdef int sqdist(self, SparseVectorI other):             # <<<<<<<<<<<<<<
 *         """computes ||x-y||^2"""
 *         cdef int s=0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_35sqdist(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_13SparseVectorI_sqdist(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other, int __pyx_skip_dispatch) {
  int __pyx_v_s;
  int __pyx_v_val;
  int __pyx_v_i1;
  int __pyx_v_i2;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sqdist", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_sqdist); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_35sqdist)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2507
 *     cpdef int sqdist(self, SparseVectorI other):
 *         """computes ||x-y||^2"""
 *         cdef int s=0             # <<<<<<<<<<<<<<
 *         cdef int val
 *         cdef int i1=0,i2=0
 */
  __pyx_v_s = 0;

  /* "lurrn/sparsmat.pyx":2509
 *         cdef int s=0
 *         cdef int val
 *         cdef int i1=0,i2=0             # <<<<<<<<<<<<<<
 *         while i1<self.my_len and i2<other.my_len:
 *             if self.idx_ptr[i1]<other.idx_ptr[i2]:
 */
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":2510
 *         cdef int val
 *         cdef int i1=0,i2=0
 *         while i1<self.my_len and i2<other.my_len:             # <<<<<<<<<<<<<<
 *             if self.idx_ptr[i1]<other.idx_ptr[i2]:
 *                 val=self.vals_ptr[i1]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i1 < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_i2 < __pyx_v_other->my_len) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":2511
 *         cdef int i1=0,i2=0
 *         while i1<self.my_len and i2<other.my_len:
 *             if self.idx_ptr[i1]<other.idx_ptr[i2]:             # <<<<<<<<<<<<<<
 *                 val=self.vals_ptr[i1]
 *                 s+=val*val
 */
    __pyx_t_7 = (((__pyx_v_self->idx_ptr[__pyx_v_i1]) < (__pyx_v_other->idx_ptr[__pyx_v_i2])) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":2512
 *         while i1<self.my_len and i2<other.my_len:
 *             if self.idx_ptr[i1]<other.idx_ptr[i2]:
 *                 val=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                 s+=val*val
 *                 i1+=1
 */
      __pyx_v_val = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

      /* "lurrn/sparsmat.pyx":2513
 *             if self.idx_ptr[i1]<other.idx_ptr[i2]:
 *                 val=self.vals_ptr[i1]
 *                 s+=val*val             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             elif self.idx_ptr[i1]>other.idx_ptr[i2]:
 */
      __pyx_v_s = (__pyx_v_s + (__pyx_v_val * __pyx_v_val));

      /* "lurrn/sparsmat.pyx":2514
 *                 val=self.vals_ptr[i1]
 *                 s+=val*val
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             elif self.idx_ptr[i1]>other.idx_ptr[i2]:
 *                 val=other.vals_ptr[i2]
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":2515
 *                 s+=val*val
 *                 i1+=1
 *             elif self.idx_ptr[i1]>other.idx_ptr[i2]:             # <<<<<<<<<<<<<<
 *                 val=other.vals_ptr[i2]
 *                 s+=val*val
 */
    __pyx_t_7 = (((__pyx_v_self->idx_ptr[__pyx_v_i1]) > (__pyx_v_other->idx_ptr[__pyx_v_i2])) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":2516
 *                 i1+=1
 *             elif self.idx_ptr[i1]>other.idx_ptr[i2]:
 *                 val=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 s+=val*val
 *                 i2+=1
 */
      __pyx_v_val = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":2517
 *             elif self.idx_ptr[i1]>other.idx_ptr[i2]:
 *                 val=other.vals_ptr[i2]
 *                 s+=val*val             # <<<<<<<<<<<<<<
 *                 i2+=1
 *             else:
 */
      __pyx_v_s = (__pyx_v_s + (__pyx_v_val * __pyx_v_val));

      /* "lurrn/sparsmat.pyx":2518
 *                 val=other.vals_ptr[i2]
 *                 s+=val*val
 *                 i2+=1             # <<<<<<<<<<<<<<
 *             else:
 *                 val=self.vals_ptr[i1]-other.vals_ptr[i2]
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":2520
 *                 i2+=1
 *             else:
 *                 val=self.vals_ptr[i1]-other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 s+=val*val
 *                 i1+=1
 */
      __pyx_v_val = ((__pyx_v_self->vals_ptr[__pyx_v_i1]) - (__pyx_v_other->vals_ptr[__pyx_v_i2]));

      /* "lurrn/sparsmat.pyx":2521
 *             else:
 *                 val=self.vals_ptr[i1]-other.vals_ptr[i2]
 *                 s+=val*val             # <<<<<<<<<<<<<<
 *                 i1+=1
 *                 i2+=1
 */
      __pyx_v_s = (__pyx_v_s + (__pyx_v_val * __pyx_v_val));

      /* "lurrn/sparsmat.pyx":2522
 *                 val=self.vals_ptr[i1]-other.vals_ptr[i2]
 *                 s+=val*val
 *                 i1+=1             # <<<<<<<<<<<<<<
 *                 i2+=1
 *         while i1<self.my_len:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);

      /* "lurrn/sparsmat.pyx":2523
 *                 s+=val*val
 *                 i1+=1
 *                 i2+=1             # <<<<<<<<<<<<<<
 *         while i1<self.my_len:
 *             val=self.vals_ptr[i1]
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":2524
 *                 i1+=1
 *                 i2+=1
 *         while i1<self.my_len:             # <<<<<<<<<<<<<<
 *             val=self.vals_ptr[i1]
 *             s+=val*val
 */
  while (1) {
    __pyx_t_7 = ((__pyx_v_i1 < __pyx_v_self->my_len) != 0);
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":2525
 *                 i2+=1
 *         while i1<self.my_len:
 *             val=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *             s+=val*val
 *             i1+=1
 */
    __pyx_v_val = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":2526
 *         while i1<self.my_len:
 *             val=self.vals_ptr[i1]
 *             s+=val*val             # <<<<<<<<<<<<<<
 *             i1+=1
 *         while i2<other.my_len:
 */
    __pyx_v_s = (__pyx_v_s + (__pyx_v_val * __pyx_v_val));

    /* "lurrn/sparsmat.pyx":2527
 *             val=self.vals_ptr[i1]
 *             s+=val*val
 *             i1+=1             # <<<<<<<<<<<<<<
 *         while i2<other.my_len:
 *             val=other.vals_ptr[i2]
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);
  }

  /* "lurrn/sparsmat.pyx":2528
 *             s+=val*val
 *             i1+=1
 *         while i2<other.my_len:             # <<<<<<<<<<<<<<
 *             val=other.vals_ptr[i2]
 *             s+=val*val
 */
  while (1) {
    __pyx_t_7 = ((__pyx_v_i2 < __pyx_v_other->my_len) != 0);
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":2529
 *             i1+=1
 *         while i2<other.my_len:
 *             val=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *             s+=val*val
 *             i2+=1
 */
    __pyx_v_val = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":2530
 *         while i2<other.my_len:
 *             val=other.vals_ptr[i2]
 *             s+=val*val             # <<<<<<<<<<<<<<
 *             i2+=1
 *         return s
 */
    __pyx_v_s = (__pyx_v_s + (__pyx_v_val * __pyx_v_val));

    /* "lurrn/sparsmat.pyx":2531
 *             val=other.vals_ptr[i2]
 *             s+=val*val
 *             i2+=1             # <<<<<<<<<<<<<<
 *         return s
 *     def write_pairs(self, f, delim=':'):
 */
    __pyx_v_i2 = (__pyx_v_i2 + 1);
  }

  /* "lurrn/sparsmat.pyx":2532
 *             s+=val*val
 *             i2+=1
 *         return s             # <<<<<<<<<<<<<<
 *     def write_pairs(self, f, delim=':'):
 *         cdef int i
 */
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2505
 *         x[self.idx_ptr[self.my_len-1]]
 *         self._axpy(<int *>x.data,a)
 *     cpdef int sqdist(self, SparseVectorI other):             # <<<<<<<<<<<<<<
 *         """computes ||x-y||^2"""
 *         cdef int s=0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorI.sqdist", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_35sqdist(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_5lurrn_8sparsmat_13SparseVectorI_34sqdist[] = "computes ||x-y||^2";
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_35sqdist(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sqdist (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorI, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_34sqdist(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_34sqdist(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sqdist", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_5lurrn_8sparsmat_13SparseVectorI_sqdist(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.sqdist", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2533
 *             i2+=1
 *         return s
 *     def write_pairs(self, f, delim=':'):             # <<<<<<<<<<<<<<
 *         cdef int i
 *         w_func=f.write
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_37write_pairs(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_37write_pairs(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_f = 0;
  PyObject *__pyx_v_delim = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_pairs (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_f,&__pyx_n_s_delim,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_kp_s__24);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_f)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_delim);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_pairs") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_f = values[0];
    __pyx_v_delim = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_pairs", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.write_pairs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_36write_pairs(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), __pyx_v_f, __pyx_v_delim);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_36write_pairs(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, PyObject *__pyx_v_f, PyObject *__pyx_v_delim) {
  int __pyx_v_i;
  PyObject *__pyx_v_w_func = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  unsigned int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("write_pairs", 0);

  /* "lurrn/sparsmat.pyx":2535
 *     def write_pairs(self, f, delim=':'):
 *         cdef int i
 *         w_func=f.write             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             # svmlight does not want 0 as index
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_w_func = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2536
 *         cdef int i
 *         w_func=f.write
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             # svmlight does not want 0 as index
 *             w_func(' %d%s%s'%(self.idx_ptr[i]+1,delim,self.vals_ptr[i]))
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2538
 *         for i from 0<=i<self.my_len:
 *             # svmlight does not want 0 as index
 *             w_func(' %d%s%s'%(self.idx_ptr[i]+1,delim,self.vals_ptr[i]))             # <<<<<<<<<<<<<<
 *     def __imul__(self, int a):
 *         cdef coordinate_t i
 */
    __pyx_t_3 = __Pyx_PyInt_From_long(((__pyx_v_self->idx_ptr[__pyx_v_i]) + 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_self->vals_ptr[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_delim);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_delim);
    __Pyx_GIVEREF(__pyx_v_delim);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_d_s_s, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_INCREF(__pyx_v_w_func);
    __pyx_t_5 = __pyx_v_w_func; __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2533
 *             i2+=1
 *         return s
 *     def write_pairs(self, f, delim=':'):             # <<<<<<<<<<<<<<
 *         cdef int i
 *         w_func=f.write
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.write_pairs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_w_func);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2539
 *             # svmlight does not want 0 as index
 *             w_func(' %d%s%s'%(self.idx_ptr[i]+1,delim,self.vals_ptr[i]))
 *     def __imul__(self, int a):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_39__imul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_a); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_39__imul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_a) {
  int __pyx_v_a;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__imul__ (wrapper)", 0);
  assert(__pyx_arg_a); {
    __pyx_v_a = __Pyx_PyInt_As_int(__pyx_arg_a); if (unlikely((__pyx_v_a == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2539; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.__imul__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_38__imul__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((int)__pyx_v_a));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_38__imul__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, int __pyx_v_a) {
  coordinate_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  coordinate_t __pyx_t_2;
  __Pyx_RefNannySetupContext("__imul__", 0);

  /* "lurrn/sparsmat.pyx":2541
 *     def __imul__(self, int a):
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             self.vals_ptr[i] *= a
 *         return self
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2542
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 *             self.vals_ptr[i] *= a             # <<<<<<<<<<<<<<
 *         return self
 *     def __idiv__(self, int a):
 */
    __pyx_t_2 = __pyx_v_i;
    (__pyx_v_self->vals_ptr[__pyx_t_2]) = ((__pyx_v_self->vals_ptr[__pyx_t_2]) * __pyx_v_a);
  }

  /* "lurrn/sparsmat.pyx":2543
 *         for i from 0<=i<self.my_len:
 *             self.vals_ptr[i] *= a
 *         return self             # <<<<<<<<<<<<<<
 *     def __idiv__(self, int a):
 *         cdef coordinate_t i
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2539
 *             # svmlight does not want 0 as index
 *             w_func(' %d%s%s'%(self.idx_ptr[i]+1,delim,self.vals_ptr[i]))
 *     def __imul__(self, int a):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2544
 *             self.vals_ptr[i] *= a
 *         return self
 *     def __idiv__(self, int a):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 */

/* Python wrapper */
#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_41__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_a); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_41__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_a) {
  int __pyx_v_a;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__idiv__ (wrapper)", 0);
  assert(__pyx_arg_a); {
    __pyx_v_a = __Pyx_PyInt_As_int(__pyx_arg_a); if (unlikely((__pyx_v_a == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2544; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.__idiv__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_40__idiv__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((int)__pyx_v_a));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_40__idiv__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, int __pyx_v_a) {
  coordinate_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  coordinate_t __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__idiv__", 0);

  /* "lurrn/sparsmat.pyx":2546
 *     def __idiv__(self, int a):
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             self.vals_ptr[i] /= a
 *         return self
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2547
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 *             self.vals_ptr[i] /= a             # <<<<<<<<<<<<<<
 *         return self
 *     cpdef SparseVectorI min_vals(self, SparseVectorI other):
 */
    __pyx_t_2 = __pyx_v_i;
    if (unlikely(__pyx_v_a == 0)) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      #ifdef WITH_THREAD
      PyGILState_Release(__pyx_gilstate_save);
      #endif
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    else if (sizeof(int) == sizeof(long) && (!(((int)-1) > 0)) && unlikely(__pyx_v_a == (int)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW((__pyx_v_self->vals_ptr[__pyx_t_2])))) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
      #ifdef WITH_THREAD
      PyGILState_Release(__pyx_gilstate_save);
      #endif
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    (__pyx_v_self->vals_ptr[__pyx_t_2]) = __Pyx_div_int((__pyx_v_self->vals_ptr[__pyx_t_2]), __pyx_v_a);
  }

  /* "lurrn/sparsmat.pyx":2548
 *         for i from 0<=i<self.my_len:
 *             self.vals_ptr[i] /= a
 *         return self             # <<<<<<<<<<<<<<
 *     cpdef SparseVectorI min_vals(self, SparseVectorI other):
 *         cdef SparseVectorI result
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2544
 *             self.vals_ptr[i] *= a
 *         return self
 *     def __idiv__(self, int a):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.__idiv__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

/* "lurrn/sparsmat.pyx":2549
 *             self.vals_ptr[i] /= a
 *         return self
 *     cpdef SparseVectorI min_vals(self, SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorI result
 *         cdef coordinate_t i1, i2, k, idx1, idx2
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_43min_vals(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_f_5lurrn_8sparsmat_13SparseVectorI_min_vals(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other, int __pyx_skip_dispatch) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_result = 0;
  coordinate_t __pyx_v_i1;
  coordinate_t __pyx_v_i2;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_idx1;
  coordinate_t __pyx_v_idx2;
  int __pyx_v_val1;
  int __pyx_v_val2;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  unsigned int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("min_vals", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_min_vals); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_43min_vals)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_SparseVectorI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2552
 *         cdef SparseVectorI result
 *         cdef coordinate_t i1, i2, k, idx1, idx2
 *         result=SparseVectorI()             # <<<<<<<<<<<<<<
 *         if self.my_len<other.my_len:
 *             result.my_len=self.my_len
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorI)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2553
 *         cdef coordinate_t i1, i2, k, idx1, idx2
 *         result=SparseVectorI()
 *         if self.my_len<other.my_len:             # <<<<<<<<<<<<<<
 *             result.my_len=self.my_len
 *         else:
 */
  __pyx_t_6 = ((__pyx_v_self->my_len < __pyx_v_other->my_len) != 0);
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":2554
 *         result=SparseVectorI()
 *         if self.my_len<other.my_len:
 *             result.my_len=self.my_len             # <<<<<<<<<<<<<<
 *         else:
 *             result.my_len=other.my_len
 */
    __pyx_t_7 = __pyx_v_self->my_len;
    __pyx_v_result->my_len = __pyx_t_7;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":2556
 *             result.my_len=self.my_len
 *         else:
 *             result.my_len=other.my_len             # <<<<<<<<<<<<<<
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))
 */
    __pyx_t_7 = __pyx_v_other->my_len;
    __pyx_v_result->my_len = __pyx_t_7;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":2557
 *         else:
 *             result.my_len=other.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))
 *         i1=i2=k=0
 */
  __pyx_v_result->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":2558
 *             result.my_len=other.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))             # <<<<<<<<<<<<<<
 *         i1=i2=k=0
 *         while i1<self.my_len and i2<other.my_len:
 */
  __pyx_v_result->vals_ptr = ((int *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(int)))));

  /* "lurrn/sparsmat.pyx":2559
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))
 *         i1=i2=k=0             # <<<<<<<<<<<<<<
 *         while i1<self.my_len and i2<other.my_len:
 *            idx1=self.idx_ptr[i1]
 */
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":2560
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))
 *         i1=i2=k=0
 *         while i1<self.my_len and i2<other.my_len:             # <<<<<<<<<<<<<<
 *            idx1=self.idx_ptr[i1]
 *            idx2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i1 < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_6 = __pyx_t_8;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_i2 < __pyx_v_other->my_len) != 0);
    __pyx_t_6 = __pyx_t_8;
    __pyx_L6_bool_binop_done:;
    if (!__pyx_t_6) break;

    /* "lurrn/sparsmat.pyx":2561
 *         i1=i2=k=0
 *         while i1<self.my_len and i2<other.my_len:
 *            idx1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *            idx2=other.idx_ptr[i2]
 *            if idx1<idx2:
 */
    __pyx_v_idx1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":2562
 *         while i1<self.my_len and i2<other.my_len:
 *            idx1=self.idx_ptr[i1]
 *            idx2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *            if idx1<idx2:
 *                i1+=1
 */
    __pyx_v_idx2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":2563
 *            idx1=self.idx_ptr[i1]
 *            idx2=other.idx_ptr[i2]
 *            if idx1<idx2:             # <<<<<<<<<<<<<<
 *                i1+=1
 *            elif idx1>idx2:
 */
    __pyx_t_6 = ((__pyx_v_idx1 < __pyx_v_idx2) != 0);
    if (__pyx_t_6) {

      /* "lurrn/sparsmat.pyx":2564
 *            idx2=other.idx_ptr[i2]
 *            if idx1<idx2:
 *                i1+=1             # <<<<<<<<<<<<<<
 *            elif idx1>idx2:
 *                i2+=1
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L8;
    }

    /* "lurrn/sparsmat.pyx":2565
 *            if idx1<idx2:
 *                i1+=1
 *            elif idx1>idx2:             # <<<<<<<<<<<<<<
 *                i2+=1
 *            else:
 */
    __pyx_t_6 = ((__pyx_v_idx1 > __pyx_v_idx2) != 0);
    if (__pyx_t_6) {

      /* "lurrn/sparsmat.pyx":2566
 *                i1+=1
 *            elif idx1>idx2:
 *                i2+=1             # <<<<<<<<<<<<<<
 *            else:
 *                result.idx_ptr[k]=idx1
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      goto __pyx_L8;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":2568
 *                i2+=1
 *            else:
 *                result.idx_ptr[k]=idx1             # <<<<<<<<<<<<<<
 *                val1=self.vals_ptr[i1]
 *                val2=other.vals_ptr[i2]
 */
      (__pyx_v_result->idx_ptr[__pyx_v_k]) = __pyx_v_idx1;

      /* "lurrn/sparsmat.pyx":2569
 *            else:
 *                result.idx_ptr[k]=idx1
 *                val1=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                val2=other.vals_ptr[i2]
 *                if val1<val2:
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

      /* "lurrn/sparsmat.pyx":2570
 *                result.idx_ptr[k]=idx1
 *                val1=self.vals_ptr[i1]
 *                val2=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                if val1<val2:
 *                    result.vals_ptr[k]=val1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":2571
 *                val1=self.vals_ptr[i1]
 *                val2=other.vals_ptr[i2]
 *                if val1<val2:             # <<<<<<<<<<<<<<
 *                    result.vals_ptr[k]=val1
 *                else:
 */
      __pyx_t_6 = ((__pyx_v_val1 < __pyx_v_val2) != 0);
      if (__pyx_t_6) {

        /* "lurrn/sparsmat.pyx":2572
 *                val2=other.vals_ptr[i2]
 *                if val1<val2:
 *                    result.vals_ptr[k]=val1             # <<<<<<<<<<<<<<
 *                else:
 *                    result.vals_ptr[k]=val2
 */
        (__pyx_v_result->vals_ptr[__pyx_v_k]) = __pyx_v_val1;
        goto __pyx_L9;
      }
      /*else*/ {

        /* "lurrn/sparsmat.pyx":2574
 *                    result.vals_ptr[k]=val1
 *                else:
 *                    result.vals_ptr[k]=val2             # <<<<<<<<<<<<<<
 *                i1+=1
 *                i2+=1
 */
        (__pyx_v_result->vals_ptr[__pyx_v_k]) = __pyx_v_val2;
      }
      __pyx_L9:;

      /* "lurrn/sparsmat.pyx":2575
 *                else:
 *                    result.vals_ptr[k]=val2
 *                i1+=1             # <<<<<<<<<<<<<<
 *                i2+=1
 *                k+=1
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);

      /* "lurrn/sparsmat.pyx":2576
 *                    result.vals_ptr[k]=val2
 *                i1+=1
 *                i2+=1             # <<<<<<<<<<<<<<
 *                k+=1
 *         result.my_len=k
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":2577
 *                i1+=1
 *                i2+=1
 *                k+=1             # <<<<<<<<<<<<<<
 *         result.my_len=k
 *         return result
 */
      __pyx_v_k = (__pyx_v_k + 1);
    }
    __pyx_L8:;
  }

  /* "lurrn/sparsmat.pyx":2578
 *                i2+=1
 *                k+=1
 *         result.my_len=k             # <<<<<<<<<<<<<<
 *         return result
 *     def scale_array(SparseVectorI self, numpy.ndarray[int, ndim=1] a):
 */
  __pyx_v_result->my_len = __pyx_v_k;

  /* "lurrn/sparsmat.pyx":2579
 *                k+=1
 *         result.my_len=k
 *         return result             # <<<<<<<<<<<<<<
 *     def scale_array(SparseVectorI self, numpy.ndarray[int, ndim=1] a):
 *         cdef SparseVectorI result
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2549
 *             self.vals_ptr[i] /= a
 *         return self
 *     cpdef SparseVectorI min_vals(self, SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorI result
 *         cdef coordinate_t i1, i2, k, idx1, idx2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.min_vals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_43min_vals(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_43min_vals(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("min_vals (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorI, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_42min_vals(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_42min_vals(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("min_vals", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_13SparseVectorI_min_vals(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.min_vals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2580
 *         result.my_len=k
 *         return result
 *     def scale_array(SparseVectorI self, numpy.ndarray[int, ndim=1] a):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorI result
 *         cdef coordinate_t i
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_45scale_array(PyObject *__pyx_v_self, PyObject *__pyx_v_a); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_45scale_array(PyObject *__pyx_v_self, PyObject *__pyx_v_a) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("scale_array (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_5numpy_ndarray, 1, "a", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_44scale_array(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((PyArrayObject *)__pyx_v_a));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_44scale_array(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, PyArrayObject *__pyx_v_a) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_result = 0;
  coordinate_t __pyx_v_i;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_a;
  __Pyx_Buffer __pyx_pybuffer_a;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  unsigned int __pyx_t_2;
  coordinate_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("scale_array", 0);
  __pyx_pybuffer_a.pybuffer.buf = NULL;
  __pyx_pybuffer_a.refcount = 0;
  __pyx_pybuffernd_a.data = NULL;
  __pyx_pybuffernd_a.rcbuffer = &__pyx_pybuffer_a;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_a.rcbuffer->pybuffer, (PyObject*)__pyx_v_a, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_a.diminfo[0].strides = __pyx_pybuffernd_a.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_a.diminfo[0].shape = __pyx_pybuffernd_a.rcbuffer->pybuffer.shape[0];

  /* "lurrn/sparsmat.pyx":2583
 *         cdef SparseVectorI result
 *         cdef coordinate_t i
 *         result=SparseVectorI()             # <<<<<<<<<<<<<<
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorI)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2584
 *         cdef coordinate_t i
 *         result=SparseVectorI()
 *         result.my_len=self.my_len             # <<<<<<<<<<<<<<
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  __pyx_v_result->my_len = __pyx_t_2;

  /* "lurrn/sparsmat.pyx":2585
 *         result=SparseVectorI()
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_result->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":2586
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]
 */
  __pyx_v_result->vals_ptr = ((int *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(int)))));

  /* "lurrn/sparsmat.pyx":2587
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result.idx_ptr[i]=self.idx_ptr[i]
 *         for i from 0<=i<self.my_len:
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2588
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]*a[self.idx_ptr[i]]
 */
    (__pyx_v_result->idx_ptr[__pyx_v_i]) = (__pyx_v_self->idx_ptr[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":2589
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result.vals_ptr[i]=self.vals_ptr[i]*a[self.idx_ptr[i]]
 *         return result
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2590
 *             result.idx_ptr[i]=self.idx_ptr[i]
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]*a[self.idx_ptr[i]]             # <<<<<<<<<<<<<<
 *         return result
 *     def __div__(SparseVectorI self, int a):
 */
    __pyx_t_3 = (__pyx_v_self->idx_ptr[__pyx_v_i]);
    __pyx_t_4 = -1;
    if (unlikely(__pyx_t_3 >= (size_t)__pyx_pybuffernd_a.diminfo[0].shape)) __pyx_t_4 = 0;
    if (unlikely(__pyx_t_4 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_4);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    (__pyx_v_result->vals_ptr[__pyx_v_i]) = ((__pyx_v_self->vals_ptr[__pyx_v_i]) * (*__Pyx_BufPtrStrided1d(int *, __pyx_pybuffernd_a.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_a.diminfo[0].strides)));
  }

  /* "lurrn/sparsmat.pyx":2591
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]*a[self.idx_ptr[i]]
 *         return result             # <<<<<<<<<<<<<<
 *     def __div__(SparseVectorI self, int a):
 *         cdef SparseVectorI result
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2580
 *         result.my_len=k
 *         return result
 *     def scale_array(SparseVectorI self, numpy.ndarray[int, ndim=1] a):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorI result
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_a.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.scale_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_a.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2592
 *             result.vals_ptr[i]=self.vals_ptr[i]*a[self.idx_ptr[i]]
 *         return result
 *     def __div__(SparseVectorI self, int a):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorI result
 *         cdef coordinate_t i
 */

/* Python wrapper */
#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_47__div__(PyObject *__pyx_v_self, PyObject *__pyx_arg_a); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_47__div__(PyObject *__pyx_v_self, PyObject *__pyx_arg_a) {
  int __pyx_v_a;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__div__ (wrapper)", 0);
  assert(__pyx_arg_a); {
    __pyx_v_a = __Pyx_PyInt_As_int(__pyx_arg_a); if (unlikely((__pyx_v_a == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2592; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.__div__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_SparseVectorI, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_46__div__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((int)__pyx_v_a));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_46__div__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, int __pyx_v_a) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_result = 0;
  coordinate_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  unsigned int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__div__", 0);

  /* "lurrn/sparsmat.pyx":2595
 *         cdef SparseVectorI result
 *         cdef coordinate_t i
 *         result=SparseVectorI()             # <<<<<<<<<<<<<<
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorI)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2596
 *         cdef coordinate_t i
 *         result=SparseVectorI()
 *         result.my_len=self.my_len             # <<<<<<<<<<<<<<
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  __pyx_v_result->my_len = __pyx_t_2;

  /* "lurrn/sparsmat.pyx":2597
 *         result=SparseVectorI()
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_result->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":2598
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]
 */
  __pyx_v_result->vals_ptr = ((int *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(int)))));

  /* "lurrn/sparsmat.pyx":2599
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result.idx_ptr[i]=self.idx_ptr[i]
 *         for i from 0<=i<self.my_len:
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2600
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]/a
 */
    (__pyx_v_result->idx_ptr[__pyx_v_i]) = (__pyx_v_self->idx_ptr[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":2601
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result.vals_ptr[i]=self.vals_ptr[i]/a
 *         return result
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2602
 *             result.idx_ptr[i]=self.idx_ptr[i]
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]/a             # <<<<<<<<<<<<<<
 *         return result
 *     def __len__(self):
 */
    if (unlikely(__pyx_v_a == 0)) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      #ifdef WITH_THREAD
      PyGILState_Release(__pyx_gilstate_save);
      #endif
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    else if (sizeof(int) == sizeof(long) && (!(((int)-1) > 0)) && unlikely(__pyx_v_a == (int)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW((__pyx_v_self->vals_ptr[__pyx_v_i])))) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
      #ifdef WITH_THREAD
      PyGILState_Release(__pyx_gilstate_save);
      #endif
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    (__pyx_v_result->vals_ptr[__pyx_v_i]) = __Pyx_div_int((__pyx_v_self->vals_ptr[__pyx_v_i]), __pyx_v_a);
  }

  /* "lurrn/sparsmat.pyx":2603
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]/a
 *         return result             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return self.my_len
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2592
 *             result.vals_ptr[i]=self.vals_ptr[i]*a[self.idx_ptr[i]]
 *         return result
 *     def __div__(SparseVectorI self, int a):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorI result
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.__div__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

/* "lurrn/sparsmat.pyx":2604
 *             result.vals_ptr[i]=self.vals_ptr[i]/a
 *         return result
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.my_len
 *     def __add__(SparseVectorI self,SparseVectorI other):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_49__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_49__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_48__len__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_48__len__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":2605
 *         return result
 *     def __len__(self):
 *         return self.my_len             # <<<<<<<<<<<<<<
 *     def __add__(SparseVectorI self,SparseVectorI other):
 *         cdef coordinate_t *new_idx
 */
  __pyx_r = __pyx_v_self->my_len;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2604
 *             result.vals_ptr[i]=self.vals_ptr[i]/a
 *         return result
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.my_len
 *     def __add__(SparseVectorI self,SparseVectorI other):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2606
 *     def __len__(self):
 *         return self.my_len
 *     def __add__(SparseVectorI self,SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *new_idx
 *         cdef int *new_vals
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_51__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_51__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_SparseVectorI, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorI, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_50__add__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_50__add__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other) {
  coordinate_t *__pyx_v_new_idx;
  int *__pyx_v_new_vals;
  coordinate_t __pyx_v_i1;
  coordinate_t __pyx_v_i2;
  coordinate_t __pyx_v_i_all;
  coordinate_t __pyx_v_n1;
  coordinate_t __pyx_v_n2;
  coordinate_t __pyx_v_n_all;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  coordinate_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":2614
 *         cdef SparseVectorI result
 *         # first pass: determine how much space we need
 *         n1=self.my_len             # <<<<<<<<<<<<<<
 *         n2=other.my_len
 *         n_all=i1=i2=0
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  __pyx_v_n1 = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":2615
 *         # first pass: determine how much space we need
 *         n1=self.my_len
 *         n2=other.my_len             # <<<<<<<<<<<<<<
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:
 */
  __pyx_t_1 = __pyx_v_other->my_len;
  __pyx_v_n2 = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":2616
 *         n1=self.my_len
 *         n2=other.my_len
 *         n_all=i1=i2=0             # <<<<<<<<<<<<<<
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 */
  __pyx_v_n_all = 0;
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":2617
 *         n2=other.my_len
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:             # <<<<<<<<<<<<<<
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":2618
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1
 */
    __pyx_v_k1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":2619
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1
 */
    __pyx_v_k2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":2620
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1             # <<<<<<<<<<<<<<
 *             if k2>=k1: i1+=1
 *             n_all+=1
 */
    __pyx_t_2 = ((__pyx_v_k1 >= __pyx_v_k2) != 0);
    if (__pyx_t_2) {
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "lurrn/sparsmat.pyx":2621
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1             # <<<<<<<<<<<<<<
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1
 */
    __pyx_t_2 = ((__pyx_v_k2 >= __pyx_v_k1) != 0);
    if (__pyx_t_2) {
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "lurrn/sparsmat.pyx":2622
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1
 *             n_all+=1             # <<<<<<<<<<<<<<
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2
 */
    __pyx_v_n_all = (__pyx_v_n_all + 1);
  }

  /* "lurrn/sparsmat.pyx":2623
 *             if k2>=k1: i1+=1
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1             # <<<<<<<<<<<<<<
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 */
  __pyx_t_2 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
  if (__pyx_t_2) {
    __pyx_v_n_all = (__pyx_v_n_all + (__pyx_v_n1 - __pyx_v_i1));
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "lurrn/sparsmat.pyx":2624
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2             # <<<<<<<<<<<<<<
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 *         new_vals=<int *>PyMem_Malloc(n_all*sizeof(int))
 */
  __pyx_t_2 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
  if (__pyx_t_2) {
    __pyx_v_n_all = (__pyx_v_n_all + (__pyx_v_n2 - __pyx_v_i2));
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "lurrn/sparsmat.pyx":2625
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         new_vals=<int *>PyMem_Malloc(n_all*sizeof(int))
 *         # second pass: fill in the actual values
 */
  __pyx_v_new_idx = ((coordinate_t *)PyMem_Malloc((__pyx_v_n_all * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":2626
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 *         new_vals=<int *>PyMem_Malloc(n_all*sizeof(int))             # <<<<<<<<<<<<<<
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0
 */
  __pyx_v_new_vals = ((int *)PyMem_Malloc((__pyx_v_n_all * (sizeof(int)))));

  /* "lurrn/sparsmat.pyx":2628
 *         new_vals=<int *>PyMem_Malloc(n_all*sizeof(int))
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0             # <<<<<<<<<<<<<<
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 */
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;
  __pyx_v_i_all = 0;

  /* "lurrn/sparsmat.pyx":2629
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0
 *         while i1<n1 and i2<n2:             # <<<<<<<<<<<<<<
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L13_bool_binop_done:;
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":2630
 *         i1=i2=i_all=0
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:
 */
    __pyx_v_k1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":2631
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *             if k1>=k2:
 *                 new_idx[i_all]=k2
 */
    __pyx_v_k2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":2632
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=other.vals_ptr[i2]
 */
    __pyx_t_2 = ((__pyx_v_k1 >= __pyx_v_k2) != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":2633
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:
 *                 new_idx[i_all]=k2             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = __pyx_v_k2;

      /* "lurrn/sparsmat.pyx":2634
 *             if k1>=k2:
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 i2+=1
 *                 if k1==k2:
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":2635
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1             # <<<<<<<<<<<<<<
 *                 if k1==k2:
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":2636
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 *                 if k1==k2:             # <<<<<<<<<<<<<<
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 *                     i1+=1
 */
      __pyx_t_2 = ((__pyx_v_k1 == __pyx_v_k2) != 0);
      if (__pyx_t_2) {

        /* "lurrn/sparsmat.pyx":2637
 *                 i2+=1
 *                 if k1==k2:
 *                     new_vals[i_all]+=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                     i1+=1
 *             elif k2>=k1:
 */
        __pyx_t_4 = __pyx_v_i_all;
        (__pyx_v_new_vals[__pyx_t_4]) = ((__pyx_v_new_vals[__pyx_t_4]) + (__pyx_v_self->vals_ptr[__pyx_v_i1]));

        /* "lurrn/sparsmat.pyx":2638
 *                 if k1==k2:
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 *                     i1+=1             # <<<<<<<<<<<<<<
 *             elif k2>=k1:
 *                 new_idx[i_all]=k1
 */
        __pyx_v_i1 = (__pyx_v_i1 + 1);
        goto __pyx_L16;
      }
      __pyx_L16:;
      goto __pyx_L15;
    }

    /* "lurrn/sparsmat.pyx":2639
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 *                     i1+=1
 *             elif k2>=k1:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]
 */
    __pyx_t_2 = ((__pyx_v_k2 >= __pyx_v_k1) != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":2640
 *                     i1+=1
 *             elif k2>=k1:
 *                 new_idx[i_all]=k1             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = __pyx_v_k1;

      /* "lurrn/sparsmat.pyx":2641
 *             elif k2>=k1:
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             i_all+=1
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

      /* "lurrn/sparsmat.pyx":2642
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             i_all+=1
 *         while i1<n1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L15;
    }
    __pyx_L15:;

    /* "lurrn/sparsmat.pyx":2643
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1
 *             i_all+=1             # <<<<<<<<<<<<<<
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]
 */
    __pyx_v_i_all = (__pyx_v_i_all + 1);
  }

  /* "lurrn/sparsmat.pyx":2644
 *                 i1+=1
 *             i_all+=1
 *         while i1<n1:             # <<<<<<<<<<<<<<
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":2645
 *             i_all+=1
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1
 */
    (__pyx_v_new_idx[__pyx_v_i_all]) = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":2646
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *             i1+=1
 *             i_all+=1
 */
    (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":2647
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1             # <<<<<<<<<<<<<<
 *             i_all+=1
 *         else:
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);

    /* "lurrn/sparsmat.pyx":2648
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1
 *             i_all+=1             # <<<<<<<<<<<<<<
 *         else:
 *             while i2<n2:
 */
    __pyx_v_i_all = (__pyx_v_i_all + 1);
  }

  /* "lurrn/sparsmat.pyx":2650
 *             i_all+=1
 *         else:
 *             while i2<n2:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=other.vals_ptr[i2]
 */
  /*else*/ {
    while (1) {
      __pyx_t_2 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
      if (!__pyx_t_2) break;

      /* "lurrn/sparsmat.pyx":2651
 *         else:
 *             while i2<n2:
 *                 new_idx[i_all]=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":2652
 *             while i2<n2:
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 i2+=1
 *                 i_all+=1
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":2653
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1             # <<<<<<<<<<<<<<
 *                 i_all+=1
 *         assert i_all==n_all
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":2654
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 *                 i_all+=1             # <<<<<<<<<<<<<<
 *         assert i_all==n_all
 *         result=SparseVectorI()
 */
      __pyx_v_i_all = (__pyx_v_i_all + 1);
    }
  }

  /* "lurrn/sparsmat.pyx":2655
 *                 i2+=1
 *                 i_all+=1
 *         assert i_all==n_all             # <<<<<<<<<<<<<<
 *         result=SparseVectorI()
 *         result.my_len=n_all
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_i_all == __pyx_v_n_all) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":2656
 *                 i_all+=1
 *         assert i_all==n_all
 *         result=SparseVectorI()             # <<<<<<<<<<<<<<
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx
 */
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorI)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "lurrn/sparsmat.pyx":2657
 *         assert i_all==n_all
 *         result=SparseVectorI()
 *         result.my_len=n_all             # <<<<<<<<<<<<<<
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals
 */
  __pyx_v_result->my_len = __pyx_v_n_all;

  /* "lurrn/sparsmat.pyx":2658
 *         result=SparseVectorI()
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx             # <<<<<<<<<<<<<<
 *         result.vals_ptr=new_vals
 *         return result
 */
  __pyx_v_result->idx_ptr = __pyx_v_new_idx;

  /* "lurrn/sparsmat.pyx":2659
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals             # <<<<<<<<<<<<<<
 *         return result
 *     def __sub__(SparseVectorI self,SparseVectorI other):
 */
  __pyx_v_result->vals_ptr = __pyx_v_new_vals;

  /* "lurrn/sparsmat.pyx":2660
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals
 *         return result             # <<<<<<<<<<<<<<
 *     def __sub__(SparseVectorI self,SparseVectorI other):
 *         cdef coordinate_t *new_idx
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2606
 *     def __len__(self):
 *         return self.my_len
 *     def __add__(SparseVectorI self,SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *new_idx
 *         cdef int *new_vals
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2661
 *         result.vals_ptr=new_vals
 *         return result
 *     def __sub__(SparseVectorI self,SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *new_idx
 *         cdef int *new_vals
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_53__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_53__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__sub__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_SparseVectorI, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorI, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_52__sub__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_52__sub__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other) {
  coordinate_t *__pyx_v_new_idx;
  int *__pyx_v_new_vals;
  coordinate_t __pyx_v_i1;
  coordinate_t __pyx_v_i2;
  coordinate_t __pyx_v_i_all;
  coordinate_t __pyx_v_n1;
  coordinate_t __pyx_v_n2;
  coordinate_t __pyx_v_n_all;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  coordinate_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__sub__", 0);

  /* "lurrn/sparsmat.pyx":2669
 *         cdef SparseVectorI result
 *         # first pass: determine how much space we need
 *         n1=self.my_len             # <<<<<<<<<<<<<<
 *         n2=other.my_len
 *         n_all=i1=i2=0
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  __pyx_v_n1 = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":2670
 *         # first pass: determine how much space we need
 *         n1=self.my_len
 *         n2=other.my_len             # <<<<<<<<<<<<<<
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:
 */
  __pyx_t_1 = __pyx_v_other->my_len;
  __pyx_v_n2 = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":2671
 *         n1=self.my_len
 *         n2=other.my_len
 *         n_all=i1=i2=0             # <<<<<<<<<<<<<<
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 */
  __pyx_v_n_all = 0;
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":2672
 *         n2=other.my_len
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:             # <<<<<<<<<<<<<<
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":2673
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1
 */
    __pyx_v_k1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":2674
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1
 */
    __pyx_v_k2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":2675
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1             # <<<<<<<<<<<<<<
 *             if k2>=k1: i1+=1
 *             n_all+=1
 */
    __pyx_t_2 = ((__pyx_v_k1 >= __pyx_v_k2) != 0);
    if (__pyx_t_2) {
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "lurrn/sparsmat.pyx":2676
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1             # <<<<<<<<<<<<<<
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1
 */
    __pyx_t_2 = ((__pyx_v_k2 >= __pyx_v_k1) != 0);
    if (__pyx_t_2) {
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "lurrn/sparsmat.pyx":2677
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1
 *             n_all+=1             # <<<<<<<<<<<<<<
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2
 */
    __pyx_v_n_all = (__pyx_v_n_all + 1);
  }

  /* "lurrn/sparsmat.pyx":2678
 *             if k2>=k1: i1+=1
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1             # <<<<<<<<<<<<<<
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 */
  __pyx_t_2 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
  if (__pyx_t_2) {
    __pyx_v_n_all = (__pyx_v_n_all + (__pyx_v_n1 - __pyx_v_i1));
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "lurrn/sparsmat.pyx":2679
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2             # <<<<<<<<<<<<<<
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 *         new_vals=<int *>PyMem_Malloc(n_all*sizeof(int))
 */
  __pyx_t_2 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
  if (__pyx_t_2) {
    __pyx_v_n_all = (__pyx_v_n_all + (__pyx_v_n2 - __pyx_v_i2));
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "lurrn/sparsmat.pyx":2680
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         new_vals=<int *>PyMem_Malloc(n_all*sizeof(int))
 *         # second pass: fill in the actual values
 */
  __pyx_v_new_idx = ((coordinate_t *)PyMem_Malloc((__pyx_v_n_all * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":2681
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 *         new_vals=<int *>PyMem_Malloc(n_all*sizeof(int))             # <<<<<<<<<<<<<<
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0
 */
  __pyx_v_new_vals = ((int *)PyMem_Malloc((__pyx_v_n_all * (sizeof(int)))));

  /* "lurrn/sparsmat.pyx":2683
 *         new_vals=<int *>PyMem_Malloc(n_all*sizeof(int))
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0             # <<<<<<<<<<<<<<
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 */
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;
  __pyx_v_i_all = 0;

  /* "lurrn/sparsmat.pyx":2684
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0
 *         while i1<n1 and i2<n2:             # <<<<<<<<<<<<<<
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L13_bool_binop_done:;
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":2685
 *         i1=i2=i_all=0
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:
 */
    __pyx_v_k1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":2686
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *             if k1>=k2:
 *                 new_idx[i_all]=k2
 */
    __pyx_v_k2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":2687
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 */
    __pyx_t_2 = ((__pyx_v_k1 >= __pyx_v_k2) != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":2688
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:
 *                 new_idx[i_all]=k2             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 *                 i2+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = __pyx_v_k2;

      /* "lurrn/sparsmat.pyx":2689
 *             if k1>=k2:
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=-other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 i2+=1
 *                 if k1==k2:
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (-(__pyx_v_other->vals_ptr[__pyx_v_i2]));

      /* "lurrn/sparsmat.pyx":2690
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 *                 i2+=1             # <<<<<<<<<<<<<<
 *                 if k1==k2:
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":2691
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 *                 i2+=1
 *                 if k1==k2:             # <<<<<<<<<<<<<<
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 *                     i1+=1
 */
      __pyx_t_2 = ((__pyx_v_k1 == __pyx_v_k2) != 0);
      if (__pyx_t_2) {

        /* "lurrn/sparsmat.pyx":2692
 *                 i2+=1
 *                 if k1==k2:
 *                     new_vals[i_all]+=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                     i1+=1
 *             elif k2>=k1:
 */
        __pyx_t_4 = __pyx_v_i_all;
        (__pyx_v_new_vals[__pyx_t_4]) = ((__pyx_v_new_vals[__pyx_t_4]) + (__pyx_v_self->vals_ptr[__pyx_v_i1]));

        /* "lurrn/sparsmat.pyx":2693
 *                 if k1==k2:
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 *                     i1+=1             # <<<<<<<<<<<<<<
 *             elif k2>=k1:
 *                 new_idx[i_all]=k1
 */
        __pyx_v_i1 = (__pyx_v_i1 + 1);
        goto __pyx_L16;
      }
      __pyx_L16:;
      goto __pyx_L15;
    }

    /* "lurrn/sparsmat.pyx":2694
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 *                     i1+=1
 *             elif k2>=k1:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]
 */
    __pyx_t_2 = ((__pyx_v_k2 >= __pyx_v_k1) != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":2695
 *                     i1+=1
 *             elif k2>=k1:
 *                 new_idx[i_all]=k1             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = __pyx_v_k1;

      /* "lurrn/sparsmat.pyx":2696
 *             elif k2>=k1:
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             i_all+=1
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

      /* "lurrn/sparsmat.pyx":2697
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             i_all+=1
 *         while i1<n1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L15;
    }
    __pyx_L15:;

    /* "lurrn/sparsmat.pyx":2698
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1
 *             i_all+=1             # <<<<<<<<<<<<<<
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]
 */
    __pyx_v_i_all = (__pyx_v_i_all + 1);
  }

  /* "lurrn/sparsmat.pyx":2699
 *                 i1+=1
 *             i_all+=1
 *         while i1<n1:             # <<<<<<<<<<<<<<
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":2700
 *             i_all+=1
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1
 */
    (__pyx_v_new_idx[__pyx_v_i_all]) = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":2701
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *             i1+=1
 *             i_all+=1
 */
    (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":2702
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1             # <<<<<<<<<<<<<<
 *             i_all+=1
 *         else:
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);

    /* "lurrn/sparsmat.pyx":2703
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1
 *             i_all+=1             # <<<<<<<<<<<<<<
 *         else:
 *             while i2<n2:
 */
    __pyx_v_i_all = (__pyx_v_i_all + 1);
  }

  /* "lurrn/sparsmat.pyx":2705
 *             i_all+=1
 *         else:
 *             while i2<n2:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 */
  /*else*/ {
    while (1) {
      __pyx_t_2 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
      if (!__pyx_t_2) break;

      /* "lurrn/sparsmat.pyx":2706
 *         else:
 *             while i2<n2:
 *                 new_idx[i_all]=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 *                 i2+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":2707
 *             while i2<n2:
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=-other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 i2+=1
 *                 i_all+=1
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (-(__pyx_v_other->vals_ptr[__pyx_v_i2]));

      /* "lurrn/sparsmat.pyx":2708
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 *                 i2+=1             # <<<<<<<<<<<<<<
 *                 i_all+=1
 *         assert i_all==n_all
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":2709
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 *                 i2+=1
 *                 i_all+=1             # <<<<<<<<<<<<<<
 *         assert i_all==n_all
 *         result=SparseVectorI()
 */
      __pyx_v_i_all = (__pyx_v_i_all + 1);
    }
  }

  /* "lurrn/sparsmat.pyx":2710
 *                 i2+=1
 *                 i_all+=1
 *         assert i_all==n_all             # <<<<<<<<<<<<<<
 *         result=SparseVectorI()
 *         result.my_len=n_all
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_i_all == __pyx_v_n_all) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":2711
 *                 i_all+=1
 *         assert i_all==n_all
 *         result=SparseVectorI()             # <<<<<<<<<<<<<<
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx
 */
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorI)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "lurrn/sparsmat.pyx":2712
 *         assert i_all==n_all
 *         result=SparseVectorI()
 *         result.my_len=n_all             # <<<<<<<<<<<<<<
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals
 */
  __pyx_v_result->my_len = __pyx_v_n_all;

  /* "lurrn/sparsmat.pyx":2713
 *         result=SparseVectorI()
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx             # <<<<<<<<<<<<<<
 *         result.vals_ptr=new_vals
 *         return result
 */
  __pyx_v_result->idx_ptr = __pyx_v_new_idx;

  /* "lurrn/sparsmat.pyx":2714
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals             # <<<<<<<<<<<<<<
 *         return result
 *     def __or__(SparseVectorI self,SparseVectorI other):
 */
  __pyx_v_result->vals_ptr = __pyx_v_new_vals;

  /* "lurrn/sparsmat.pyx":2715
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals
 *         return result             # <<<<<<<<<<<<<<
 *     def __or__(SparseVectorI self,SparseVectorI other):
 *         cdef coordinate_t *new_idx
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2661
 *         result.vals_ptr=new_vals
 *         return result
 *     def __sub__(SparseVectorI self,SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *new_idx
 *         cdef int *new_vals
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.__sub__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2716
 *         result.vals_ptr=new_vals
 *         return result
 *     def __or__(SparseVectorI self,SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *new_idx
 *         cdef int *new_vals
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_55__or__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_55__or__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__or__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_SparseVectorI, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorI, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_54__or__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_54__or__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_other) {
  coordinate_t *__pyx_v_new_idx;
  int *__pyx_v_new_vals;
  coordinate_t __pyx_v_i1;
  coordinate_t __pyx_v_i2;
  coordinate_t __pyx_v_i_all;
  coordinate_t __pyx_v_n1;
  coordinate_t __pyx_v_n2;
  coordinate_t __pyx_v_n_all;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_result = 0;
  int __pyx_v_val;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__or__", 0);

  /* "lurrn/sparsmat.pyx":2725
 *         cdef int val
 *         # first pass: determine how much space we need
 *         n1=self.my_len             # <<<<<<<<<<<<<<
 *         n2=other.my_len
 *         n_all=i1=i2=0
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  __pyx_v_n1 = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":2726
 *         # first pass: determine how much space we need
 *         n1=self.my_len
 *         n2=other.my_len             # <<<<<<<<<<<<<<
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:
 */
  __pyx_t_1 = __pyx_v_other->my_len;
  __pyx_v_n2 = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":2727
 *         n1=self.my_len
 *         n2=other.my_len
 *         n_all=i1=i2=0             # <<<<<<<<<<<<<<
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 */
  __pyx_v_n_all = 0;
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":2728
 *         n2=other.my_len
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:             # <<<<<<<<<<<<<<
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":2729
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1
 */
    __pyx_v_k1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":2730
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1
 */
    __pyx_v_k2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":2731
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1             # <<<<<<<<<<<<<<
 *             if k2>=k1: i1+=1
 *             n_all+=1
 */
    __pyx_t_2 = ((__pyx_v_k1 >= __pyx_v_k2) != 0);
    if (__pyx_t_2) {
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "lurrn/sparsmat.pyx":2732
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1             # <<<<<<<<<<<<<<
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1
 */
    __pyx_t_2 = ((__pyx_v_k2 >= __pyx_v_k1) != 0);
    if (__pyx_t_2) {
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "lurrn/sparsmat.pyx":2733
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1
 *             n_all+=1             # <<<<<<<<<<<<<<
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2
 */
    __pyx_v_n_all = (__pyx_v_n_all + 1);
  }

  /* "lurrn/sparsmat.pyx":2734
 *             if k2>=k1: i1+=1
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1             # <<<<<<<<<<<<<<
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 */
  __pyx_t_2 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
  if (__pyx_t_2) {
    __pyx_v_n_all = (__pyx_v_n_all + (__pyx_v_n1 - __pyx_v_i1));
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "lurrn/sparsmat.pyx":2735
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2             # <<<<<<<<<<<<<<
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 *         new_vals=<int *>PyMem_Malloc(n_all*sizeof(int))
 */
  __pyx_t_2 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
  if (__pyx_t_2) {
    __pyx_v_n_all = (__pyx_v_n_all + (__pyx_v_n2 - __pyx_v_i2));
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "lurrn/sparsmat.pyx":2736
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         new_vals=<int *>PyMem_Malloc(n_all*sizeof(int))
 *         # second pass: fill in the actual values
 */
  __pyx_v_new_idx = ((coordinate_t *)PyMem_Malloc((__pyx_v_n_all * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":2737
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 *         new_vals=<int *>PyMem_Malloc(n_all*sizeof(int))             # <<<<<<<<<<<<<<
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0
 */
  __pyx_v_new_vals = ((int *)PyMem_Malloc((__pyx_v_n_all * (sizeof(int)))));

  /* "lurrn/sparsmat.pyx":2739
 *         new_vals=<int *>PyMem_Malloc(n_all*sizeof(int))
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0             # <<<<<<<<<<<<<<
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 */
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;
  __pyx_v_i_all = 0;

  /* "lurrn/sparsmat.pyx":2740
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0
 *         while i1<n1 and i2<n2:             # <<<<<<<<<<<<<<
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L13_bool_binop_done:;
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":2741
 *         i1=i2=i_all=0
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:
 */
    __pyx_v_k1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":2742
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *             if k1>=k2:
 *                 new_idx[i_all]=k2
 */
    __pyx_v_k2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":2743
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=other.vals_ptr[i2]
 */
    __pyx_t_2 = ((__pyx_v_k1 >= __pyx_v_k2) != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":2744
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:
 *                 new_idx[i_all]=k2             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = __pyx_v_k2;

      /* "lurrn/sparsmat.pyx":2745
 *             if k1>=k2:
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 i2+=1
 *                 if k1==k2:
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":2746
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1             # <<<<<<<<<<<<<<
 *                 if k1==k2:
 *                     val=self.vals_ptr[i1]
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":2747
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 *                 if k1==k2:             # <<<<<<<<<<<<<<
 *                     val=self.vals_ptr[i1]
 *                     if new_vals[i_all]<val:
 */
      __pyx_t_2 = ((__pyx_v_k1 == __pyx_v_k2) != 0);
      if (__pyx_t_2) {

        /* "lurrn/sparsmat.pyx":2748
 *                 i2+=1
 *                 if k1==k2:
 *                     val=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                     if new_vals[i_all]<val:
 *                         new_vals[i_all]=val
 */
        __pyx_v_val = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

        /* "lurrn/sparsmat.pyx":2749
 *                 if k1==k2:
 *                     val=self.vals_ptr[i1]
 *                     if new_vals[i_all]<val:             # <<<<<<<<<<<<<<
 *                         new_vals[i_all]=val
 *                     i1+=1
 */
        __pyx_t_2 = (((__pyx_v_new_vals[__pyx_v_i_all]) < __pyx_v_val) != 0);
        if (__pyx_t_2) {

          /* "lurrn/sparsmat.pyx":2750
 *                     val=self.vals_ptr[i1]
 *                     if new_vals[i_all]<val:
 *                         new_vals[i_all]=val             # <<<<<<<<<<<<<<
 *                     i1+=1
 *             else: # k2>k1:
 */
          (__pyx_v_new_vals[__pyx_v_i_all]) = __pyx_v_val;
          goto __pyx_L17;
        }
        __pyx_L17:;

        /* "lurrn/sparsmat.pyx":2751
 *                     if new_vals[i_all]<val:
 *                         new_vals[i_all]=val
 *                     i1+=1             # <<<<<<<<<<<<<<
 *             else: # k2>k1:
 *                 new_idx[i_all]=k1
 */
        __pyx_v_i1 = (__pyx_v_i1 + 1);
        goto __pyx_L16;
      }
      __pyx_L16:;
      goto __pyx_L15;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":2753
 *                     i1+=1
 *             else: # k2>k1:
 *                 new_idx[i_all]=k1             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = __pyx_v_k1;

      /* "lurrn/sparsmat.pyx":2754
 *             else: # k2>k1:
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             i_all+=1
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

      /* "lurrn/sparsmat.pyx":2755
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             i_all+=1
 *         while i1<n1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
    }
    __pyx_L15:;

    /* "lurrn/sparsmat.pyx":2756
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1
 *             i_all+=1             # <<<<<<<<<<<<<<
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]
 */
    __pyx_v_i_all = (__pyx_v_i_all + 1);
  }

  /* "lurrn/sparsmat.pyx":2757
 *                 i1+=1
 *             i_all+=1
 *         while i1<n1:             # <<<<<<<<<<<<<<
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":2758
 *             i_all+=1
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1
 */
    (__pyx_v_new_idx[__pyx_v_i_all]) = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":2759
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *             i1+=1
 *             i_all+=1
 */
    (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":2760
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1             # <<<<<<<<<<<<<<
 *             i_all+=1
 *         else:
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);

    /* "lurrn/sparsmat.pyx":2761
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1
 *             i_all+=1             # <<<<<<<<<<<<<<
 *         else:
 *             while i2<n2:
 */
    __pyx_v_i_all = (__pyx_v_i_all + 1);
  }

  /* "lurrn/sparsmat.pyx":2763
 *             i_all+=1
 *         else:
 *             while i2<n2:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=other.vals_ptr[i2]
 */
  /*else*/ {
    while (1) {
      __pyx_t_2 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
      if (!__pyx_t_2) break;

      /* "lurrn/sparsmat.pyx":2764
 *         else:
 *             while i2<n2:
 *                 new_idx[i_all]=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":2765
 *             while i2<n2:
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 i2+=1
 *                 i_all+=1
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":2766
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1             # <<<<<<<<<<<<<<
 *                 i_all+=1
 *         assert i_all==n_all
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":2767
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 *                 i_all+=1             # <<<<<<<<<<<<<<
 *         assert i_all==n_all
 *         result=SparseVectorI()
 */
      __pyx_v_i_all = (__pyx_v_i_all + 1);
    }
  }

  /* "lurrn/sparsmat.pyx":2768
 *                 i2+=1
 *                 i_all+=1
 *         assert i_all==n_all             # <<<<<<<<<<<<<<
 *         result=SparseVectorI()
 *         result.my_len=n_all
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_i_all == __pyx_v_n_all) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":2769
 *                 i_all+=1
 *         assert i_all==n_all
 *         result=SparseVectorI()             # <<<<<<<<<<<<<<
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx
 */
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorI)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "lurrn/sparsmat.pyx":2770
 *         assert i_all==n_all
 *         result=SparseVectorI()
 *         result.my_len=n_all             # <<<<<<<<<<<<<<
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals
 */
  __pyx_v_result->my_len = __pyx_v_n_all;

  /* "lurrn/sparsmat.pyx":2771
 *         result=SparseVectorI()
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx             # <<<<<<<<<<<<<<
 *         result.vals_ptr=new_vals
 *         return result
 */
  __pyx_v_result->idx_ptr = __pyx_v_new_idx;

  /* "lurrn/sparsmat.pyx":2772
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals             # <<<<<<<<<<<<<<
 *         return result
 *     def __lshift__(self, int k):
 */
  __pyx_v_result->vals_ptr = __pyx_v_new_vals;

  /* "lurrn/sparsmat.pyx":2773
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals
 *         return result             # <<<<<<<<<<<<<<
 *     def __lshift__(self, int k):
 *         cdef SparseVectorI result
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2716
 *         result.vals_ptr=new_vals
 *         return result
 *     def __or__(SparseVectorI self,SparseVectorI other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *new_idx
 *         cdef int *new_vals
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.__or__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2774
 *         result.vals_ptr=new_vals
 *         return result
 *     def __lshift__(self, int k):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorI result
 *         cdef coordinate_t i
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_57__lshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_57__lshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__lshift__ (wrapper)", 0);
  assert(__pyx_arg_k); {
    __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2774; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.__lshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_56__lshift__(((PyObject *)__pyx_v_self), ((int)__pyx_v_k));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_56__lshift__(PyObject *__pyx_v_self, int __pyx_v_k) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_result = 0;
  coordinate_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  unsigned int __pyx_t_2;
  coordinate_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  coordinate_t __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__lshift__", 0);

  /* "lurrn/sparsmat.pyx":2777
 *         cdef SparseVectorI result
 *         cdef coordinate_t i
 *         result=SparseVectorI()             # <<<<<<<<<<<<<<
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorI)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2778
 *         cdef coordinate_t i
 *         result=SparseVectorI()
 *         result.my_len=self.my_len             # <<<<<<<<<<<<<<
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_my_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_unsigned_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_result->my_len = __pyx_t_2;

  /* "lurrn/sparsmat.pyx":2779
 *         result=SparseVectorI()
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_result->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":2780
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]+k
 */
  __pyx_v_result->vals_ptr = ((int *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(int)))));

  /* "lurrn/sparsmat.pyx":2781
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result.idx_ptr[i]=self.idx_ptr[i]+k
 *         for i from 0<=i<self.my_len:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_my_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_coordinate_t(__pyx_t_1); if (unlikely((__pyx_t_3 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2782
 *         result.vals_ptr=<int *>PyMem_Malloc(result.my_len*sizeof(int))
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]+k             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_idx_ptr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_i, coordinate_t, 0, __Pyx_PyInt_From_coordinate_t, 0, 0, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = __Pyx_PyInt_As_coordinate_t(__pyx_t_5); if (unlikely((__pyx_t_6 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    (__pyx_v_result->idx_ptr[__pyx_v_i]) = __pyx_t_6;
  }

  /* "lurrn/sparsmat.pyx":2783
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]+k
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result.vals_ptr[i]=self.vals_ptr[i]
 *         return result
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_my_len); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyInt_As_coordinate_t(__pyx_t_5); if (unlikely((__pyx_t_3 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2784
 *             result.idx_ptr[i]=self.idx_ptr[i]+k
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *         return result
 *     def __ilshift__(self, int k):
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_vals_ptr); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_5, __pyx_v_i, coordinate_t, 0, __Pyx_PyInt_From_coordinate_t, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2784; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    (__pyx_v_result->vals_ptr[__pyx_v_i]) = __pyx_t_7;
  }

  /* "lurrn/sparsmat.pyx":2785
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]
 *         return result             # <<<<<<<<<<<<<<
 *     def __ilshift__(self, int k):
 *         cdef SparseVectorI result
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2774
 *         result.vals_ptr=new_vals
 *         return result
 *     def __lshift__(self, int k):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorI result
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.__lshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2786
 *             result.vals_ptr[i]=self.vals_ptr[i]
 *         return result
 *     def __ilshift__(self, int k):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorI result
 *         cdef coordinate_t i
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_59__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_59__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ilshift__ (wrapper)", 0);
  assert(__pyx_arg_k); {
    __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2786; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.__ilshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_58__ilshift__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((int)__pyx_v_k));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_58__ilshift__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, int __pyx_v_k) {
  coordinate_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  coordinate_t __pyx_t_2;
  __Pyx_RefNannySetupContext("__ilshift__", 0);

  /* "lurrn/sparsmat.pyx":2789
 *         cdef SparseVectorI result
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             self.idx_ptr[i]+=k
 *         return self
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2790
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 *             self.idx_ptr[i]+=k             # <<<<<<<<<<<<<<
 *         return self
 *     def __getitem__(self, int i):
 */
    __pyx_t_2 = __pyx_v_i;
    (__pyx_v_self->idx_ptr[__pyx_t_2]) = ((__pyx_v_self->idx_ptr[__pyx_t_2]) + __pyx_v_k);
  }

  /* "lurrn/sparsmat.pyx":2791
 *         for i from 0<=i<self.my_len:
 *             self.idx_ptr[i]+=k
 *         return self             # <<<<<<<<<<<<<<
 *     def __getitem__(self, int i):
 *         if i<0:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2786
 *             result.vals_ptr[i]=self.vals_ptr[i]
 *         return result
 *     def __ilshift__(self, int k):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorI result
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2792
 *             self.idx_ptr[i]+=k
 *         return self
 *     def __getitem__(self, int i):             # <<<<<<<<<<<<<<
 *         if i<0:
 *             i=self.my_len+i
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_61__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_i); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_61__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_i) {
  int __pyx_v_i;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  assert(__pyx_arg_i); {
    __pyx_v_i = __Pyx_PyInt_As_int(__pyx_arg_i); if (unlikely((__pyx_v_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2792; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_60__getitem__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((int)__pyx_v_i));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_60__getitem__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, int __pyx_v_i) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "lurrn/sparsmat.pyx":2793
 *         return self
 *     def __getitem__(self, int i):
 *         if i<0:             # <<<<<<<<<<<<<<
 *             i=self.my_len+i
 *         if i>=self.my_len or i<0:
 */
  __pyx_t_1 = ((__pyx_v_i < 0) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":2794
 *     def __getitem__(self, int i):
 *         if i<0:
 *             i=self.my_len+i             # <<<<<<<<<<<<<<
 *         if i>=self.my_len or i<0:
 *             raise IndexError
 */
    __pyx_v_i = (__pyx_v_self->my_len + __pyx_v_i);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":2795
 *         if i<0:
 *             i=self.my_len+i
 *         if i>=self.my_len or i<0:             # <<<<<<<<<<<<<<
 *             raise IndexError
 *         return (self.idx_ptr[i],self.vals_ptr[i])
 */
  __pyx_t_2 = ((__pyx_v_i >= __pyx_v_self->my_len) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_i < 0) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":2796
 *             i=self.my_len+i
 *         if i>=self.my_len or i<0:
 *             raise IndexError             # <<<<<<<<<<<<<<
 *         return (self.idx_ptr[i],self.vals_ptr[i])
 *     def __repr__(self):
 */
    __Pyx_Raise(__pyx_builtin_IndexError, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lurrn/sparsmat.pyx":2797
 *         if i>=self.my_len or i<0:
 *             raise IndexError
 *         return (self.idx_ptr[i],self.vals_ptr[i])             # <<<<<<<<<<<<<<
 *     def __repr__(self):
 *         cdef unsigned int i
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->idx_ptr[__pyx_v_i])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_self->vals_ptr[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2792
 *             self.idx_ptr[i]+=k
 *         return self
 *     def __getitem__(self, int i):             # <<<<<<<<<<<<<<
 *         if i<0:
 *             i=self.my_len+i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2798
 *             raise IndexError
 *         return (self.idx_ptr[i],self.vals_ptr[i])
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         cdef unsigned int i
 *         ss=[]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_63__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_63__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_62__repr__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_62__repr__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self) {
  unsigned int __pyx_v_i;
  PyObject *__pyx_v_ss = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  unsigned int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "lurrn/sparsmat.pyx":2800
 *     def __repr__(self):
 *         cdef unsigned int i
 *         ss=[]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             ss.append('(%d,%s)'%(self.idx_ptr[i],self.vals_ptr[i]))
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ss = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2801
 *         cdef unsigned int i
 *         ss=[]
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             ss.append('(%d,%s)'%(self.idx_ptr[i],self.vals_ptr[i]))
 *         return 'SparseVectorI([%s])'%(','.join(ss))
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2802
 *         ss=[]
 *         for i from 0<=i<self.my_len:
 *             ss.append('(%d,%s)'%(self.idx_ptr[i],self.vals_ptr[i]))             # <<<<<<<<<<<<<<
 *         return 'SparseVectorI([%s])'%(','.join(ss))
 *     def __reduce_ex__(self,protocol):
 */
    __pyx_t_1 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->idx_ptr[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_self->vals_ptr[__pyx_v_i])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_d_s, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyList_Append(__pyx_v_ss, __pyx_t_3); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }

  /* "lurrn/sparsmat.pyx":2803
 *         for i from 0<=i<self.my_len:
 *             ss.append('(%d,%s)'%(self.idx_ptr[i],self.vals_ptr[i]))
 *         return 'SparseVectorI([%s])'%(','.join(ss))             # <<<<<<<<<<<<<<
 *     def __reduce_ex__(self,protocol):
 *         if protocol==0:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyString_Join(__pyx_kp_s__25, __pyx_v_ss); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_SparseVectorI_s, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2798
 *             raise IndexError
 *         return (self.idx_ptr[i],self.vals_ptr[i])
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         cdef unsigned int i
 *         ss=[]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ss);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2804
 *             ss.append('(%d,%s)'%(self.idx_ptr[i],self.vals_ptr[i]))
 *         return 'SparseVectorI([%s])'%(','.join(ss))
 *     def __reduce_ex__(self,protocol):             # <<<<<<<<<<<<<<
 *         if protocol==0:
 *             # choose compatibility over performance.
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_65__reduce_ex__(PyObject *__pyx_v_self, PyObject *__pyx_v_protocol); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_65__reduce_ex__(PyObject *__pyx_v_self, PyObject *__pyx_v_protocol) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_ex__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_64__reduce_ex__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((PyObject *)__pyx_v_protocol));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_64__reduce_ex__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, PyObject *__pyx_v_protocol) {
  PyObject *__pyx_v_s_idx = NULL;
  PyObject *__pyx_v_s_vals = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_ex__", 0);

  /* "lurrn/sparsmat.pyx":2805
 *         return 'SparseVectorI([%s])'%(','.join(ss))
 *     def __reduce_ex__(self,protocol):
 *         if protocol==0:             # <<<<<<<<<<<<<<
 *             # choose compatibility over performance.
 *             return (SparseVectorI,(list(self),),())
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_protocol, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "lurrn/sparsmat.pyx":2807
 *         if protocol==0:
 *             # choose compatibility over performance.
 *             return (SparseVectorI,(list(self),),())             # <<<<<<<<<<<<<<
 *         else:
 *             s_idx=PyString_FromStringAndSize(<char *>self.idx_ptr,self.my_len*sizeof(coordinate_t))
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorI)));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorI)));
    __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorI)));
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_empty_tuple);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_empty_tuple);
    __Pyx_GIVEREF(__pyx_empty_tuple);
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":2809
 *             return (SparseVectorI,(list(self),),())
 *         else:
 *             s_idx=PyString_FromStringAndSize(<char *>self.idx_ptr,self.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *             s_vals=PyString_FromStringAndSize(<char *>self.vals_ptr,self.my_len*sizeof(int))
 *             return (SparseVectorI,(None,),(s_idx,s_vals))
 */
    __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->idx_ptr), (__pyx_v_self->my_len * (sizeof(coordinate_t)))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_s_idx = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "lurrn/sparsmat.pyx":2810
 *         else:
 *             s_idx=PyString_FromStringAndSize(<char *>self.idx_ptr,self.my_len*sizeof(coordinate_t))
 *             s_vals=PyString_FromStringAndSize(<char *>self.vals_ptr,self.my_len*sizeof(int))             # <<<<<<<<<<<<<<
 *             return (SparseVectorI,(None,),(s_idx,s_vals))
 *     def __setstate__(self,state):
 */
    __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->vals_ptr), (__pyx_v_self->my_len * (sizeof(int)))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_s_vals = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "lurrn/sparsmat.pyx":2811
 *             s_idx=PyString_FromStringAndSize(<char *>self.idx_ptr,self.my_len*sizeof(coordinate_t))
 *             s_vals=PyString_FromStringAndSize(<char *>self.vals_ptr,self.my_len*sizeof(int))
 *             return (SparseVectorI,(None,),(s_idx,s_vals))             # <<<<<<<<<<<<<<
 *     def __setstate__(self,state):
 *         cdef coordinate_t *p_idx
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_s_idx);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_s_idx);
    __Pyx_GIVEREF(__pyx_v_s_idx);
    __Pyx_INCREF(__pyx_v_s_vals);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_s_vals);
    __Pyx_GIVEREF(__pyx_v_s_vals);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorI)));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorI)));
    __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorI)));
    __Pyx_INCREF(__pyx_tuple__26);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_tuple__26);
    __Pyx_GIVEREF(__pyx_tuple__26);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":2804
 *             ss.append('(%d,%s)'%(self.idx_ptr[i],self.vals_ptr[i]))
 *         return 'SparseVectorI([%s])'%(','.join(ss))
 *     def __reduce_ex__(self,protocol):             # <<<<<<<<<<<<<<
 *         if protocol==0:
 *             # choose compatibility over performance.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.__reduce_ex__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s_idx);
  __Pyx_XDECREF(__pyx_v_s_vals);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2812
 *             s_vals=PyString_FromStringAndSize(<char *>self.vals_ptr,self.my_len*sizeof(int))
 *             return (SparseVectorI,(None,),(s_idx,s_vals))
 *     def __setstate__(self,state):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *p_idx
 *         cdef int *p_vals
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_67__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_67__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_66__setstate__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self), ((PyObject *)__pyx_v_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_66__setstate__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self, PyObject *__pyx_v_state) {
  coordinate_t *__pyx_v_p_idx;
  int *__pyx_v_p_vals;
  PyObject *__pyx_v_s_idx = NULL;
  PyObject *__pyx_v_s_vals = NULL;
  long __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  char *__pyx_t_7;
  size_t __pyx_t_8;
  unsigned int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* "lurrn/sparsmat.pyx":2815
 *         cdef coordinate_t *p_idx
 *         cdef int *p_vals
 *         if len(state)==0:             # <<<<<<<<<<<<<<
 *             pass
 *         elif len(state)==2:
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_state); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((__pyx_t_1 == 0) != 0);
  if (__pyx_t_2) {
    goto __pyx_L3;
  }

  /* "lurrn/sparsmat.pyx":2817
 *         if len(state)==0:
 *             pass
 *         elif len(state)==2:             # <<<<<<<<<<<<<<
 *             assert (self.idx_ptr==NULL)
 *             (s_idx, s_vals)=state
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_state); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((__pyx_t_1 == 2) != 0);
  if (__pyx_t_2) {

    /* "lurrn/sparsmat.pyx":2818
 *             pass
 *         elif len(state)==2:
 *             assert (self.idx_ptr==NULL)             # <<<<<<<<<<<<<<
 *             (s_idx, s_vals)=state
 *             p_idx=<coordinate_t *>(<char *>s_idx)
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      if (unlikely(!((__pyx_v_self->idx_ptr == NULL) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":2819
 *         elif len(state)==2:
 *             assert (self.idx_ptr==NULL)
 *             (s_idx, s_vals)=state             # <<<<<<<<<<<<<<
 *             p_idx=<coordinate_t *>(<char *>s_idx)
 *             p_vals=<int *>(<char *>s_vals)
 */
    if ((likely(PyTuple_CheckExact(__pyx_v_state))) || (PyList_CheckExact(__pyx_v_state))) {
      PyObject* sequence = __pyx_v_state;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      #endif
    } else {
      Py_ssize_t index = -1;
      __pyx_t_5 = PyObject_GetIter(__pyx_v_state); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = NULL;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L5_unpacking_done;
      __pyx_L4_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L5_unpacking_done:;
    }
    __pyx_v_s_idx = __pyx_t_3;
    __pyx_t_3 = 0;
    __pyx_v_s_vals = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":2820
 *             assert (self.idx_ptr==NULL)
 *             (s_idx, s_vals)=state
 *             p_idx=<coordinate_t *>(<char *>s_idx)             # <<<<<<<<<<<<<<
 *             p_vals=<int *>(<char *>s_vals)
 *             self.my_len=len(s_idx)/sizeof(coordinate_t)
 */
    __pyx_t_7 = __Pyx_PyObject_AsString(__pyx_v_s_idx); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_p_idx = ((coordinate_t *)((char *)__pyx_t_7));

    /* "lurrn/sparsmat.pyx":2821
 *             (s_idx, s_vals)=state
 *             p_idx=<coordinate_t *>(<char *>s_idx)
 *             p_vals=<int *>(<char *>s_vals)             # <<<<<<<<<<<<<<
 *             self.my_len=len(s_idx)/sizeof(coordinate_t)
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 */
    __pyx_t_7 = __Pyx_PyObject_AsString(__pyx_v_s_vals); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_p_vals = ((int *)((char *)__pyx_t_7));

    /* "lurrn/sparsmat.pyx":2822
 *             p_idx=<coordinate_t *>(<char *>s_idx)
 *             p_vals=<int *>(<char *>s_vals)
 *             self.my_len=len(s_idx)/sizeof(coordinate_t)             # <<<<<<<<<<<<<<
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *             self.vals_ptr=<int *>PyMem_Malloc(self.my_len*sizeof(int))
 */
    __pyx_t_1 = PyObject_Length(__pyx_v_s_idx); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = (sizeof(coordinate_t));
    if (unlikely(__pyx_t_8 == 0)) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      #ifdef WITH_THREAD
      PyGILState_Release(__pyx_gilstate_save);
      #endif
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_self->my_len = (__pyx_t_1 / __pyx_t_8);

    /* "lurrn/sparsmat.pyx":2823
 *             p_vals=<int *>(<char *>s_vals)
 *             self.my_len=len(s_idx)/sizeof(coordinate_t)
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *             self.vals_ptr=<int *>PyMem_Malloc(self.my_len*sizeof(int))
 *             for i from 0<=i<self.my_len:
 */
    __pyx_v_self->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_self->my_len * (sizeof(coordinate_t)))));

    /* "lurrn/sparsmat.pyx":2824
 *             self.my_len=len(s_idx)/sizeof(coordinate_t)
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *             self.vals_ptr=<int *>PyMem_Malloc(self.my_len*sizeof(int))             # <<<<<<<<<<<<<<
 *             for i from 0<=i<self.my_len:
 *                 self.idx_ptr[i]=p_idx[i]
 */
    __pyx_v_self->vals_ptr = ((int *)PyMem_Malloc((__pyx_v_self->my_len * (sizeof(int)))));

    /* "lurrn/sparsmat.pyx":2825
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *             self.vals_ptr=<int *>PyMem_Malloc(self.my_len*sizeof(int))
 *             for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *                 self.idx_ptr[i]=p_idx[i]
 *                 self.vals_ptr[i]=p_vals[i]
 */
    __pyx_t_9 = __pyx_v_self->my_len;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":2826
 *             self.vals_ptr=<int *>PyMem_Malloc(self.my_len*sizeof(int))
 *             for i from 0<=i<self.my_len:
 *                 self.idx_ptr[i]=p_idx[i]             # <<<<<<<<<<<<<<
 *                 self.vals_ptr[i]=p_vals[i]
 *     def __dealloc__(self):
 */
      (__pyx_v_self->idx_ptr[__pyx_v_i]) = (__pyx_v_p_idx[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":2827
 *             for i from 0<=i<self.my_len:
 *                 self.idx_ptr[i]=p_idx[i]
 *                 self.vals_ptr[i]=p_vals[i]             # <<<<<<<<<<<<<<
 *     def __dealloc__(self):
 *         if self.buf is None:
 */
      (__pyx_v_self->vals_ptr[__pyx_v_i]) = (__pyx_v_p_vals[__pyx_v_i]);
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":2812
 *             s_vals=PyString_FromStringAndSize(<char *>self.vals_ptr,self.my_len*sizeof(int))
 *             return (SparseVectorI,(None,),(s_idx,s_vals))
 *     def __setstate__(self,state):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *p_idx
 *         cdef int *p_vals
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.__setstate__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s_idx);
  __Pyx_XDECREF(__pyx_v_s_vals);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2828
 *                 self.idx_ptr[i]=p_idx[i]
 *                 self.vals_ptr[i]=p_vals[i]
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.buf is None:
 *             PyMem_Free(self.idx_ptr)
 */

/* Python wrapper */
static void __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_69__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_69__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_68__dealloc__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_68__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lurrn/sparsmat.pyx":2829
 *                 self.vals_ptr[i]=p_vals[i]
 *     def __dealloc__(self):
 *         if self.buf is None:             # <<<<<<<<<<<<<<
 *             PyMem_Free(self.idx_ptr)
 *             PyMem_Free(self.vals_ptr)
 */
  __pyx_t_1 = (__pyx_v_self->buf == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lurrn/sparsmat.pyx":2830
 *     def __dealloc__(self):
 *         if self.buf is None:
 *             PyMem_Free(self.idx_ptr)             # <<<<<<<<<<<<<<
 *             PyMem_Free(self.vals_ptr)
 *         else:
 */
    PyMem_Free(__pyx_v_self->idx_ptr);

    /* "lurrn/sparsmat.pyx":2831
 *         if self.buf is None:
 *             PyMem_Free(self.idx_ptr)
 *             PyMem_Free(self.vals_ptr)             # <<<<<<<<<<<<<<
 *         else:
 *             self.buf=None
 */
    PyMem_Free(__pyx_v_self->vals_ptr);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":2833
 *             PyMem_Free(self.vals_ptr)
 *         else:
 *             self.buf=None             # <<<<<<<<<<<<<<
 *         self.idx_ptr=<coordinate_t *>0
 *         self.vals_ptr=<int *>0
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->buf);
    __Pyx_DECREF(__pyx_v_self->buf);
    __pyx_v_self->buf = Py_None;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":2834
 *         else:
 *             self.buf=None
 *         self.idx_ptr=<coordinate_t *>0             # <<<<<<<<<<<<<<
 *         self.vals_ptr=<int *>0
 *         self.my_len=0
 */
  __pyx_v_self->idx_ptr = ((coordinate_t *)0);

  /* "lurrn/sparsmat.pyx":2835
 *             self.buf=None
 *         self.idx_ptr=<coordinate_t *>0
 *         self.vals_ptr=<int *>0             # <<<<<<<<<<<<<<
 *         self.my_len=0
 *     def to_scipy(self):
 */
  __pyx_v_self->vals_ptr = ((int *)0);

  /* "lurrn/sparsmat.pyx":2836
 *         self.idx_ptr=<coordinate_t *>0
 *         self.vals_ptr=<int *>0
 *         self.my_len=0             # <<<<<<<<<<<<<<
 *     def to_scipy(self):
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] data
 */
  __pyx_v_self->my_len = 0;

  /* "lurrn/sparsmat.pyx":2828
 *                 self.idx_ptr[i]=p_idx[i]
 *                 self.vals_ptr[i]=p_vals[i]
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.buf is None:
 *             PyMem_Free(self.idx_ptr)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":2837
 *         self.vals_ptr=<int *>0
 *         self.my_len=0
 *     def to_scipy(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] data
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indices
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_71to_scipy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_71to_scipy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_scipy (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorI_70to_scipy(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorI_70to_scipy(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_self) {
  PyArrayObject *__pyx_v_data = 0;
  PyArrayObject *__pyx_v_indices = 0;
  PyArrayObject *__pyx_v_indptr = 0;
  int __pyx_v_i;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_data;
  __Pyx_Buffer __pyx_pybuffer_data;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indices;
  __Pyx_Buffer __pyx_pybuffer_indices;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indptr;
  __Pyx_Buffer __pyx_pybuffer_indptr;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyArrayObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyArrayObject *__pyx_t_13 = NULL;
  PyArrayObject *__pyx_t_14 = NULL;
  unsigned int __pyx_t_15;
  long __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_scipy", 0);
  __pyx_pybuffer_data.pybuffer.buf = NULL;
  __pyx_pybuffer_data.refcount = 0;
  __pyx_pybuffernd_data.data = NULL;
  __pyx_pybuffernd_data.rcbuffer = &__pyx_pybuffer_data;
  __pyx_pybuffer_indices.pybuffer.buf = NULL;
  __pyx_pybuffer_indices.refcount = 0;
  __pyx_pybuffernd_indices.data = NULL;
  __pyx_pybuffernd_indices.rcbuffer = &__pyx_pybuffer_indices;
  __pyx_pybuffer_indptr.pybuffer.buf = NULL;
  __pyx_pybuffer_indptr.refcount = 0;
  __pyx_pybuffernd_indptr.data = NULL;
  __pyx_pybuffernd_indptr.rcbuffer = &__pyx_pybuffer_indptr;

  /* "lurrn/sparsmat.pyx":2842
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indptr
 *         cdef int i,j
 *         indptr=numpy.zeros(2, numpy.int32)             # <<<<<<<<<<<<<<
 *         indices=numpy.zeros(self.my_len, numpy.int32)
 *         data=numpy.zeros(self.my_len, numpy.int32)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_int_2);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
    __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_8 < 0)) {
      PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer, (PyObject*)__pyx_v_indptr, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
    }
    __pyx_pybuffernd_indptr.diminfo[0].strides = __pyx_pybuffernd_indptr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indptr.diminfo[0].shape = __pyx_pybuffernd_indptr.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_7 = 0;
  __pyx_v_indptr = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2843
 *         cdef int i,j
 *         indptr=numpy.zeros(2, numpy.int32)
 *         indices=numpy.zeros(self.my_len, numpy.int32)             # <<<<<<<<<<<<<<
 *         data=numpy.zeros(self.my_len, numpy.int32)
 *         indptr[1]=self.my_len
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->my_len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_12 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_5, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_5, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_13 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
    __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indices.rcbuffer->pybuffer, (PyObject*)__pyx_t_13, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_8 < 0)) {
      PyErr_Fetch(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indices.rcbuffer->pybuffer, (PyObject*)__pyx_v_indices, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_11, __pyx_t_10, __pyx_t_9);
      }
    }
    __pyx_pybuffernd_indices.diminfo[0].strides = __pyx_pybuffernd_indices.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indices.diminfo[0].shape = __pyx_pybuffernd_indices.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_13 = 0;
  __pyx_v_indices = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2844
 *         indptr=numpy.zeros(2, numpy.int32)
 *         indices=numpy.zeros(self.my_len, numpy.int32)
 *         data=numpy.zeros(self.my_len, numpy.int32)             # <<<<<<<<<<<<<<
 *         indptr[1]=self.my_len
 *         for i from 0<=i<self.my_len:
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_zeros); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->my_len); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_6 = 0;
  __pyx_t_3 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
    __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_8 < 0)) {
      PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data.rcbuffer->pybuffer, (PyObject*)__pyx_v_data, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
    }
    __pyx_pybuffernd_data.diminfo[0].strides = __pyx_pybuffernd_data.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_data.diminfo[0].shape = __pyx_pybuffernd_data.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_14 = 0;
  __pyx_v_data = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2845
 *         indices=numpy.zeros(self.my_len, numpy.int32)
 *         data=numpy.zeros(self.my_len, numpy.int32)
 *         indptr[1]=self.my_len             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             indices[i]=0
 */
  __pyx_t_15 = __pyx_v_self->my_len;
  __pyx_t_16 = 1;
  __pyx_t_8 = -1;
  if (__pyx_t_16 < 0) {
    __pyx_t_16 += __pyx_pybuffernd_indptr.diminfo[0].shape;
    if (unlikely(__pyx_t_16 < 0)) __pyx_t_8 = 0;
  } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_indptr.diminfo[0].shape)) __pyx_t_8 = 0;
  if (unlikely(__pyx_t_8 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_8);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_indptr.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_indptr.diminfo[0].strides) = __pyx_t_15;

  /* "lurrn/sparsmat.pyx":2846
 *         data=numpy.zeros(self.my_len, numpy.int32)
 *         indptr[1]=self.my_len
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             indices[i]=0
 *         for i from 0<=i<self.my_len:
 */
  __pyx_t_15 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_15; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2847
 *         indptr[1]=self.my_len
 *         for i from 0<=i<self.my_len:
 *             indices[i]=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             data[i]=self.vals_ptr[i]
 */
    __pyx_t_8 = __pyx_v_i;
    __pyx_t_17 = -1;
    if (__pyx_t_8 < 0) {
      __pyx_t_8 += __pyx_pybuffernd_indices.diminfo[0].shape;
      if (unlikely(__pyx_t_8 < 0)) __pyx_t_17 = 0;
    } else if (unlikely(__pyx_t_8 >= __pyx_pybuffernd_indices.diminfo[0].shape)) __pyx_t_17 = 0;
    if (unlikely(__pyx_t_17 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_17);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_indices.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_indices.diminfo[0].strides) = 0;
  }

  /* "lurrn/sparsmat.pyx":2848
 *         for i from 0<=i<self.my_len:
 *             indices[i]=0
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             data[i]=self.vals_ptr[i]
 *         return (data,indices,indptr)
 */
  __pyx_t_15 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_15; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2849
 *             indices[i]=0
 *         for i from 0<=i<self.my_len:
 *             data[i]=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *         return (data,indices,indptr)
 * 
 */
    __pyx_t_17 = __pyx_v_i;
    __pyx_t_18 = -1;
    if (__pyx_t_17 < 0) {
      __pyx_t_17 += __pyx_pybuffernd_data.diminfo[0].shape;
      if (unlikely(__pyx_t_17 < 0)) __pyx_t_18 = 0;
    } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_data.diminfo[0].shape)) __pyx_t_18 = 0;
    if (unlikely(__pyx_t_18 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_18);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_data.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_data.diminfo[0].strides) = (__pyx_v_self->vals_ptr[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":2850
 *         for i from 0<=i<self.my_len:
 *             data[i]=self.vals_ptr[i]
 *         return (data,indices,indptr)             # <<<<<<<<<<<<<<
 * 
 * emptyvec_I=SparseVectorI([])
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_data));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_data));
  __Pyx_INCREF(((PyObject *)__pyx_v_indices));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_indices));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_indices));
  __Pyx_INCREF(((PyObject *)__pyx_v_indptr));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_indptr));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_indptr));
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2837
 *         self.vals_ptr=<int *>0
 *         self.my_len=0
 *     def to_scipy(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] data
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indices
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_12);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorI.to_scipy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_data);
  __Pyx_XDECREF((PyObject *)__pyx_v_indices);
  __Pyx_XDECREF((PyObject *)__pyx_v_indptr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2855
 * 
 * cdef class SparseVectorsI:
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *        self.vecs = []
 *     cpdef SparseVectorI to_vec(self):
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsI___init__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_14SparseVectorsI___init__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":2856
 * cdef class SparseVectorsI:
 *     def __init__(self):
 *        self.vecs = []             # <<<<<<<<<<<<<<
 *     cpdef SparseVectorI to_vec(self):
 *         cdef SparseVectorI vec
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->vecs);
  __Pyx_DECREF(__pyx_v_self->vecs);
  __pyx_v_self->vecs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2855
 * 
 * cdef class SparseVectorsI:
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *        self.vecs = []
 *     cpdef SparseVectorI to_vec(self):
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsI.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2857
 *     def __init__(self):
 *        self.vecs = []
 *     cpdef SparseVectorI to_vec(self):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorI vec
 *         cdef int weight
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_3to_vec(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_f_5lurrn_8sparsmat_14SparseVectorsI_to_vec(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_self, int __pyx_skip_dispatch) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_vec = 0;
  int __pyx_v_weight;
  size_t __pyx_v_i;
  size_t __pyx_v_j;
  struct __pyx_obj_5lurrn_8sparsmat_VecI1 *__pyx_v_result = 0;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  unsigned int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_vec", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_to_vec); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_3to_vec)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_SparseVectorI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2861
 *         cdef int weight
 *         cdef size_t i, j
 *         cdef VecI1 result = VecI1()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2862
 *         cdef size_t i, j
 *         cdef VecI1 result = VecI1()
 *         for i from 0<=i<len(self.vecs):             # <<<<<<<<<<<<<<
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 */
  __pyx_t_1 = __pyx_v_self->vecs;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2863
 *         cdef VecI1 result = VecI1()
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = self.vecs[i]
 *             for j from 0<=j<vec.my_len:
 */
    __pyx_v_weight = __pyx_v_self->weights.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":2864
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]             # <<<<<<<<<<<<<<
 *             for j from 0<=j<vec.my_len:
 *                 result.add_count(vec.idx_ptr[j], weight*vec.vals_ptr[j])
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->vecs, __pyx_v_i, size_t, 0, __Pyx_PyInt_FromSize_t, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_SparseVectorI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":2865
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 *             for j from 0<=j<vec.my_len:             # <<<<<<<<<<<<<<
 *                 result.add_count(vec.idx_ptr[j], weight*vec.vals_ptr[j])
 *         return result.to_sparse()
 */
    __pyx_t_6 = __pyx_v_vec->my_len;
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_6; __pyx_v_j++) {

      /* "lurrn/sparsmat.pyx":2866
 *             vec = self.vecs[i]
 *             for j from 0<=j<vec.my_len:
 *                 result.add_count(vec.idx_ptr[j], weight*vec.vals_ptr[j])             # <<<<<<<<<<<<<<
 *         return result.to_sparse()
 *     cpdef add(self, SparseVectorI vec, int weight=1):
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_result), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyInt_From_coordinate_t((__pyx_v_vec->idx_ptr[__pyx_v_j])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_weight * (__pyx_v_vec->vals_ptr[__pyx_v_j]))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_8 = 1;
        }
      }
      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
  }

  /* "lurrn/sparsmat.pyx":2867
 *             for j from 0<=j<vec.my_len:
 *                 result.add_count(vec.idx_ptr[j], weight*vec.vals_ptr[j])
 *         return result.to_sparse()             # <<<<<<<<<<<<<<
 *     cpdef add(self, SparseVectorI vec, int weight=1):
 *         self.vecs.append(vec)
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI1 *)__pyx_v_result->__pyx_vtab)->to_sparse(__pyx_v_result, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2857
 *     def __init__(self):
 *        self.vecs = []
 *     cpdef SparseVectorI to_vec(self):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorI vec
 *         cdef int weight
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsI.to_vec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_vec);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_3to_vec(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_3to_vec(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_vec (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_2to_vec(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_2to_vec(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_vec", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_14SparseVectorsI_to_vec(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsI.to_vec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2868
 *                 result.add_count(vec.idx_ptr[j], weight*vec.vals_ptr[j])
 *         return result.to_sparse()
 *     cpdef add(self, SparseVectorI vec, int weight=1):             # <<<<<<<<<<<<<<
 *         self.vecs.append(vec)
 *         self.weights.push_back(weight)
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_5add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5lurrn_8sparsmat_14SparseVectorsI_add(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_vec, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsI_add *__pyx_optional_args) {
  int __pyx_v_weight = ((int)1);
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_weight = __pyx_optional_args->weight;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_add); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_5add)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_weight); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_vec));
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_vec));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_vec));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2869
 *         return result.to_sparse()
 *     cpdef add(self, SparseVectorI vec, int weight=1):
 *         self.vecs.append(vec)             # <<<<<<<<<<<<<<
 *         self.weights.push_back(weight)
 *     def __mul__(self, factor):
 */
  __pyx_t_8 = __Pyx_PyObject_Append(__pyx_v_self->vecs, ((PyObject *)__pyx_v_vec)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lurrn/sparsmat.pyx":2870
 *     cpdef add(self, SparseVectorI vec, int weight=1):
 *         self.vecs.append(vec)
 *         self.weights.push_back(weight)             # <<<<<<<<<<<<<<
 *     def __mul__(self, factor):
 *         cdef SparseVectorI vec
 */
  __pyx_v_self->weights.push_back(__pyx_v_weight);

  /* "lurrn/sparsmat.pyx":2868
 *                 result.add_count(vec.idx_ptr[j], weight*vec.vals_ptr[j])
 *         return result.to_sparse()
 *     cpdef add(self, SparseVectorI vec, int weight=1):             # <<<<<<<<<<<<<<
 *         self.vecs.append(vec)
 *         self.weights.push_back(weight)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsI.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_5add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_5add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_vec = 0;
  int __pyx_v_weight;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_vec,&__pyx_n_s_weight,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weight);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_vec = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)values[0]);
    if (values[1]) {
      __pyx_v_weight = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_weight == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_weight = ((int)1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsI.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vec), __pyx_ptype_5lurrn_8sparsmat_SparseVectorI, 1, "vec", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_4add(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *)__pyx_v_self), __pyx_v_vec, __pyx_v_weight);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_4add(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_vec, int __pyx_v_weight) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsI_add __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.weight = __pyx_v_weight;
  __pyx_t_1 = __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorsI->add(__pyx_v_self, __pyx_v_vec, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsI.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2871
 *         self.vecs.append(vec)
 *         self.weights.push_back(weight)
 *     def __mul__(self, factor):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorI vec
 *         cdef int weight
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_7__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_factor); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_7__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_factor) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__mul__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_6__mul__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_factor));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_6__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_factor) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_vec = 0;
  int __pyx_v_weight;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_result = 0;
  long __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsI_add __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__mul__", 0);

  /* "lurrn/sparsmat.pyx":2874
 *         cdef SparseVectorI vec
 *         cdef int weight
 *         cdef SparseVectorsI result = SparseVectorsI             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 */
  if (!(likely(((((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsI))) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsI)), __pyx_ptype_5lurrn_8sparsmat_SparseVectorsI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsI));
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2875
 *         cdef int weight
 *         cdef SparseVectorsI result = SparseVectorsI
 *         for i from 0<=i<len(self.vecs):             # <<<<<<<<<<<<<<
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_vecs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2876
 *         cdef SparseVectorsI result = SparseVectorsI
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = self.vecs[i]
 *             result.add(vec, weight*factor)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_weights); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_at); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_weight = __pyx_t_7;

    /* "lurrn/sparsmat.pyx":2877
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]             # <<<<<<<<<<<<<<
 *             result.add(vec, weight*factor)
 *     def __add__(self, others):
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_vecs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_i, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2877; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5lurrn_8sparsmat_SparseVectorI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":2878
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 *             result.add(vec, weight*factor)             # <<<<<<<<<<<<<<
 *     def __add__(self, others):
 *         cdef SparseVectorI vec
 */
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_weight); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyNumber_Multiply(__pyx_t_4, __pyx_v_factor); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_8.__pyx_n = 1;
    __pyx_t_8.weight = __pyx_t_7;
    __pyx_t_1 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsI *)__pyx_v_result->__pyx_vtab)->add(__pyx_v_result, __pyx_v_vec, 0, &__pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2871
 *         self.vecs.append(vec)
 *         self.weights.push_back(weight)
 *     def __mul__(self, factor):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorI vec
 *         cdef int weight
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsI.__mul__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_vec);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2879
 *             vec = self.vecs[i]
 *             result.add(vec, weight*factor)
 *     def __add__(self, others):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorI vec
 *         cdef int weight
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_9__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_others); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_9__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_others) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_8__add__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_others));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_8__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_others) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_vec = 0;
  int __pyx_v_weight;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_oth_vecs = 0;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_result = 0;
  long __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsI_add __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":2882
 *         cdef SparseVectorI vec
 *         cdef int weight
 *         cdef SparseVectorsI oth_vecs = others             # <<<<<<<<<<<<<<
 *         cdef SparseVectorsI result = SparseVectorsI
 *         for i from 0<=i<len(self.vecs):
 */
  if (!(likely(((__pyx_v_others) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_others, __pyx_ptype_5lurrn_8sparsmat_SparseVectorsI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_others;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_oth_vecs = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2883
 *         cdef int weight
 *         cdef SparseVectorsI oth_vecs = others
 *         cdef SparseVectorsI result = SparseVectorsI             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 */
  if (!(likely(((((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsI))) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsI)), __pyx_ptype_5lurrn_8sparsmat_SparseVectorsI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsI));
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2884
 *         cdef SparseVectorsI oth_vecs = others
 *         cdef SparseVectorsI result = SparseVectorsI
 *         for i from 0<=i<len(self.vecs):             # <<<<<<<<<<<<<<
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_vecs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2885
 *         cdef SparseVectorsI result = SparseVectorsI
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = self.vecs[i]
 *             result.add(vec, weight)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_weights); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_at); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_weight = __pyx_t_7;

    /* "lurrn/sparsmat.pyx":2886
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]             # <<<<<<<<<<<<<<
 *             result.add(vec, weight)
 *         for i from 0<=i<len(oth_vecs.vecs):
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_vecs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_i, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2886; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5lurrn_8sparsmat_SparseVectorI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":2887
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 *             result.add(vec, weight)             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(oth_vecs.vecs):
 *             weight = oth_vecs.weights.at(i)
 */
    __pyx_t_8.__pyx_n = 1;
    __pyx_t_8.weight = __pyx_v_weight;
    __pyx_t_4 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsI *)__pyx_v_result->__pyx_vtab)->add(__pyx_v_result, __pyx_v_vec, 0, &__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }

  /* "lurrn/sparsmat.pyx":2888
 *             vec = self.vecs[i]
 *             result.add(vec, weight)
 *         for i from 0<=i<len(oth_vecs.vecs):             # <<<<<<<<<<<<<<
 *             weight = oth_vecs.weights.at(i)
 *             vec = oth_vecs.vecs[i]
 */
  __pyx_t_4 = __pyx_v_oth_vecs->vecs;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_2 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2889
 *             result.add(vec, weight)
 *         for i from 0<=i<len(oth_vecs.vecs):
 *             weight = oth_vecs.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = oth_vecs.vecs[i]
 *             result.add(vec, weight)
 */
    __pyx_v_weight = __pyx_v_oth_vecs->weights.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":2890
 *         for i from 0<=i<len(oth_vecs.vecs):
 *             weight = oth_vecs.weights.at(i)
 *             vec = oth_vecs.vecs[i]             # <<<<<<<<<<<<<<
 *             result.add(vec, weight)
 *         return result
 */
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_oth_vecs->vecs, __pyx_v_i, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2890; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5lurrn_8sparsmat_SparseVectorI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":2891
 *             weight = oth_vecs.weights.at(i)
 *             vec = oth_vecs.vecs[i]
 *             result.add(vec, weight)             # <<<<<<<<<<<<<<
 *         return result
 *     def __sub__(SparseVectorsI self, SparseVectorsI others):
 */
    __pyx_t_8.__pyx_n = 1;
    __pyx_t_8.weight = __pyx_v_weight;
    __pyx_t_4 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsI *)__pyx_v_result->__pyx_vtab)->add(__pyx_v_result, __pyx_v_vec, 0, &__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }

  /* "lurrn/sparsmat.pyx":2892
 *             vec = oth_vecs.vecs[i]
 *             result.add(vec, weight)
 *         return result             # <<<<<<<<<<<<<<
 *     def __sub__(SparseVectorsI self, SparseVectorsI others):
 *         cdef SparseVectorI vec
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2879
 *             vec = self.vecs[i]
 *             result.add(vec, weight*factor)
 *     def __add__(self, others):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorI vec
 *         cdef int weight
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsI.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_vec);
  __Pyx_XDECREF((PyObject *)__pyx_v_oth_vecs);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2893
 *             result.add(vec, weight)
 *         return result
 *     def __sub__(SparseVectorsI self, SparseVectorsI others):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorI vec
 *         cdef int weight
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_11__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_others); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_11__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_others) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__sub__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_SparseVectorsI, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_others), __pyx_ptype_5lurrn_8sparsmat_SparseVectorsI, 1, "others", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_10__sub__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *)__pyx_v_others));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_10__sub__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_others) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_vec = 0;
  int __pyx_v_weight;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_oth_vecs = 0;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_result = 0;
  long __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsI_add __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__sub__", 0);

  /* "lurrn/sparsmat.pyx":2896
 *         cdef SparseVectorI vec
 *         cdef int weight
 *         cdef SparseVectorsI oth_vecs = others             # <<<<<<<<<<<<<<
 *         cdef SparseVectorsI result = SparseVectorsI()
 *         for i from 0<=i<len(self.vecs):
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_others));
  __pyx_v_oth_vecs = __pyx_v_others;

  /* "lurrn/sparsmat.pyx":2897
 *         cdef int weight
 *         cdef SparseVectorsI oth_vecs = others
 *         cdef SparseVectorsI result = SparseVectorsI()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsI)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2898
 *         cdef SparseVectorsI oth_vecs = others
 *         cdef SparseVectorsI result = SparseVectorsI()
 *         for i from 0<=i<len(self.vecs):             # <<<<<<<<<<<<<<
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 */
  __pyx_t_1 = __pyx_v_self->vecs;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2898; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2899
 *         cdef SparseVectorsI result = SparseVectorsI()
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = self.vecs[i]
 *             result.add(vec, weight)
 */
    __pyx_v_weight = __pyx_v_self->weights.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":2900
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]             # <<<<<<<<<<<<<<
 *             result.add(vec, weight)
 *         for i from 0<=i<len(oth_vecs.vecs):
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->vecs, __pyx_v_i, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2900; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_SparseVectorI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":2901
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 *             result.add(vec, weight)             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(oth_vecs.vecs):
 *             weight = oth_vecs.weights.at(i)
 */
    __pyx_t_3.__pyx_n = 1;
    __pyx_t_3.weight = __pyx_v_weight;
    __pyx_t_1 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsI *)__pyx_v_result->__pyx_vtab)->add(__pyx_v_result, __pyx_v_vec, 0, &__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2902
 *             vec = self.vecs[i]
 *             result.add(vec, weight)
 *         for i from 0<=i<len(oth_vecs.vecs):             # <<<<<<<<<<<<<<
 *             weight = oth_vecs.weights.at(i)
 *             vec = oth_vecs.vecs[i]
 */
  __pyx_t_1 = __pyx_v_oth_vecs->vecs;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2903
 *             result.add(vec, weight)
 *         for i from 0<=i<len(oth_vecs.vecs):
 *             weight = oth_vecs.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = oth_vecs.vecs[i]
 *             result.add(vec, -weight)
 */
    __pyx_v_weight = __pyx_v_oth_vecs->weights.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":2904
 *         for i from 0<=i<len(oth_vecs.vecs):
 *             weight = oth_vecs.weights.at(i)
 *             vec = oth_vecs.vecs[i]             # <<<<<<<<<<<<<<
 *             result.add(vec, -weight)
 *         return result
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_oth_vecs->vecs, __pyx_v_i, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2904; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_SparseVectorI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":2905
 *             weight = oth_vecs.weights.at(i)
 *             vec = oth_vecs.vecs[i]
 *             result.add(vec, -weight)             # <<<<<<<<<<<<<<
 *         return result
 *     cdef int _dotFull(self, const_int_ptr full_ptr):
 */
    __pyx_t_3.__pyx_n = 1;
    __pyx_t_3.weight = (-__pyx_v_weight);
    __pyx_t_1 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsI *)__pyx_v_result->__pyx_vtab)->add(__pyx_v_result, __pyx_v_vec, 0, &__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2906
 *             vec = oth_vecs.vecs[i]
 *             result.add(vec, -weight)
 *         return result             # <<<<<<<<<<<<<<
 *     cdef int _dotFull(self, const_int_ptr full_ptr):
 *         cdef size_t i, j
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2893
 *             result.add(vec, weight)
 *         return result
 *     def __sub__(SparseVectorsI self, SparseVectorsI others):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorI vec
 *         cdef int weight
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsI.__sub__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_vec);
  __Pyx_XDECREF((PyObject *)__pyx_v_oth_vecs);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2907
 *             result.add(vec, -weight)
 *         return result
 *     cdef int _dotFull(self, const_int_ptr full_ptr):             # <<<<<<<<<<<<<<
 *         cdef size_t i, j
 *         cdef int weight
 */

static int __pyx_f_5lurrn_8sparsmat_14SparseVectorsI__dotFull(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_self, const int * __pyx_v_full_ptr) {
  size_t __pyx_v_i;
  size_t __pyx_v_j;
  int __pyx_v_weight;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *__pyx_v_vec = 0;
  int __pyx_v_result;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  unsigned int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_dotFull", 0);

  /* "lurrn/sparsmat.pyx":2911
 *         cdef int weight
 *         cdef SparseVectorI vec
 *         cdef int result=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 */
  __pyx_v_result = 0;

  /* "lurrn/sparsmat.pyx":2912
 *         cdef SparseVectorI vec
 *         cdef int result=0
 *         for i from 0<=i<len(self.vecs):             # <<<<<<<<<<<<<<
 *             weight = self.weights.at(i)
 *             vec = self.vecs.at(i)
 */
  __pyx_t_1 = __pyx_v_self->vecs;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":2913
 *         cdef int result=0
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = self.vecs.at(i)
 *             for j from 0<=j<vec.my_len:
 */
    __pyx_v_weight = __pyx_v_self->weights.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":2914
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 *             vec = self.vecs.at(i)             # <<<<<<<<<<<<<<
 *             for j from 0<=j<vec.my_len:
 *                 result += full_ptr[vec.indices[j]]*weight*vec.vals_ptr[j]
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->vecs, __pyx_n_s_at); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_SparseVectorI))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":2915
 *             weight = self.weights.at(i)
 *             vec = self.vecs.at(i)
 *             for j from 0<=j<vec.my_len:             # <<<<<<<<<<<<<<
 *                 result += full_ptr[vec.indices[j]]*weight*vec.vals_ptr[j]
 *         return result
 */
    __pyx_t_7 = __pyx_v_vec->my_len;
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_7; __pyx_v_j++) {

      /* "lurrn/sparsmat.pyx":2916
 *             vec = self.vecs.at(i)
 *             for j from 0<=j<vec.my_len:
 *                 result += full_ptr[vec.indices[j]]*weight*vec.vals_ptr[j]             # <<<<<<<<<<<<<<
 *         return result
 *     def __len__(self):
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_vec), __pyx_n_s_indices); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_j, size_t, 0, __Pyx_PyInt_FromSize_t, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2916; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_result = (__pyx_v_result + (((__pyx_v_full_ptr[__pyx_t_8]) * __pyx_v_weight) * (__pyx_v_vec->vals_ptr[__pyx_v_j])));
    }
  }

  /* "lurrn/sparsmat.pyx":2917
 *             for j from 0<=j<vec.my_len:
 *                 result += full_ptr[vec.indices[j]]*weight*vec.vals_ptr[j]
 *         return result             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return len(self.vecs)
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2907
 *             result.add(vec, -weight)
 *         return result
 *     cdef int _dotFull(self, const_int_ptr full_ptr):             # <<<<<<<<<<<<<<
 *         cdef size_t i, j
 *         cdef int weight
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorsI._dotFull", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_vec);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2918
 *                 result += full_ptr[vec.indices[j]]*weight*vec.vals_ptr[j]
 *         return result
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return len(self.vecs)
 *     def __getitem__(self, k):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_13__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_13__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_12__len__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_12__len__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":2919
 *         return result
 *     def __len__(self):
 *         return len(self.vecs)             # <<<<<<<<<<<<<<
 *     def __getitem__(self, k):
 *         vec = self.vecs[k]
 */
  __pyx_t_1 = __pyx_v_self->vecs;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2918
 *                 result += full_ptr[vec.indices[j]]*weight*vec.vals_ptr[j]
 *         return result
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return len(self.vecs)
 *     def __getitem__(self, k):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsI.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2920
 *     def __len__(self):
 *         return len(self.vecs)
 *     def __getitem__(self, k):             # <<<<<<<<<<<<<<
 *         vec = self.vecs[k]
 *         return (self.weights.at(k), vec)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_15__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_k); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_15__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_14__getitem__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *)__pyx_v_self), ((PyObject *)__pyx_v_k));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsI_14__getitem__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_v_vec = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "lurrn/sparsmat.pyx":2921
 *         return len(self.vecs)
 *     def __getitem__(self, k):
 *         vec = self.vecs[k]             # <<<<<<<<<<<<<<
 *         return (self.weights.at(k), vec)
 * ## F -> float
 */
  __pyx_t_1 = PyObject_GetItem(__pyx_v_self->vecs, __pyx_v_k); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2921; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_vec = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2922
 *     def __getitem__(self, k):
 *         vec = self.vecs[k]
 *         return (self.weights.at(k), vec)             # <<<<<<<<<<<<<<
 * ## F -> float
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_v_k); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->weights.at(__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_vec);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_vec);
  __Pyx_GIVEREF(__pyx_v_vec);
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2920
 *     def __len__(self):
 *         return len(self.vecs)
 *     def __getitem__(self, k):             # <<<<<<<<<<<<<<
 *         vec = self.vecs[k]
 *         return (self.weights.at(k), vec)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsI.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_vec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2930
 * cdef class VecF1:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_5VecF1_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_5VecF1_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1___init__(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_5VecF1___init__(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":2931
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     def item_iter(self):
 *         self.ensure_compact()
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":2930
 * cdef class VecF1:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2932
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecF1_iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("item_iter (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1_2item_iter(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("item_iter", 0);

  /* "lurrn/sparsmat.pyx":2933
 *         self.is_compact=True
 *     def item_iter(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return IVecF1_iter(self)
 *     def get_size(self,compactify=True):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":2934
 *     def item_iter(self):
 *         self.ensure_compact()
 *         return IVecF1_iter(self)             # <<<<<<<<<<<<<<
 *     def get_size(self,compactify=True):
 *         if compactify:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_IVecF1_iter)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2932
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecF1_iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.item_iter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2935
 *         self.ensure_compact()
 *         return IVecF1_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2935; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2935; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1_4get_size(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":2936
 *         return IVecF1_iter(self)
 *     def get_size(self,compactify=True):
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *         return self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":2937
 *     def get_size(self,compactify=True):
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return self.vec.size()
 *     def __len__(self):
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":2938
 *         if compactify:
 *             self.ensure_compact()
 *         return self.vec.size()             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return self.get_size(True)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_self->vec.size()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2935
 *         self.ensure_compact()
 *         return IVecF1_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2939
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecF1_7__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecF1_7__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1_6__len__(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecF1_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":2940
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2939
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2941
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1_8clear(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear", 0);

  /* "lurrn/sparsmat.pyx":2942
 *         return self.get_size(True)
 *     def clear(self):
 *         self.vec.resize(0)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void compactify(self):
 */
  __pyx_v_self->vec.resize(0);

  /* "lurrn/sparsmat.pyx":2943
 *     def clear(self):
 *         self.vec.resize(0)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrF1 comp
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":2941
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2944
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrF1 comp
 *         c_IVecF1_sort(self.vec.begin(),self.vec.end(),comp)
 */

static void __pyx_f_5lurrn_8sparsmat_5VecF1_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self) {
  struct smallerAddr<1,float> __pyx_v_comp;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compactify", 0);

  /* "lurrn/sparsmat.pyx":2946
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrF1 comp
 *         c_IVecF1_sort(self.vec.begin(),self.vec.end(),comp)             # <<<<<<<<<<<<<<
 *         c_compactifyF1(&self.vec)
 *         self.is_compact=True
 */
  sort(__pyx_v_self->vec.begin(), __pyx_v_self->vec.end(), __pyx_v_comp);

  /* "lurrn/sparsmat.pyx":2947
 *         cdef c_SmallerAddrF1 comp
 *         c_IVecF1_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyF1(&self.vec)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 */
  compactify((&__pyx_v_self->vec));

  /* "lurrn/sparsmat.pyx":2948
 *         c_IVecF1_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyF1(&self.vec)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":2944
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrF1 comp
 *         c_IVecF1_sort(self.vec.begin(),self.vec.end(),comp)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":2949
 *         c_compactifyF1(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

static void __pyx_f_5lurrn_8sparsmat_5VecF1_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":2950
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:             # <<<<<<<<<<<<<<
 *             self.compactify()
 *     cpdef float get_count(self,coordinate_t k0):
 */
  __pyx_t_1 = ((!(__pyx_v_self->is_compact != 0)) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":2951
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 *             self.compactify()             # <<<<<<<<<<<<<<
 *     cpdef float get_count(self,coordinate_t k0):
 *         cdef c_CItemF1 ci
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF1 *)__pyx_v_self->__pyx_vtab)->compactify(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":2949
 *         c_compactifyF1(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":2952
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef float get_count(self,coordinate_t k0):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF1 ci
 *         ci.addr[0]=k0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_arg_k0); /*proto*/
static float __pyx_f_5lurrn_8sparsmat_5VecF1_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, coordinate_t __pyx_v_k0, int __pyx_skip_dispatch) {
  struct CountItem<1,float> __pyx_v_ci;
  float __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  float __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_11get_count)) {
      __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_7 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":2954
 *     cpdef float get_count(self,coordinate_t k0):
 *         cdef c_CItemF1 ci
 *         ci.addr[0]=k0             # <<<<<<<<<<<<<<
 *         return c_get_countF1(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0, float item):
 */
  (__pyx_v_ci.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":2955
 *         cdef c_CItemF1 ci
 *         ci.addr[0]=k0
 *         return c_get_countF1(&self.vec,ci)             # <<<<<<<<<<<<<<
 *     cdef void c_add(self, coordinate_t k0, float item):
 *         cdef c_CItemF1 c
 */
  __pyx_r = get_count_v((&__pyx_v_self->vec), __pyx_v_ci);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2952
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef float get_count(self,coordinate_t k0):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF1 ci
 *         ci.addr[0]=k0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecF1.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_arg_k0); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_arg_k0) {
  coordinate_t __pyx_v_k0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_count (wrapper)", 0);
  assert(__pyx_arg_k0); {
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(__pyx_arg_k0); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2952; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1_10get_count(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self), ((coordinate_t)__pyx_v_k0));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, coordinate_t __pyx_v_k0) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_5VecF1_get_count(__pyx_v_self, __pyx_v_k0, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2956
 *         ci.addr[0]=k0
 *         return c_get_countF1(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0, float item):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF1 c
 *         c.addr[0]=k0
 */

static void __pyx_f_5lurrn_8sparsmat_5VecF1_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, coordinate_t __pyx_v_k0, float __pyx_v_item) {
  struct CountItem<1,float> __pyx_v_c;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_add", 0);

  /* "lurrn/sparsmat.pyx":2958
 *     cdef void c_add(self, coordinate_t k0, float item):
 *         cdef c_CItemF1 c
 *         c.addr[0]=k0             # <<<<<<<<<<<<<<
 *         c.item=item
 *         self.vec.push_back(c)
 */
  (__pyx_v_c.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":2959
 *         cdef c_CItemF1 c
 *         c.addr[0]=k0
 *         c.item=item             # <<<<<<<<<<<<<<
 *         self.vec.push_back(c)
 *         self.is_compact=False
 */
  __pyx_v_c.item = __pyx_v_item;

  /* "lurrn/sparsmat.pyx":2960
 *         c.addr[0]=k0
 *         c.item=item
 *         self.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0, item=1):
 */
  __pyx_v_self->vec.push_back(__pyx_v_c);

  /* "lurrn/sparsmat.pyx":2961
 *         c.item=item
 *         self.vec.push_back(c)
 *         self.is_compact=False             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.c_add(k0, item)
 */
  __pyx_v_self->is_compact = 0;

  /* "lurrn/sparsmat.pyx":2956
 *         ci.addr[0]=k0
 *         return c_get_countF1(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0, float item):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF1 c
 *         c.addr[0]=k0
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":2962
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0, item=1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0, item)
 *     def __add__(VecF1 self, VecF1 other):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  PyObject *__pyx_v_item = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_item,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_item);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2962; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2962; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_item = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2962; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1_12add_count(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self), __pyx_v_k0, __pyx_v_item);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, coordinate_t __pyx_v_k0, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  float __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":2963
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.c_add(k0, item)             # <<<<<<<<<<<<<<
 *     def __add__(VecF1 self, VecF1 other):
 *         cdef c_CItemF1 c1, c2
 */
  __pyx_t_1 = __pyx_PyFloat_AsFloat(__pyx_v_item); if (unlikely((__pyx_t_1 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2963; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF1 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_v_k0, __pyx_t_1);

  /* "lurrn/sparsmat.pyx":2962
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0, item=1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0, item)
 *     def __add__(VecF1 self, VecF1 other):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":2964
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.c_add(k0, item)
 *     def __add__(VecF1 self, VecF1 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF1 c1, c2
 *         cdef unsigned int i1, i2
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_VecF1, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_VecF1, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1_14__add__(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_other) {
  struct CountItem<1,float> __pyx_v_c1;
  struct CountItem<1,float> __pyx_v_c2;
  unsigned int __pyx_v_i1;
  unsigned int __pyx_v_i2;
  int __pyx_v_k;
  int __pyx_v_delta;
  struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":2969
 *         cdef int k, delta
 *         cdef VecF1 result
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         other.ensure_compact()
 *         result=VecF1()
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":2970
 *         cdef VecF1 result
 *         self.ensure_compact()
 *         other.ensure_compact()             # <<<<<<<<<<<<<<
 *         result=VecF1()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF1 *)__pyx_v_other->__pyx_vtab)->ensure_compact(__pyx_v_other);

  /* "lurrn/sparsmat.pyx":2971
 *         self.ensure_compact()
 *         other.ensure_compact()
 *         result=VecF1()             # <<<<<<<<<<<<<<
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2972
 *         other.ensure_compact()
 *         result=VecF1()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))             # <<<<<<<<<<<<<<
 *         i1=0
 *         i2=0
 */
  __pyx_t_2 = __pyx_v_other->vec.size();
  __pyx_t_3 = __pyx_v_self->vec.size();
  if (((__pyx_t_2 > __pyx_t_3) != 0)) {
    __pyx_t_4 = __pyx_t_2;
  } else {
    __pyx_t_4 = __pyx_t_3;
  }
  __pyx_v_result->vec.reserve(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":2973
 *         result=VecF1()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0             # <<<<<<<<<<<<<<
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 */
  __pyx_v_i1 = 0;

  /* "lurrn/sparsmat.pyx":2974
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 *         i2=0             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 */
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":2975
 *         i1=0
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 */
  while (1) {
    __pyx_t_6 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_6 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":2976
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             delta=0
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":2977
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             delta=0
 *             for k from 0<=k<1:
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":2978
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 *             delta=0             # <<<<<<<<<<<<<<
 *             for k from 0<=k<1:
 *                 if c1.addr[k]<c2.addr[k]:
 */
    __pyx_v_delta = 0;

    /* "lurrn/sparsmat.pyx":2979
 *             c2=other.vec.at(i2)
 *             delta=0
 *             for k from 0<=k<1:             # <<<<<<<<<<<<<<
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 */
    for (__pyx_v_k = 0; __pyx_v_k < 1; __pyx_v_k++) {

      /* "lurrn/sparsmat.pyx":2980
 *             delta=0
 *             for k from 0<=k<1:
 *                 if c1.addr[k]<c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=-1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) < (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":2981
 *             for k from 0<=k<1:
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1             # <<<<<<<<<<<<<<
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 */
        __pyx_v_delta = -1;

        /* "lurrn/sparsmat.pyx":2982
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 *                     break             # <<<<<<<<<<<<<<
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 */
        goto __pyx_L8_break;
      }

      /* "lurrn/sparsmat.pyx":2983
 *                     delta=-1
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) > (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":2984
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1             # <<<<<<<<<<<<<<
 *                     break
 *             if delta==0:
 */
        __pyx_v_delta = 1;

        /* "lurrn/sparsmat.pyx":2985
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 *                     break             # <<<<<<<<<<<<<<
 *             if delta==0:
 *                 c1.item+=c2.item
 */
        goto __pyx_L8_break;
      }
    }
    __pyx_L8_break:;

    /* "lurrn/sparsmat.pyx":2991
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
    switch (__pyx_v_delta) {

      /* "lurrn/sparsmat.pyx":2986
 *                     delta=1
 *                     break
 *             if delta==0:             # <<<<<<<<<<<<<<
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)
 */
      case 0:

      /* "lurrn/sparsmat.pyx":2987
 *                     break
 *             if delta==0:
 *                 c1.item+=c2.item             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      __pyx_v_c1.item = (__pyx_v_c1.item + __pyx_v_c2.item);

      /* "lurrn/sparsmat.pyx":2988
 *             if delta==0:
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *                 i2+=1
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":2989
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *                 i2+=1
 *             elif delta==-1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);

      /* "lurrn/sparsmat.pyx":2990
 *                 result.vec.push_back(c1)
 *                 i1+=1
 *                 i2+=1             # <<<<<<<<<<<<<<
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;

      /* "lurrn/sparsmat.pyx":2991
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      case -1:

      /* "lurrn/sparsmat.pyx":2992
 *                 i2+=1
 *             elif delta==-1:
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             else:
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":2993
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             else:
 *                 result.vec.push_back(c2)
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      break;
      default:

      /* "lurrn/sparsmat.pyx":2995
 *                 i1+=1
 *             else:
 *                 result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *                 i2+=1
 *         while i1<self.vec.size():
 */
      __pyx_v_result->vec.push_back(__pyx_v_c2);

      /* "lurrn/sparsmat.pyx":2996
 *             else:
 *                 result.vec.push_back(c2)
 *                 i2+=1             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;
    }
  }

  /* "lurrn/sparsmat.pyx":2997
 *                 result.vec.push_back(c2)
 *                 i2+=1
 *         while i1<self.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":2998
 *                 i2+=1
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c1)
 *             i1+=1
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":2999
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *             i1+=1
 *         while i2<other.vec.size():
 */
    __pyx_v_result->vec.push_back(__pyx_v_c1);

    /* "lurrn/sparsmat.pyx":3000
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 *             i1+=1             # <<<<<<<<<<<<<<
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);
  }

  /* "lurrn/sparsmat.pyx":3001
 *             result.vec.push_back(c1)
 *             i1+=1
 *         while i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":3002
 *             i1+=1
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c2)
 *             i2+=1
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":3003
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *             i2+=1
 *         return result
 */
    __pyx_v_result->vec.push_back(__pyx_v_c2);

    /* "lurrn/sparsmat.pyx":3004
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 *             i2+=1             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_v_i2 = (__pyx_v_i2 + 1);
  }

  /* "lurrn/sparsmat.pyx":3005
 *             result.vec.push_back(c2)
 *             i2+=1
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     cpdef SparseVectorF to_sparse(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":2964
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.c_add(k0, item)
 *     def __add__(VecF1 self, VecF1 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF1 c1, c2
 *         cdef unsigned int i1, i2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3007
 *         return result
 * 
 *     cpdef SparseVectorF to_sparse(self):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF1 c
 *         cdef SparseVectorF result
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_17to_sparse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_f_5lurrn_8sparsmat_5VecF1_to_sparse(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, int __pyx_skip_dispatch) {
  struct CountItem<1,float> __pyx_v_c;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_result = 0;
  coordinate_t __pyx_v_n;
  coordinate_t __pyx_v_i;
  coordinate_t *__pyx_v_idx_ptr;
  float *__pyx_v_vals_ptr;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  coordinate_t __pyx_t_5;
  float __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_sparse", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_to_sparse); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_17to_sparse)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_SparseVectorF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3013
 *         cdef coordinate_t *idx_ptr
 *         cdef float *vals_ptr
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         idx_ptr=<coordinate_t *>PyMem_Malloc(n*sizeof(coordinate_t))
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":3014
 *         cdef float *vals_ptr
 *         self.ensure_compact()
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         idx_ptr=<coordinate_t *>PyMem_Malloc(n*sizeof(coordinate_t))
 *         vals_ptr=<float *>PyMem_Malloc(n*sizeof(float))
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":3015
 *         self.ensure_compact()
 *         n=self.vec.size()
 *         idx_ptr=<coordinate_t *>PyMem_Malloc(n*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         vals_ptr=<float *>PyMem_Malloc(n*sizeof(float))
 *         for i from 0<=i<n:
 */
  __pyx_v_idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_n * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":3016
 *         n=self.vec.size()
 *         idx_ptr=<coordinate_t *>PyMem_Malloc(n*sizeof(coordinate_t))
 *         vals_ptr=<float *>PyMem_Malloc(n*sizeof(float))             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *           c=self.vec.at(i)
 */
  __pyx_v_vals_ptr = ((float *)PyMem_Malloc((__pyx_v_n * (sizeof(float)))));

  /* "lurrn/sparsmat.pyx":3017
 *         idx_ptr=<coordinate_t *>PyMem_Malloc(n*sizeof(coordinate_t))
 *         vals_ptr=<float *>PyMem_Malloc(n*sizeof(float))
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *           c=self.vec.at(i)
 *           idx_ptr[i]=c.addr[0]
 */
  __pyx_t_5 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3018
 *         vals_ptr=<float *>PyMem_Malloc(n*sizeof(float))
 *         for i from 0<=i<n:
 *           c=self.vec.at(i)             # <<<<<<<<<<<<<<
 *           idx_ptr[i]=c.addr[0]
 *           vals_ptr[i]=c.item
 */
    __pyx_v_c = __pyx_v_self->vec.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":3019
 *         for i from 0<=i<n:
 *           c=self.vec.at(i)
 *           idx_ptr[i]=c.addr[0]             # <<<<<<<<<<<<<<
 *           vals_ptr[i]=c.item
 *         result=SparseVectorF(None)
 */
    (__pyx_v_idx_ptr[__pyx_v_i]) = (__pyx_v_c.addr[0]);

    /* "lurrn/sparsmat.pyx":3020
 *           c=self.vec.at(i)
 *           idx_ptr[i]=c.addr[0]
 *           vals_ptr[i]=c.item             # <<<<<<<<<<<<<<
 *         result=SparseVectorF(None)
 *         result.idx_ptr=idx_ptr
 */
    __pyx_t_6 = __pyx_v_c.item;
    (__pyx_v_vals_ptr[__pyx_v_i]) = __pyx_t_6;
  }

  /* "lurrn/sparsmat.pyx":3021
 *           idx_ptr[i]=c.addr[0]
 *           vals_ptr[i]=c.item
 *         result=SparseVectorF(None)             # <<<<<<<<<<<<<<
 *         result.idx_ptr=idx_ptr
 *         result.vals_ptr=vals_ptr
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorF)), __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3022
 *           vals_ptr[i]=c.item
 *         result=SparseVectorF(None)
 *         result.idx_ptr=idx_ptr             # <<<<<<<<<<<<<<
 *         result.vals_ptr=vals_ptr
 *         result.my_len=n
 */
  __pyx_v_result->idx_ptr = __pyx_v_idx_ptr;

  /* "lurrn/sparsmat.pyx":3023
 *         result=SparseVectorF(None)
 *         result.idx_ptr=idx_ptr
 *         result.vals_ptr=vals_ptr             # <<<<<<<<<<<<<<
 *         result.my_len=n
 *         return result
 */
  __pyx_v_result->vals_ptr = __pyx_v_vals_ptr;

  /* "lurrn/sparsmat.pyx":3024
 *         result.idx_ptr=idx_ptr
 *         result.vals_ptr=vals_ptr
 *         result.my_len=n             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
  __pyx_v_result->my_len = __pyx_v_n;

  /* "lurrn/sparsmat.pyx":3025
 *         result.vals_ptr=vals_ptr
 *         result.my_len=n
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def tofile(self, f):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3007
 *         return result
 * 
 *     cpdef SparseVectorF to_sparse(self):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF1 c
 *         cdef SparseVectorF result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.to_sparse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_17to_sparse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_17to_sparse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_sparse (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1_16to_sparse(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_16to_sparse(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_sparse", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_5VecF1_to_sparse(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.to_sparse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3027
 *         return result
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_19tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_19tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tofile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1_18tofile(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_18tofile(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  long __pyx_v_k;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  long __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("tofile", 0);

  /* "lurrn/sparsmat.pyx":3029
 *     def tofile(self, f):
 *         cdef long i, n, k, k_max
 *         n=self.get_size()             # <<<<<<<<<<<<<<
 *         f.write('F1 %d\n'%(n,))
 *         k=0
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":3030
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 *         f.write('F1 %d\n'%(n,))             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_F1_d, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3031
 *         n=self.get_size()
 *         f.write('F1 %d\n'%(n,))
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecF1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemF1))
 */
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":3032
 *         f.write('F1 %d\n'%(n,))
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecF1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemF1))
 *             f.write(s)
 */
  __pyx_t_4 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3033
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecF1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemF1))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *             k+=CHUNK_SIZE
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), (256 * (sizeof(struct CountItem<1,float>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":3034
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecF1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemF1))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":3035
 *             s=PyString_FromStringAndSize(<char *>c_VecF1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemF1))
 *             f.write(s)
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecF1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemF1))
 */
    __pyx_v_k = (__pyx_v_k + 256);
  }

  /* "lurrn/sparsmat.pyx":3036
 *             f.write(s)
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecF1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemF1))
 *             f.write(s)
 */
  __pyx_t_7 = ((__pyx_v_k < __pyx_v_n) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":3037
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecF1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemF1))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *     def fromfile(self, f):
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), ((__pyx_v_n - __pyx_v_k) * (sizeof(struct CountItem<1,float>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3037; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":3038
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecF1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemF1))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *     def fromfile(self, f):
 *         cdef long i, n
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":3027
 *         return result
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.tofile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3039
 *             s=PyString_FromStringAndSize(<char *>c_VecF1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemF1))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_21fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_21fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fromfile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1_20fromfile(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_20fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  PyObject *__pyx_v_line = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  long __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  size_t __pyx_t_9;
  char *__pyx_t_10;
  size_t __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromfile", 0);

  /* "lurrn/sparsmat.pyx":3041
 *     def fromfile(self, f):
 *         cdef long i, n
 *         line=f.readline().strip().split()             # <<<<<<<<<<<<<<
 *         assert line[0]=='F1'
 *         n=long(line[1])
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_readline); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_line = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3042
 *         cdef long i, n
 *         line=f.readline().strip().split()
 *         assert line[0]=='F1'             # <<<<<<<<<<<<<<
 *         n=long(line[1])
 *         self.clear()
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3042; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_F1, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_6)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":3043
 *         line=f.readline().strip().split()
 *         assert line[0]=='F1'
 *         n=long(line[1])             # <<<<<<<<<<<<<<
 *         self.clear()
 *         self.vec.resize(n)
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3043; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyLong_Type))), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_7;

  /* "lurrn/sparsmat.pyx":3044
 *         assert line[0]=='F1'
 *         n=long(line[1])
 *         self.clear()             # <<<<<<<<<<<<<<
 *         self.vec.resize(n)
 *         k=0
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clear); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3045
 *         n=long(line[1])
 *         self.clear()
 *         self.vec.resize(n)             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_v_self->vec.resize(__pyx_v_n);

  /* "lurrn/sparsmat.pyx":3046
 *         self.clear()
 *         self.vec.resize(n)
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemF1))
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_k = __pyx_int_0;

  /* "lurrn/sparsmat.pyx":3047
 *         self.vec.resize(n)
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemF1))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemF1)
 */
  __pyx_t_7 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3048
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemF1))             # <<<<<<<<<<<<<<
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemF1)
 *             memcpy(<void *>c_VecF1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemF1))
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyInt_FromSize_t((256 * (sizeof(struct CountItem<1,float>)))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":3049
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemF1))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemF1)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecF1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemF1))
 *             k+=CHUNK_SIZE
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!((__pyx_t_8 == (256 * (sizeof(struct CountItem<1,float>)))) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":3050
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemF1))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemF1)
 *             memcpy(<void *>c_VecF1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemF1))             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), (256 * (sizeof(struct CountItem<1,float>))));

    /* "lurrn/sparsmat.pyx":3051
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemF1)
 *             memcpy(<void *>c_VecF1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemF1))
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemF1))
 */
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_k, __pyx_int_256); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_1);
    __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3052
 *             memcpy(<void *>c_VecF1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemF1))
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=f.read((n-k)*sizeof(c_CItemF1))
 *             assert len(s)==(n-k)*sizeof(c_CItemF1)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":3053
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemF1))             # <<<<<<<<<<<<<<
 *             assert len(s)==(n-k)*sizeof(c_CItemF1)
 *             memcpy(<void *>c_VecF1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemF1))
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_5, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<1,float>))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":3054
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemF1))
 *             assert len(s)==(n-k)*sizeof(c_CItemF1)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecF1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemF1))
 *     cpdef int get_maxcol(self, int k=0):
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<1,float>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_6)) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":3055
 *             s=f.read((n-k)*sizeof(c_CItemF1))
 *             assert len(s)==(n-k)*sizeof(c_CItemF1)
 *             memcpy(<void *>c_VecF1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemF1))             # <<<<<<<<<<<<<<
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<1,float>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), __pyx_t_11);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":3039
 *             s=PyString_FromStringAndSize(<char *>c_VecF1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemF1))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.fromfile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_line);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3056
 *             assert len(s)==(n-k)*sizeof(c_CItemF1)
 *             memcpy(<void *>c_VecF1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemF1))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<1
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecF1_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF1_get_maxcol *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_i;
  int __pyx_v_n;
  int __pyx_v_new_val;
  int __pyx_v_col;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_maxcol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_23get_maxcol)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3058
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<1             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         if n==0:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_9 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_9 = ((__pyx_v_k < 1) != 0);
    __pyx_t_8 = __pyx_t_9;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_8)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":3059
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<1
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         if n==0:
 *             return -1
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":3060
 *         assert k>=0 and k<1
 *         n=self.vec.size()
 *         if n==0:             # <<<<<<<<<<<<<<
 *             return -1
 *         if k==0:
 */
  __pyx_t_8 = ((__pyx_v_n == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":3061
 *         n=self.vec.size()
 *         if n==0:
 *             return -1             # <<<<<<<<<<<<<<
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 */
    __pyx_r = -1;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":3062
 *         if n==0:
 *             return -1
 *         if k==0:             # <<<<<<<<<<<<<<
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 */
  __pyx_t_8 = ((__pyx_v_k == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":3063
 *             return -1
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]             # <<<<<<<<<<<<<<
 *         col=-1
 *         n=self.vec.size()
 */
    __pyx_r = (__pyx_v_self->vec.at((__pyx_v_n - 1)).addr[0]);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":3064
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 *         col=-1             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_v_col = -1;

  /* "lurrn/sparsmat.pyx":3065
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":3066
 *         col=-1
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 */
  __pyx_t_7 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3067
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             if new_val>col:
 *                 col=new_val
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":3068
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:             # <<<<<<<<<<<<<<
 *                 col=new_val
 *         return col
 */
    __pyx_t_8 = ((__pyx_v_new_val > __pyx_v_col) != 0);
    if (__pyx_t_8) {

      /* "lurrn/sparsmat.pyx":3069
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 *                 col=new_val             # <<<<<<<<<<<<<<
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 */
      __pyx_v_col = __pyx_v_new_val;
      goto __pyx_L9;
    }
    __pyx_L9:;
  }

  /* "lurrn/sparsmat.pyx":3070
 *             if new_val>col:
 *                 col=new_val
 *         return col             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 *         cdef int old_val, new_val, i, n, count
 */
  __pyx_r = __pyx_v_col;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3056
 *             assert len(s)==(n-k)*sizeof(c_CItemF1)
 *             memcpy(<void *>c_VecF1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemF1))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecF1.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_maxcol (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_maxcol") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_maxcol", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1_22get_maxcol(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_22get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecF1_get_maxcol __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = __pyx_vtabptr_5lurrn_8sparsmat_VecF1->get_maxcol(__pyx_v_self, 1, &__pyx_t_2); 
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3071
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecF1_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF1_get_type_counts *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_new_val;
  int __pyx_v_i;
  int __pyx_v_n;
  PyArrayObject *__pyx_v_result = 0;
  long __pyx_v_n_types;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecF1_get_maxcol __pyx_t_11;
  PyArrayObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_25get_type_counts)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3074
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<1             # <<<<<<<<<<<<<<
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_8 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_k < 1) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_7)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":3075
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<1
 *         if self.vec.size()==0:             # <<<<<<<<<<<<<<
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 */
  __pyx_t_7 = ((__pyx_v_self->vec.size() == 0) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":3076
 *         assert k>=0 and k<1
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_9 = 1;
      }
    }
    __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_2) {
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":3077
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":3078
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1             # <<<<<<<<<<<<<<
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 */
  __pyx_t_11.__pyx_n = 1;
  __pyx_t_11.k = __pyx_v_k;
  __pyx_t_10 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF1 *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0, &__pyx_t_11); 
  __pyx_v_n_types = (__pyx_t_10 + 1);

  /* "lurrn/sparsmat.pyx":3079
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_n_types); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_9 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_6) {
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_12 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
    }
    __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_12 = 0;
  __pyx_v_result = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3080
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":3081
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3082
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             result[new_val]+=1
 *         return result
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":3083
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1             # <<<<<<<<<<<<<<
 *         return result
 *     cpdef VecF1 remap(self, int k, numpy.ndarray filt):
 */
    __pyx_t_16 = __pyx_v_new_val;
    __pyx_t_17 = -1;
    if (__pyx_t_16 < 0) {
      __pyx_t_16 += __pyx_pybuffernd_result.diminfo[0].shape;
      if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 0;
    } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_17 = 0;
    if (unlikely(__pyx_t_17 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_17);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_result.diminfo[0].strides) += 1;
  }

  /* "lurrn/sparsmat.pyx":3084
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 *         return result             # <<<<<<<<<<<<<<
 *     cpdef VecF1 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyArrayObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3071
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3071; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3071; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3071; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1_24get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_24get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecF1_get_type_counts __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_5lurrn_8sparsmat_VecF1->get_type_counts(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3085
 *             result[new_val]+=1
 *         return result
 *     cpdef VecF1 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_f_5lurrn_8sparsmat_5VecF1_remap(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_wanted = 0;
  PyArrayObject *__pyx_v_target = 0;
  int __pyx_v_n;
  int __pyx_v_i;
  struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_result = 0;
  struct CountItem<1,float> __pyx_v_c;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_target;
  __Pyx_Buffer __pyx_pybuffer_target;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_wanted;
  __Pyx_Buffer __pyx_pybuffer_wanted;
  struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __pyx_pybuffer_wanted.pybuffer.buf = NULL;
  __pyx_pybuffer_wanted.refcount = 0;
  __pyx_pybuffernd_wanted.data = NULL;
  __pyx_pybuffernd_wanted.rcbuffer = &__pyx_pybuffer_wanted;
  __pyx_pybuffer_target.pybuffer.buf = NULL;
  __pyx_pybuffer_target.refcount = 0;
  __pyx_pybuffernd_target.data = NULL;
  __pyx_pybuffernd_target.rcbuffer = &__pyx_pybuffer_target;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_remap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_27remap)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_filt));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_filt));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_filt));
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_VecF1))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3086
 *         return result
 *     cpdef VecF1 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_wanted = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_wanted.diminfo[0].strides = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_wanted.diminfo[0].shape = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_8 = 0;
  __pyx_v_wanted = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":3087
 *     cpdef VecF1 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_cumsum); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Subtract(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_target = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_target.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_target.diminfo[0].strides = __pyx_pybuffernd_target.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_target.diminfo[0].shape = __pyx_pybuffernd_target.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_9 = 0;
  __pyx_v_target = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3088
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         cdef int n=self.vec.size()
 *         cdef int i
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":3089
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()             # <<<<<<<<<<<<<<
 *         cdef int i
 *         cdef VecF1 result=VecF1()
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":3091
 *         cdef int n=self.vec.size()
 *         cdef int i
 *         cdef VecF1 result=VecF1()             # <<<<<<<<<<<<<<
 *         cdef c_CItemF1 c
 *         for i from 0<=i<n:
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3093
 *         cdef VecF1 result=VecF1()
 *         cdef c_CItemF1 c
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3094
 *         cdef c_CItemF1 c
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)             # <<<<<<<<<<<<<<
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 */
    __pyx_v_c = __pyx_v_self->vec.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":3095
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:             # <<<<<<<<<<<<<<
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 */
    __pyx_t_11 = (__pyx_v_c.addr[__pyx_v_k]);
    __pyx_t_12 = -1;
    if (__pyx_t_11 < 0) {
      __pyx_t_11 += __pyx_pybuffernd_wanted.diminfo[0].shape;
      if (unlikely(__pyx_t_11 < 0)) __pyx_t_12 = 0;
    } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_wanted.diminfo[0].shape)) __pyx_t_12 = 0;
    if (unlikely(__pyx_t_12 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_12);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_wanted.diminfo[0].strides)) != 0);
    if (__pyx_t_13) {

      /* "lurrn/sparsmat.pyx":3096
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c)
 *         return result
 */
      __pyx_t_12 = (__pyx_v_c.addr[__pyx_v_k]);
      __pyx_t_14 = -1;
      if (__pyx_t_12 < 0) {
        __pyx_t_12 += __pyx_pybuffernd_target.diminfo[0].shape;
        if (unlikely(__pyx_t_12 < 0)) __pyx_t_14 = 0;
      } else if (unlikely(__pyx_t_12 >= __pyx_pybuffernd_target.diminfo[0].shape)) __pyx_t_14 = 0;
      if (unlikely(__pyx_t_14 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_14);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      (__pyx_v_c.addr[__pyx_v_k]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_target.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_target.diminfo[0].strides));

      /* "lurrn/sparsmat.pyx":3097
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         return result
 *     def append(self,tup):
 */
      __pyx_v_result->vec.push_back(__pyx_v_c);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "lurrn/sparsmat.pyx":3098
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 *         return result             # <<<<<<<<<<<<<<
 *     def append(self,tup):
 *         k0,val=tup
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3085
 *             result[new_val]+=1
 *         return result
 *     cpdef VecF1 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_wanted);
  __Pyx_XDECREF((PyObject *)__pyx_v_target);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3085; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3085; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3085; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_filt = ((PyArrayObject *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3085; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_filt), __pyx_ptype_5numpy_ndarray, 1, "filt", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1_26remap(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_26remap(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_5VecF1_remap(__pyx_v_self, __pyx_v_k, __pyx_v_filt, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3099
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,val=tup
 *         self.c_add(k0,val)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_29append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_29append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("append (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1_28append(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self), ((PyObject *)__pyx_v_tup));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_28append(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *(*__pyx_t_4)(PyObject *);
  coordinate_t __pyx_t_5;
  float __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("append", 0);

  /* "lurrn/sparsmat.pyx":3100
 *         return result
 *     def append(self,tup):
 *         k0,val=tup             # <<<<<<<<<<<<<<
 *         self.c_add(k0,val)
 *     def extend(self,tups):
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_tup))) || (PyList_CheckExact(__pyx_v_tup))) {
    PyObject* sequence = __pyx_v_tup;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    #endif
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_4(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_k0 = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_val = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":3101
 *     def append(self,tup):
 *         k0,val=tup
 *         self.c_add(k0,val)             # <<<<<<<<<<<<<<
 *     def extend(self,tups):
 *         for k0,val in tups:
 */
  __pyx_t_5 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_5 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = __pyx_PyFloat_AsFloat(__pyx_v_val); if (unlikely((__pyx_t_6 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF1 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_5, __pyx_t_6);

  /* "lurrn/sparsmat.pyx":3099
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,val=tup
 *         self.c_add(k0,val)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3102
 *         k0,val=tup
 *         self.c_add(k0,val)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,val in tups:
 *             self.c_add(k0,val)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_31extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_31extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extend (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1_30extend(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self), ((PyObject *)__pyx_v_tups));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_30extend(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  coordinate_t __pyx_t_9;
  float __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("extend", 0);

  /* "lurrn/sparsmat.pyx":3103
 *         self.c_add(k0,val)
 *     def extend(self,tups):
 *         for k0,val in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,val)
 *     def __iter__(self):
 */
  if (likely(PyList_CheckExact(__pyx_v_tups)) || PyTuple_CheckExact(__pyx_v_tups)) {
    __pyx_t_1 = __pyx_v_tups; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_tups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_k0, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "lurrn/sparsmat.pyx":3104
 *     def extend(self,tups):
 *         for k0,val in tups:
 *             self.c_add(k0,val)             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self.item_iter()
 */
    __pyx_t_9 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_9 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __pyx_PyFloat_AsFloat(__pyx_v_val); if (unlikely((__pyx_t_10 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF1 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_9, __pyx_t_10);

    /* "lurrn/sparsmat.pyx":3103
 *         self.c_add(k0,val)
 *     def extend(self,tups):
 *         for k0,val in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,val)
 *     def __iter__(self):
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3102
 *         k0,val=tup
 *         self.c_add(k0,val)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,val in tups:
 *             self.c_add(k0,val)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.extend", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3105
 *         for k0,val in tups:
 *             self.c_add(k0,val)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_33__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_33__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1_32__iter__(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_32__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":3106
 *             self.c_add(k0,val)
 *     def __iter__(self):
 *         return self.item_iter()             # <<<<<<<<<<<<<<
 *     def __reduce__(self):
 *         return (VecF1,(),(),self.item_iter())
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3105
 *         for k0,val in tups:
 *             self.c_add(k0,val)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3107
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecF1,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_35__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_35__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1_34__reduce__(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_34__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "lurrn/sparsmat.pyx":3108
 *         return self.item_iter()
 *     def __reduce__(self):
 *         return (VecF1,(),(),self.item_iter())             # <<<<<<<<<<<<<<
 *     def __setstate__(self,state):
 *         pass
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF1)));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF1)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF1)));
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3107
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecF1,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3109
 *     def __reduce__(self):
 *         return (VecF1,(),(),self.item_iter())
 *     def __setstate__(self,state):             # <<<<<<<<<<<<<<
 *         pass
 *     def __repr__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_37__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_37__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1_36__setstate__(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self), ((PyObject *)__pyx_v_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_36__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3111
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecF1(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_39__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF1_39__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF1_38__repr__(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF1_38__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "lurrn/sparsmat.pyx":3112
 *         pass
 *     def __repr__(self):
 *         return 'VecF1(%s)'%(str(list(self)),)             # <<<<<<<<<<<<<<
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_VecF1_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3111
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecF1(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF1.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3113
 *     def __repr__(self):
 *         return 'VecF1(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

/* Python wrapper */
static void __pyx_pw_5lurrn_8sparsmat_5VecF1_41__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5lurrn_8sparsmat_5VecF1_41__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5lurrn_8sparsmat_5VecF1_40__dealloc__(((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5lurrn_8sparsmat_5VecF1_40__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lurrn/sparsmat.pyx":3115
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()             # <<<<<<<<<<<<<<
 * 
 * cdef class IVecF1_iter:
 */
  __pyx_v_self->vec.~vector();

  /* "lurrn/sparsmat.pyx":3113
 *     def __repr__(self):
 *         return 'VecF1(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":3121
 *     cdef c_VecF1 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_11IVecF1_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_11IVecF1_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_vec = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_vec,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3121; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_vec = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3121; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.IVecF1_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecF1_iter___init__(((struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter *)__pyx_v_self), __pyx_v_vec);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_11IVecF1_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter *__pyx_v_self, PyObject *__pyx_v_vec) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":3122
 *     cdef unsigned int k
 *     def __init__(self,vec):
 *         self.vec=vec             # <<<<<<<<<<<<<<
 *         self.vecC=&self.vec.vec
 *         self.k=0
 */
  if (!(likely(((__pyx_v_vec) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_vec, __pyx_ptype_5lurrn_8sparsmat_VecF1))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_vec;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->vec);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->vec));
  __pyx_v_self->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3123
 *     def __init__(self,vec):
 *         self.vec=vec
 *         self.vecC=&self.vec.vec             # <<<<<<<<<<<<<<
 *         self.k=0
 *     def __iter__(self):
 */
  __pyx_v_self->vecC = (&__pyx_v_self->vec->vec);

  /* "lurrn/sparsmat.pyx":3124
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 *         self.k=0             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self
 */
  __pyx_v_self->k = 0;

  /* "lurrn/sparsmat.pyx":3121
 *     cdef c_VecF1 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecF1_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3125
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecF1_iter_3__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecF1_iter_3__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecF1_iter_2__iter__(((struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecF1_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":3126
 *         self.k=0
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3125
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3127
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecF1_iter_5__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecF1_iter_5__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecF1_iter_4__next__(((struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecF1_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter *__pyx_v_self) {
  struct CountItem<1,float> __pyx_v_res;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "lurrn/sparsmat.pyx":3128
 *         return self
 *     def __next__(self):
 *         if self.k>=self.vecC.size():             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         cdef c_CItemF1 res=self.vecC.at(self.k)
 */
  __pyx_t_1 = ((__pyx_v_self->k >= __pyx_v_self->vecC->size()) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":3129
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         cdef c_CItemF1 res=self.vecC.at(self.k)
 *         self.k+=1
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lurrn/sparsmat.pyx":3130
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 *         cdef c_CItemF1 res=self.vecC.at(self.k)             # <<<<<<<<<<<<<<
 *         self.k+=1
 *         return (res.addr[0],
 */
  __pyx_v_res = __pyx_v_self->vecC->at(__pyx_v_self->k);

  /* "lurrn/sparsmat.pyx":3131
 *             raise StopIteration
 *         cdef c_CItemF1 res=self.vecC.at(self.k)
 *         self.k+=1             # <<<<<<<<<<<<<<
 *         return (res.addr[0],
 *                 res.item)
 */
  __pyx_v_self->k = (__pyx_v_self->k + 1);

  /* "lurrn/sparsmat.pyx":3132
 *         cdef c_CItemF1 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.item)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_res.addr[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "lurrn/sparsmat.pyx":3133
 *         self.k+=1
 *         return (res.addr[0],
 *                 res.item)             # <<<<<<<<<<<<<<
 * 
 * cdef class LargeVecF1:
 */
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_res.item); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "lurrn/sparsmat.pyx":3132
 *         cdef c_CItemF1 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.item)
 * 
 */
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3127
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecF1_iter.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3138
 *     cdef public object compact
 *     cdef public VecF1 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecF1()
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF1_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF1_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF1___init__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF1___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":3139
 *     cdef public VecF1 loose
 *     def __init__(self):
 *         self.compact=[]             # <<<<<<<<<<<<<<
 *         self.loose=VecF1()
 *         self.loose.vec.reserve(100000)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3140
 *     def __init__(self):
 *         self.compact=[]
 *         self.loose=VecF1()             # <<<<<<<<<<<<<<
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3141
 *         self.compact=[]
 *         self.loose=VecF1()
 *         self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 */
  __pyx_v_self->loose->vec.reserve(100000);

  /* "lurrn/sparsmat.pyx":3138
 *     cdef public object compact
 *     cdef public VecF1 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecF1()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF1.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3142
 *         self.loose=VecF1()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ensure_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_2ensure_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF1_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":3143
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *         self.loose=VecF1()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":3144
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *         self.loose=VecF1()
 *         while len(self.compact)>=2:
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":3145
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 *         self.loose=VecF1()             # <<<<<<<<<<<<<<
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":3146
 *             self.compact.append(self.loose)
 *         self.loose=VecF1()
 *         while len(self.compact)>=2:             # <<<<<<<<<<<<<<
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0, item=1):
 */
  while (1) {
    __pyx_t_2 = __pyx_v_self->compact;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = ((__pyx_t_6 >= 2) != 0);
    if (!__pyx_t_4) break;

    /* "lurrn/sparsmat.pyx":3147
 *         self.loose=VecF1()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.loose.c_add(k0, item)
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3147; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3147; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_1, -2, 0, NULL, NULL, &__pyx_slice__30, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3142
 *         self.loose=VecF1()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF1.ensure_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3148
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0, item=1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0, item)
 *         if self.loose.get_size(False)>=100000:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  PyObject *__pyx_v_item = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_item,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_item);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3148; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3148; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_item = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3148; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF1.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_4add_count(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *)__pyx_v_self), __pyx_v_k0, __pyx_v_item);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF1_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self, coordinate_t __pyx_v_k0, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  float __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":3149
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.loose.c_add(k0, item)             # <<<<<<<<<<<<<<
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 */
  __pyx_t_1 = __pyx_PyFloat_AsFloat(__pyx_v_item); if (unlikely((__pyx_t_1 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF1 *)__pyx_v_self->loose->__pyx_vtab)->c_add(__pyx_v_self->loose, __pyx_v_k0, __pyx_t_1);

  /* "lurrn/sparsmat.pyx":3150
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.loose.c_add(k0, item)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_int_100000, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":3151
 *         self.loose.c_add(k0, item)
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *             self.loose=VecF1()
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF1 *)__pyx_v_self->loose->__pyx_vtab)->ensure_compact(__pyx_v_self->loose);

    /* "lurrn/sparsmat.pyx":3152
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *             self.loose=VecF1()
 *             self.loose.vec.reserve(100000)
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lurrn/sparsmat.pyx":3153
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 *             self.loose=VecF1()             # <<<<<<<<<<<<<<
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 */
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->loose);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
    __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":3154
 *             self.compact.append(self.loose)
 *             self.loose=VecF1()
 *             self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 */
    __pyx_v_self->loose->vec.reserve(100000);

    /* "lurrn/sparsmat.pyx":3155
 *             self.loose=VecF1()
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and             # <<<<<<<<<<<<<<
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
    while (1) {
      __pyx_t_2 = __pyx_v_self->compact;
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_7 = ((__pyx_t_6 >= 2) != 0);
      if (__pyx_t_7) {
      } else {
        __pyx_t_4 = __pyx_t_7;
        goto __pyx_L6_bool_binop_done;
      }

      /* "lurrn/sparsmat.pyx":3156
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):             # <<<<<<<<<<<<<<
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 */
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3156; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3156; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyNumber_Multiply(__pyx_float_0_6, __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_2, __pyx_t_9, Py_GE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_4 = __pyx_t_7;
      __pyx_L6_bool_binop_done:;
      if (!__pyx_t_4) break;

      /* "lurrn/sparsmat.pyx":3157
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3157; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3157; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = PyNumber_Add(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyList_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_9, -2, 0, NULL, NULL, &__pyx_slice__32, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":3148
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0, item=1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0, item)
 *         if self.loose.get_size(False)>=100000:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF1.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3158
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_6get_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF1_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_compact", 0);

  /* "lurrn/sparsmat.pyx":3159
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         if len(self.compact)>0:
 *             return self.compact[0]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3160
 *     def get_compact(self):
 *         self.ensure_compact()
 *         if len(self.compact)>0:             # <<<<<<<<<<<<<<
 *             return self.compact[0]
 *         else:
 */
  __pyx_t_1 = __pyx_v_self->compact;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((__pyx_t_4 > 0) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":3161
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 *             return self.compact[0]             # <<<<<<<<<<<<<<
 *         else:
 *             return VecF1()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3161; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":3163
 *             return self.compact[0]
 *         else:
 *             return VecF1()             # <<<<<<<<<<<<<<
 *     def get_size(self, compactify=True):
 *         cdef int n
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":3158
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF1.get_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3164
 *         else:
 *             return VecF1()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3164; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3164; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF1.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_8get_size(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF1_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  int __pyx_v_n;
  PyObject *__pyx_v_c = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":3166
 *     def get_size(self, compactify=True):
 *         cdef int n
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *             if self.compact:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":3167
 *         cdef int n
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *             if self.compact:
 *                 return self.compact[0].get_size()
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":3168
 *         if compactify:
 *             self.ensure_compact()
 *             if self.compact:             # <<<<<<<<<<<<<<
 *                 return self.compact[0].get_size()
 *             else:
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->compact); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":3169
 *             self.ensure_compact()
 *             if self.compact:
 *                 return self.compact[0].get_size()             # <<<<<<<<<<<<<<
 *             else:
 *                 return 0
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3169; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":3171
 *                 return self.compact[0].get_size()
 *             else:
 *                 return 0             # <<<<<<<<<<<<<<
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_int_0);
      __pyx_r = __pyx_int_0;
      goto __pyx_L0;
    }
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":3173
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_v_self->compact)) || PyTuple_CheckExact(__pyx_v_self->compact)) {
      __pyx_t_4 = __pyx_v_self->compact; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_self->compact); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_get_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":3174
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":3175
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)
 *             return n             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         self.ensure_compact()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":3164
 *         else:
 *             return VecF1()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF1.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_c);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3176
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_11__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_11__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_10__iter__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF1_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":3177
 *             return n
 *     def __iter__(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         try:
 *             return iter(self.compact[0])
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3178
 *     def __iter__(self):
 *         self.ensure_compact()
 *         try:             # <<<<<<<<<<<<<<
 *             return iter(self.compact[0])
 *         except IndexError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "lurrn/sparsmat.pyx":3179
 *         self.ensure_compact()
 *         try:
 *             return iter(self.compact[0])             # <<<<<<<<<<<<<<
 *         except IndexError:
 *             return iter([])
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3179; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3179; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L7_try_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":3180
 *         try:
 *             return iter(self.compact[0])
 *         except IndexError:             # <<<<<<<<<<<<<<
 *             return iter([])
 * 
 */
    __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_IndexError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF1.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3180; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_3);

      /* "lurrn/sparsmat.pyx":3181
 *             return iter(self.compact[0])
 *         except IndexError:
 *             return iter([])             # <<<<<<<<<<<<<<
 * 
 *     def get_type_counts(self, k=0):
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3181; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3181; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_r = __pyx_t_9;
      __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":3176
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF1.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3183
 *             return iter([])
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_13get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_13get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3183; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3183; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_12get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF1_12get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);

  /* "lurrn/sparsmat.pyx":3184
 * 
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)             # <<<<<<<<<<<<<<
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_k);
    __Pyx_GIVEREF(__pyx_v_k);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3183
 *             return iter([])
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3185
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_15remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_15remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  PyObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3185; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3185; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = values[0];
    __pyx_v_filt = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3185; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_14remap(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF1_14remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);

  /* "lurrn/sparsmat.pyx":3186
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_remap); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_v_k);
  PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_k);
  __Pyx_GIVEREF(__pyx_v_k);
  __Pyx_INCREF(__pyx_v_filt);
  PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_filt);
  __Pyx_GIVEREF(__pyx_v_filt);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3185
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3136
 * 
 * cdef class LargeVecF1:
 *     cdef public object compact             # <<<<<<<<<<<<<<
 *     cdef public VecF1 loose
 *     def __init__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_7compact_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_7compact_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_7compact___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF1_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->compact);
  __pyx_r = __pyx_v_self->compact;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF1_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF1_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_7compact_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF1_7compact_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF1_7compact_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_7compact_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3137
 * cdef class LargeVecF1:
 *     cdef public object compact
 *     cdef public VecF1 loose             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *         self.compact=[]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_5loose_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_5loose_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_5loose___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF1_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->loose));
  __pyx_r = ((PyObject *)__pyx_v_self->loose);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF1_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF1_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_5loose_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5lurrn_8sparsmat_VecF1))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF1.loose.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF1_5loose_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF1_5loose_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_5loose_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF1_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3193
 * cdef class VecF2:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_5VecF2_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_5VecF2_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2___init__(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_5VecF2___init__(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":3194
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     def item_iter(self):
 *         self.ensure_compact()
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":3193
 * cdef class VecF2:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3195
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecF2_iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("item_iter (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2_2item_iter(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("item_iter", 0);

  /* "lurrn/sparsmat.pyx":3196
 *         self.is_compact=True
 *     def item_iter(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return IVecF2_iter(self)
 *     def get_size(self,compactify=True):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":3197
 *     def item_iter(self):
 *         self.ensure_compact()
 *         return IVecF2_iter(self)             # <<<<<<<<<<<<<<
 *     def get_size(self,compactify=True):
 *         if compactify:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_IVecF2_iter)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3195
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecF2_iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.item_iter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3198
 *         self.ensure_compact()
 *         return IVecF2_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3198; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3198; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2_4get_size(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":3199
 *         return IVecF2_iter(self)
 *     def get_size(self,compactify=True):
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *         return self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":3200
 *     def get_size(self,compactify=True):
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return self.vec.size()
 *     def __len__(self):
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":3201
 *         if compactify:
 *             self.ensure_compact()
 *         return self.vec.size()             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return self.get_size(True)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_self->vec.size()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3198
 *         self.ensure_compact()
 *         return IVecF2_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3202
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecF2_7__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecF2_7__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2_6__len__(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecF2_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":3203
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__35, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3202
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3204
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2_8clear(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear", 0);

  /* "lurrn/sparsmat.pyx":3205
 *         return self.get_size(True)
 *     def clear(self):
 *         self.vec.resize(0)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void compactify(self):
 */
  __pyx_v_self->vec.resize(0);

  /* "lurrn/sparsmat.pyx":3206
 *     def clear(self):
 *         self.vec.resize(0)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrF2 comp
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":3204
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3207
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrF2 comp
 *         c_IVecF2_sort(self.vec.begin(),self.vec.end(),comp)
 */

static void __pyx_f_5lurrn_8sparsmat_5VecF2_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self) {
  struct smallerAddr<2,float> __pyx_v_comp;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compactify", 0);

  /* "lurrn/sparsmat.pyx":3209
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrF2 comp
 *         c_IVecF2_sort(self.vec.begin(),self.vec.end(),comp)             # <<<<<<<<<<<<<<
 *         c_compactifyF2(&self.vec)
 *         self.is_compact=True
 */
  sort(__pyx_v_self->vec.begin(), __pyx_v_self->vec.end(), __pyx_v_comp);

  /* "lurrn/sparsmat.pyx":3210
 *         cdef c_SmallerAddrF2 comp
 *         c_IVecF2_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyF2(&self.vec)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 */
  compactify((&__pyx_v_self->vec));

  /* "lurrn/sparsmat.pyx":3211
 *         c_IVecF2_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyF2(&self.vec)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":3207
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrF2 comp
 *         c_IVecF2_sort(self.vec.begin(),self.vec.end(),comp)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":3212
 *         c_compactifyF2(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

static void __pyx_f_5lurrn_8sparsmat_5VecF2_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":3213
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:             # <<<<<<<<<<<<<<
 *             self.compactify()
 *     cpdef float get_count(self,coordinate_t k0,coordinate_t k1):
 */
  __pyx_t_1 = ((!(__pyx_v_self->is_compact != 0)) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":3214
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 *             self.compactify()             # <<<<<<<<<<<<<<
 *     cpdef float get_count(self,coordinate_t k0,coordinate_t k1):
 *         cdef c_CItemF2 ci
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF2 *)__pyx_v_self->__pyx_vtab)->compactify(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":3212
 *         c_compactifyF2(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":3215
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef float get_count(self,coordinate_t k0,coordinate_t k1):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF2 ci
 *         ci.addr[0]=k0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static float __pyx_f_5lurrn_8sparsmat_5VecF2_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, int __pyx_skip_dispatch) {
  struct CountItem<2,float> __pyx_v_ci;
  float __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  float __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_11get_count)) {
      __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_5 = __pyx_t_1; __pyx_t_6 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_7 = 1;
        }
      }
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_6) {
        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_9;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3217
 *     cpdef float get_count(self,coordinate_t k0,coordinate_t k1):
 *         cdef c_CItemF2 ci
 *         ci.addr[0]=k0             # <<<<<<<<<<<<<<
 *         ci.addr[1]=k1
 *         return c_get_countF2(&self.vec,ci)
 */
  (__pyx_v_ci.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":3218
 *         cdef c_CItemF2 ci
 *         ci.addr[0]=k0
 *         ci.addr[1]=k1             # <<<<<<<<<<<<<<
 *         return c_get_countF2(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1, float item):
 */
  (__pyx_v_ci.addr[1]) = __pyx_v_k1;

  /* "lurrn/sparsmat.pyx":3219
 *         ci.addr[0]=k0
 *         ci.addr[1]=k1
 *         return c_get_countF2(&self.vec,ci)             # <<<<<<<<<<<<<<
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1, float item):
 *         cdef c_CItemF2 c
 */
  __pyx_r = get_count_v((&__pyx_v_self->vec), __pyx_v_ci);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3215
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef float get_count(self,coordinate_t k0,coordinate_t k1):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF2 ci
 *         ci.addr[0]=k0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecF2.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_count", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_count", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2_10get_count(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_5VecF2_get_count(__pyx_v_self, __pyx_v_k0, __pyx_v_k1, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3220
 *         ci.addr[1]=k1
 *         return c_get_countF2(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1, float item):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF2 c
 *         c.addr[0]=k0
 */

static void __pyx_f_5lurrn_8sparsmat_5VecF2_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, float __pyx_v_item) {
  struct CountItem<2,float> __pyx_v_c;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_add", 0);

  /* "lurrn/sparsmat.pyx":3222
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1, float item):
 *         cdef c_CItemF2 c
 *         c.addr[0]=k0             # <<<<<<<<<<<<<<
 *         c.addr[1]=k1
 *         c.item=item
 */
  (__pyx_v_c.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":3223
 *         cdef c_CItemF2 c
 *         c.addr[0]=k0
 *         c.addr[1]=k1             # <<<<<<<<<<<<<<
 *         c.item=item
 *         self.vec.push_back(c)
 */
  (__pyx_v_c.addr[1]) = __pyx_v_k1;

  /* "lurrn/sparsmat.pyx":3224
 *         c.addr[0]=k0
 *         c.addr[1]=k1
 *         c.item=item             # <<<<<<<<<<<<<<
 *         self.vec.push_back(c)
 *         self.is_compact=False
 */
  __pyx_v_c.item = __pyx_v_item;

  /* "lurrn/sparsmat.pyx":3225
 *         c.addr[1]=k1
 *         c.item=item
 *         self.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 */
  __pyx_v_self->vec.push_back(__pyx_v_c);

  /* "lurrn/sparsmat.pyx":3226
 *         c.item=item
 *         self.vec.push_back(c)
 *         self.is_compact=False             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.c_add(k0,k1, item)
 */
  __pyx_v_self->is_compact = 0;

  /* "lurrn/sparsmat.pyx":3220
 *         ci.addr[1]=k1
 *         return c_get_countF2(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1, float item):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF2 c
 *         c.addr[0]=k0
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":3227
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1, item)
 *     def __add__(VecF2 self, VecF2 other):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  PyObject *__pyx_v_item = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,&__pyx_n_s_item,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_item);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_item = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2_12add_count(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1, __pyx_v_item);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  float __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":3228
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.c_add(k0,k1, item)             # <<<<<<<<<<<<<<
 *     def __add__(VecF2 self, VecF2 other):
 *         cdef c_CItemF2 c1, c2
 */
  __pyx_t_1 = __pyx_PyFloat_AsFloat(__pyx_v_item); if (unlikely((__pyx_t_1 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF2 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_v_k0, __pyx_v_k1, __pyx_t_1);

  /* "lurrn/sparsmat.pyx":3227
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1, item)
 *     def __add__(VecF2 self, VecF2 other):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3229
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.c_add(k0,k1, item)
 *     def __add__(VecF2 self, VecF2 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF2 c1, c2
 *         cdef unsigned int i1, i2
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_VecF2, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_VecF2, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2_14__add__(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_other) {
  struct CountItem<2,float> __pyx_v_c1;
  struct CountItem<2,float> __pyx_v_c2;
  unsigned int __pyx_v_i1;
  unsigned int __pyx_v_i2;
  int __pyx_v_k;
  int __pyx_v_delta;
  struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":3234
 *         cdef int k, delta
 *         cdef VecF2 result
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         other.ensure_compact()
 *         result=VecF2()
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":3235
 *         cdef VecF2 result
 *         self.ensure_compact()
 *         other.ensure_compact()             # <<<<<<<<<<<<<<
 *         result=VecF2()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF2 *)__pyx_v_other->__pyx_vtab)->ensure_compact(__pyx_v_other);

  /* "lurrn/sparsmat.pyx":3236
 *         self.ensure_compact()
 *         other.ensure_compact()
 *         result=VecF2()             # <<<<<<<<<<<<<<
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3237
 *         other.ensure_compact()
 *         result=VecF2()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))             # <<<<<<<<<<<<<<
 *         i1=0
 *         i2=0
 */
  __pyx_t_2 = __pyx_v_other->vec.size();
  __pyx_t_3 = __pyx_v_self->vec.size();
  if (((__pyx_t_2 > __pyx_t_3) != 0)) {
    __pyx_t_4 = __pyx_t_2;
  } else {
    __pyx_t_4 = __pyx_t_3;
  }
  __pyx_v_result->vec.reserve(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":3238
 *         result=VecF2()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0             # <<<<<<<<<<<<<<
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 */
  __pyx_v_i1 = 0;

  /* "lurrn/sparsmat.pyx":3239
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 *         i2=0             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 */
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":3240
 *         i1=0
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 */
  while (1) {
    __pyx_t_6 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_6 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":3241
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             delta=0
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":3242
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             delta=0
 *             for k from 0<=k<2:
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":3243
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 *             delta=0             # <<<<<<<<<<<<<<
 *             for k from 0<=k<2:
 *                 if c1.addr[k]<c2.addr[k]:
 */
    __pyx_v_delta = 0;

    /* "lurrn/sparsmat.pyx":3244
 *             c2=other.vec.at(i2)
 *             delta=0
 *             for k from 0<=k<2:             # <<<<<<<<<<<<<<
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 */
    for (__pyx_v_k = 0; __pyx_v_k < 2; __pyx_v_k++) {

      /* "lurrn/sparsmat.pyx":3245
 *             delta=0
 *             for k from 0<=k<2:
 *                 if c1.addr[k]<c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=-1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) < (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":3246
 *             for k from 0<=k<2:
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1             # <<<<<<<<<<<<<<
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 */
        __pyx_v_delta = -1;

        /* "lurrn/sparsmat.pyx":3247
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 *                     break             # <<<<<<<<<<<<<<
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 */
        goto __pyx_L8_break;
      }

      /* "lurrn/sparsmat.pyx":3248
 *                     delta=-1
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) > (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":3249
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1             # <<<<<<<<<<<<<<
 *                     break
 *             if delta==0:
 */
        __pyx_v_delta = 1;

        /* "lurrn/sparsmat.pyx":3250
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 *                     break             # <<<<<<<<<<<<<<
 *             if delta==0:
 *                 c1.item+=c2.item
 */
        goto __pyx_L8_break;
      }
    }
    __pyx_L8_break:;

    /* "lurrn/sparsmat.pyx":3256
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
    switch (__pyx_v_delta) {

      /* "lurrn/sparsmat.pyx":3251
 *                     delta=1
 *                     break
 *             if delta==0:             # <<<<<<<<<<<<<<
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)
 */
      case 0:

      /* "lurrn/sparsmat.pyx":3252
 *                     break
 *             if delta==0:
 *                 c1.item+=c2.item             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      __pyx_v_c1.item = (__pyx_v_c1.item + __pyx_v_c2.item);

      /* "lurrn/sparsmat.pyx":3253
 *             if delta==0:
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *                 i2+=1
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":3254
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *                 i2+=1
 *             elif delta==-1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);

      /* "lurrn/sparsmat.pyx":3255
 *                 result.vec.push_back(c1)
 *                 i1+=1
 *                 i2+=1             # <<<<<<<<<<<<<<
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;

      /* "lurrn/sparsmat.pyx":3256
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      case -1:

      /* "lurrn/sparsmat.pyx":3257
 *                 i2+=1
 *             elif delta==-1:
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             else:
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":3258
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             else:
 *                 result.vec.push_back(c2)
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      break;
      default:

      /* "lurrn/sparsmat.pyx":3260
 *                 i1+=1
 *             else:
 *                 result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *                 i2+=1
 *         while i1<self.vec.size():
 */
      __pyx_v_result->vec.push_back(__pyx_v_c2);

      /* "lurrn/sparsmat.pyx":3261
 *             else:
 *                 result.vec.push_back(c2)
 *                 i2+=1             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;
    }
  }

  /* "lurrn/sparsmat.pyx":3262
 *                 result.vec.push_back(c2)
 *                 i2+=1
 *         while i1<self.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":3263
 *                 i2+=1
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c1)
 *             i1+=1
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":3264
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *             i1+=1
 *         while i2<other.vec.size():
 */
    __pyx_v_result->vec.push_back(__pyx_v_c1);

    /* "lurrn/sparsmat.pyx":3265
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 *             i1+=1             # <<<<<<<<<<<<<<
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);
  }

  /* "lurrn/sparsmat.pyx":3266
 *             result.vec.push_back(c1)
 *             i1+=1
 *         while i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":3267
 *             i1+=1
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c2)
 *             i2+=1
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":3268
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *             i2+=1
 *         return result
 */
    __pyx_v_result->vec.push_back(__pyx_v_c2);

    /* "lurrn/sparsmat.pyx":3269
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 *             i2+=1             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_v_i2 = (__pyx_v_i2 + 1);
  }

  /* "lurrn/sparsmat.pyx":3270
 *             result.vec.push_back(c2)
 *             i2+=1
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     cpdef CSRMatrixF to_csr(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3229
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.c_add(k0,k1, item)
 *     def __add__(VecF2 self, VecF2 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF2 c1, c2
 *         cdef unsigned int i1, i2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3272
 *         return result
 * 
 *     cpdef CSRMatrixF to_csr(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         cdef c_CSRMatrixF *matC=vec2csrF(&self.vec)
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_17to_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_f_5lurrn_8sparsmat_5VecF2_to_csr(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, int __pyx_skip_dispatch) {
  struct CSRMatrix<float> *__pyx_v_matC;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_v_mat = 0;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_csr", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_to_csr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_17to_csr)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3273
 * 
 *     cpdef CSRMatrixF to_csr(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         cdef c_CSRMatrixF *matC=vec2csrF(&self.vec)
 *         cdef CSRMatrixF mat=CSRMatrixF()
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":3274
 *     cpdef CSRMatrixF to_csr(self):
 *         self.ensure_compact()
 *         cdef c_CSRMatrixF *matC=vec2csrF(&self.vec)             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixF mat=CSRMatrixF()
 *         mat.set_matrix(matC)
 */
  __pyx_v_matC = vec2csr((&__pyx_v_self->vec));

  /* "lurrn/sparsmat.pyx":3275
 *         self.ensure_compact()
 *         cdef c_CSRMatrixF *matC=vec2csrF(&self.vec)
 *         cdef CSRMatrixF mat=CSRMatrixF()             # <<<<<<<<<<<<<<
 *         mat.set_matrix(matC)
 *         return mat
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixF)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_mat = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3276
 *         cdef c_CSRMatrixF *matC=vec2csrF(&self.vec)
 *         cdef CSRMatrixF mat=CSRMatrixF()
 *         mat.set_matrix(matC)             # <<<<<<<<<<<<<<
 *         return mat
 * 
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixF *)__pyx_v_mat->__pyx_vtab)->set_matrix(__pyx_v_mat, __pyx_v_matC);

  /* "lurrn/sparsmat.pyx":3277
 *         cdef CSRMatrixF mat=CSRMatrixF()
 *         mat.set_matrix(matC)
 *         return mat             # <<<<<<<<<<<<<<
 * 
 *     def tofile(self, f):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_mat));
  __pyx_r = __pyx_v_mat;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3272
 *         return result
 * 
 *     cpdef CSRMatrixF to_csr(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         cdef c_CSRMatrixF *matC=vec2csrF(&self.vec)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.to_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mat);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_17to_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_17to_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_csr (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2_16to_csr(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_16to_csr(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_csr", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_5VecF2_to_csr(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.to_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3279
 *         return mat
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_19tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_19tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tofile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2_18tofile(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_18tofile(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  long __pyx_v_k;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  long __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("tofile", 0);

  /* "lurrn/sparsmat.pyx":3281
 *     def tofile(self, f):
 *         cdef long i, n, k, k_max
 *         n=self.get_size()             # <<<<<<<<<<<<<<
 *         f.write('F2 %d\n'%(n,))
 *         k=0
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":3282
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 *         f.write('F2 %d\n'%(n,))             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_F2_d, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3283
 *         n=self.get_size()
 *         f.write('F2 %d\n'%(n,))
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecF2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemF2))
 */
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":3284
 *         f.write('F2 %d\n'%(n,))
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecF2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemF2))
 *             f.write(s)
 */
  __pyx_t_4 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3285
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecF2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemF2))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *             k+=CHUNK_SIZE
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), (256 * (sizeof(struct CountItem<2,float>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":3286
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecF2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemF2))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":3287
 *             s=PyString_FromStringAndSize(<char *>c_VecF2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemF2))
 *             f.write(s)
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecF2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemF2))
 */
    __pyx_v_k = (__pyx_v_k + 256);
  }

  /* "lurrn/sparsmat.pyx":3288
 *             f.write(s)
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecF2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemF2))
 *             f.write(s)
 */
  __pyx_t_7 = ((__pyx_v_k < __pyx_v_n) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":3289
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecF2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemF2))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *     def fromfile(self, f):
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), ((__pyx_v_n - __pyx_v_k) * (sizeof(struct CountItem<2,float>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":3290
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecF2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemF2))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *     def fromfile(self, f):
 *         cdef long i, n
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":3279
 *         return mat
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.tofile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3291
 *             s=PyString_FromStringAndSize(<char *>c_VecF2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemF2))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_21fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_21fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fromfile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2_20fromfile(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_20fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  PyObject *__pyx_v_line = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  long __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  size_t __pyx_t_9;
  char *__pyx_t_10;
  size_t __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromfile", 0);

  /* "lurrn/sparsmat.pyx":3293
 *     def fromfile(self, f):
 *         cdef long i, n
 *         line=f.readline().strip().split()             # <<<<<<<<<<<<<<
 *         assert line[0]=='F2'
 *         n=long(line[1])
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_readline); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_line = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3294
 *         cdef long i, n
 *         line=f.readline().strip().split()
 *         assert line[0]=='F2'             # <<<<<<<<<<<<<<
 *         n=long(line[1])
 *         self.clear()
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3294; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_F2, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_6)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":3295
 *         line=f.readline().strip().split()
 *         assert line[0]=='F2'
 *         n=long(line[1])             # <<<<<<<<<<<<<<
 *         self.clear()
 *         self.vec.resize(n)
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3295; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyLong_Type))), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_7;

  /* "lurrn/sparsmat.pyx":3296
 *         assert line[0]=='F2'
 *         n=long(line[1])
 *         self.clear()             # <<<<<<<<<<<<<<
 *         self.vec.resize(n)
 *         k=0
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clear); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3297
 *         n=long(line[1])
 *         self.clear()
 *         self.vec.resize(n)             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_v_self->vec.resize(__pyx_v_n);

  /* "lurrn/sparsmat.pyx":3298
 *         self.clear()
 *         self.vec.resize(n)
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemF2))
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_k = __pyx_int_0;

  /* "lurrn/sparsmat.pyx":3299
 *         self.vec.resize(n)
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemF2))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemF2)
 */
  __pyx_t_7 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3300
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemF2))             # <<<<<<<<<<<<<<
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemF2)
 *             memcpy(<void *>c_VecF2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemF2))
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyInt_FromSize_t((256 * (sizeof(struct CountItem<2,float>)))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":3301
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemF2))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemF2)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecF2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemF2))
 *             k+=CHUNK_SIZE
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!((__pyx_t_8 == (256 * (sizeof(struct CountItem<2,float>)))) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":3302
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemF2))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemF2)
 *             memcpy(<void *>c_VecF2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemF2))             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), (256 * (sizeof(struct CountItem<2,float>))));

    /* "lurrn/sparsmat.pyx":3303
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemF2)
 *             memcpy(<void *>c_VecF2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemF2))
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemF2))
 */
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_k, __pyx_int_256); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_1);
    __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3304
 *             memcpy(<void *>c_VecF2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemF2))
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=f.read((n-k)*sizeof(c_CItemF2))
 *             assert len(s)==(n-k)*sizeof(c_CItemF2)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":3305
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemF2))             # <<<<<<<<<<<<<<
 *             assert len(s)==(n-k)*sizeof(c_CItemF2)
 *             memcpy(<void *>c_VecF2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemF2))
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_5, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<2,float>))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":3306
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemF2))
 *             assert len(s)==(n-k)*sizeof(c_CItemF2)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecF2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemF2))
 *     cpdef int get_maxcol(self, int k=0):
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<2,float>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_6)) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":3307
 *             s=f.read((n-k)*sizeof(c_CItemF2))
 *             assert len(s)==(n-k)*sizeof(c_CItemF2)
 *             memcpy(<void *>c_VecF2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemF2))             # <<<<<<<<<<<<<<
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<2,float>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), __pyx_t_11);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":3291
 *             s=PyString_FromStringAndSize(<char *>c_VecF2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemF2))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.fromfile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_line);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3308
 *             assert len(s)==(n-k)*sizeof(c_CItemF2)
 *             memcpy(<void *>c_VecF2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemF2))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<2
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecF2_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF2_get_maxcol *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_i;
  int __pyx_v_n;
  int __pyx_v_new_val;
  int __pyx_v_col;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_maxcol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_23get_maxcol)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3310
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<2             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         if n==0:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_9 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_9 = ((__pyx_v_k < 2) != 0);
    __pyx_t_8 = __pyx_t_9;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_8)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":3311
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<2
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         if n==0:
 *             return -1
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":3312
 *         assert k>=0 and k<2
 *         n=self.vec.size()
 *         if n==0:             # <<<<<<<<<<<<<<
 *             return -1
 *         if k==0:
 */
  __pyx_t_8 = ((__pyx_v_n == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":3313
 *         n=self.vec.size()
 *         if n==0:
 *             return -1             # <<<<<<<<<<<<<<
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 */
    __pyx_r = -1;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":3314
 *         if n==0:
 *             return -1
 *         if k==0:             # <<<<<<<<<<<<<<
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 */
  __pyx_t_8 = ((__pyx_v_k == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":3315
 *             return -1
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]             # <<<<<<<<<<<<<<
 *         col=-1
 *         n=self.vec.size()
 */
    __pyx_r = (__pyx_v_self->vec.at((__pyx_v_n - 1)).addr[0]);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":3316
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 *         col=-1             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_v_col = -1;

  /* "lurrn/sparsmat.pyx":3317
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":3318
 *         col=-1
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 */
  __pyx_t_7 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3319
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             if new_val>col:
 *                 col=new_val
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":3320
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:             # <<<<<<<<<<<<<<
 *                 col=new_val
 *         return col
 */
    __pyx_t_8 = ((__pyx_v_new_val > __pyx_v_col) != 0);
    if (__pyx_t_8) {

      /* "lurrn/sparsmat.pyx":3321
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 *                 col=new_val             # <<<<<<<<<<<<<<
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 */
      __pyx_v_col = __pyx_v_new_val;
      goto __pyx_L9;
    }
    __pyx_L9:;
  }

  /* "lurrn/sparsmat.pyx":3322
 *             if new_val>col:
 *                 col=new_val
 *         return col             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 *         cdef int old_val, new_val, i, n, count
 */
  __pyx_r = __pyx_v_col;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3308
 *             assert len(s)==(n-k)*sizeof(c_CItemF2)
 *             memcpy(<void *>c_VecF2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemF2))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecF2.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_maxcol (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_maxcol") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3308; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3308; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_maxcol", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3308; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2_22get_maxcol(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_22get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecF2_get_maxcol __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = __pyx_vtabptr_5lurrn_8sparsmat_VecF2->get_maxcol(__pyx_v_self, 1, &__pyx_t_2); 
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3323
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecF2_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF2_get_type_counts *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_new_val;
  int __pyx_v_i;
  int __pyx_v_n;
  PyArrayObject *__pyx_v_result = 0;
  long __pyx_v_n_types;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecF2_get_maxcol __pyx_t_11;
  PyArrayObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_25get_type_counts)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3326
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<2             # <<<<<<<<<<<<<<
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_8 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_k < 2) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_7)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":3327
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<2
 *         if self.vec.size()==0:             # <<<<<<<<<<<<<<
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 */
  __pyx_t_7 = ((__pyx_v_self->vec.size() == 0) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":3328
 *         assert k>=0 and k<2
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_9 = 1;
      }
    }
    __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_2) {
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":3329
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":3330
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1             # <<<<<<<<<<<<<<
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 */
  __pyx_t_11.__pyx_n = 1;
  __pyx_t_11.k = __pyx_v_k;
  __pyx_t_10 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF2 *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0, &__pyx_t_11); 
  __pyx_v_n_types = (__pyx_t_10 + 1);

  /* "lurrn/sparsmat.pyx":3331
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_n_types); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_9 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_6) {
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_12 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
    }
    __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_12 = 0;
  __pyx_v_result = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3332
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":3333
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3334
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             result[new_val]+=1
 *         return result
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":3335
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1             # <<<<<<<<<<<<<<
 *         return result
 *     cpdef VecF2 remap(self, int k, numpy.ndarray filt):
 */
    __pyx_t_16 = __pyx_v_new_val;
    __pyx_t_17 = -1;
    if (__pyx_t_16 < 0) {
      __pyx_t_16 += __pyx_pybuffernd_result.diminfo[0].shape;
      if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 0;
    } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_17 = 0;
    if (unlikely(__pyx_t_17 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_17);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_result.diminfo[0].strides) += 1;
  }

  /* "lurrn/sparsmat.pyx":3336
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 *         return result             # <<<<<<<<<<<<<<
 *     cpdef VecF2 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyArrayObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3323
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3323; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3323; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3323; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2_24get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_24get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecF2_get_type_counts __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_5lurrn_8sparsmat_VecF2->get_type_counts(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3337
 *             result[new_val]+=1
 *         return result
 *     cpdef VecF2 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_f_5lurrn_8sparsmat_5VecF2_remap(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_wanted = 0;
  PyArrayObject *__pyx_v_target = 0;
  int __pyx_v_n;
  int __pyx_v_i;
  struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_result = 0;
  struct CountItem<2,float> __pyx_v_c;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_target;
  __Pyx_Buffer __pyx_pybuffer_target;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_wanted;
  __Pyx_Buffer __pyx_pybuffer_wanted;
  struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __pyx_pybuffer_wanted.pybuffer.buf = NULL;
  __pyx_pybuffer_wanted.refcount = 0;
  __pyx_pybuffernd_wanted.data = NULL;
  __pyx_pybuffernd_wanted.rcbuffer = &__pyx_pybuffer_wanted;
  __pyx_pybuffer_target.pybuffer.buf = NULL;
  __pyx_pybuffer_target.refcount = 0;
  __pyx_pybuffernd_target.data = NULL;
  __pyx_pybuffernd_target.rcbuffer = &__pyx_pybuffer_target;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_remap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_27remap)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_filt));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_filt));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_filt));
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_VecF2))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3338
 *         return result
 *     cpdef VecF2 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_wanted = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_wanted.diminfo[0].strides = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_wanted.diminfo[0].shape = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_8 = 0;
  __pyx_v_wanted = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":3339
 *     cpdef VecF2 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_cumsum); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Subtract(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_target = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_target.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_target.diminfo[0].strides = __pyx_pybuffernd_target.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_target.diminfo[0].shape = __pyx_pybuffernd_target.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_9 = 0;
  __pyx_v_target = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3340
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         cdef int n=self.vec.size()
 *         cdef int i
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":3341
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()             # <<<<<<<<<<<<<<
 *         cdef int i
 *         cdef VecF2 result=VecF2()
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":3343
 *         cdef int n=self.vec.size()
 *         cdef int i
 *         cdef VecF2 result=VecF2()             # <<<<<<<<<<<<<<
 *         cdef c_CItemF2 c
 *         for i from 0<=i<n:
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3345
 *         cdef VecF2 result=VecF2()
 *         cdef c_CItemF2 c
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3346
 *         cdef c_CItemF2 c
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)             # <<<<<<<<<<<<<<
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 */
    __pyx_v_c = __pyx_v_self->vec.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":3347
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:             # <<<<<<<<<<<<<<
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 */
    __pyx_t_11 = (__pyx_v_c.addr[__pyx_v_k]);
    __pyx_t_12 = -1;
    if (__pyx_t_11 < 0) {
      __pyx_t_11 += __pyx_pybuffernd_wanted.diminfo[0].shape;
      if (unlikely(__pyx_t_11 < 0)) __pyx_t_12 = 0;
    } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_wanted.diminfo[0].shape)) __pyx_t_12 = 0;
    if (unlikely(__pyx_t_12 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_12);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_wanted.diminfo[0].strides)) != 0);
    if (__pyx_t_13) {

      /* "lurrn/sparsmat.pyx":3348
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c)
 *         return result
 */
      __pyx_t_12 = (__pyx_v_c.addr[__pyx_v_k]);
      __pyx_t_14 = -1;
      if (__pyx_t_12 < 0) {
        __pyx_t_12 += __pyx_pybuffernd_target.diminfo[0].shape;
        if (unlikely(__pyx_t_12 < 0)) __pyx_t_14 = 0;
      } else if (unlikely(__pyx_t_12 >= __pyx_pybuffernd_target.diminfo[0].shape)) __pyx_t_14 = 0;
      if (unlikely(__pyx_t_14 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_14);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      (__pyx_v_c.addr[__pyx_v_k]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_target.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_target.diminfo[0].strides));

      /* "lurrn/sparsmat.pyx":3349
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         return result
 *     def append(self,tup):
 */
      __pyx_v_result->vec.push_back(__pyx_v_c);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "lurrn/sparsmat.pyx":3350
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 *         return result             # <<<<<<<<<<<<<<
 *     def append(self,tup):
 *         k0,k1,val=tup
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3337
 *             result[new_val]+=1
 *         return result
 *     cpdef VecF2 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_wanted);
  __Pyx_XDECREF((PyObject *)__pyx_v_target);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3337; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3337; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3337; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_filt = ((PyArrayObject *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3337; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_filt), __pyx_ptype_5numpy_ndarray, 1, "filt", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2_26remap(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_26remap(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_5VecF2_remap(__pyx_v_self, __pyx_v_k, __pyx_v_filt, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3351
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,k1,val=tup
 *         self.c_add(k0,k1,val)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_29append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_29append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("append (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2_28append(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self), ((PyObject *)__pyx_v_tup));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_28append(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_k1 = NULL;
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *(*__pyx_t_5)(PyObject *);
  coordinate_t __pyx_t_6;
  coordinate_t __pyx_t_7;
  float __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("append", 0);

  /* "lurrn/sparsmat.pyx":3352
 *         return result
 *     def append(self,tup):
 *         k0,k1,val=tup             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1,val)
 *     def extend(self,tups):
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_tup))) || (PyList_CheckExact(__pyx_v_tup))) {
    PyObject* sequence = __pyx_v_tup;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    #endif
  } else {
    Py_ssize_t index = -1;
    __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 2; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_k0 = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_k1 = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_val = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "lurrn/sparsmat.pyx":3353
 *     def append(self,tup):
 *         k0,k1,val=tup
 *         self.c_add(k0,k1,val)             # <<<<<<<<<<<<<<
 *     def extend(self,tups):
 *         for k0,k1,val in tups:
 */
  __pyx_t_6 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_6 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k1); if (unlikely((__pyx_t_7 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_v_val); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF2 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_6, __pyx_t_7, __pyx_t_8);

  /* "lurrn/sparsmat.pyx":3351
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,k1,val=tup
 *         self.c_add(k0,k1,val)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_k1);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3354
 *         k0,k1,val=tup
 *         self.c_add(k0,k1,val)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,k1,val in tups:
 *             self.c_add(k0,k1,val)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_31extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_31extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extend (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2_30extend(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self), ((PyObject *)__pyx_v_tups));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_30extend(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_k1 = NULL;
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  coordinate_t __pyx_t_10;
  coordinate_t __pyx_t_11;
  float __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("extend", 0);

  /* "lurrn/sparsmat.pyx":3355
 *         self.c_add(k0,k1,val)
 *     def extend(self,tups):
 *         for k0,k1,val in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,k1,val)
 *     def __iter__(self):
 */
  if (likely(PyList_CheckExact(__pyx_v_tups)) || PyTuple_CheckExact(__pyx_v_tups)) {
    __pyx_t_1 = __pyx_v_tups; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_tups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_8 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      index = 2; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_9 = NULL;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_k0, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_k1, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "lurrn/sparsmat.pyx":3356
 *     def extend(self,tups):
 *         for k0,k1,val in tups:
 *             self.c_add(k0,k1,val)             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self.item_iter()
 */
    __pyx_t_10 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_10 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k1); if (unlikely((__pyx_t_11 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_12 = __pyx_PyFloat_AsFloat(__pyx_v_val); if (unlikely((__pyx_t_12 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF2 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_10, __pyx_t_11, __pyx_t_12);

    /* "lurrn/sparsmat.pyx":3355
 *         self.c_add(k0,k1,val)
 *     def extend(self,tups):
 *         for k0,k1,val in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,k1,val)
 *     def __iter__(self):
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3354
 *         k0,k1,val=tup
 *         self.c_add(k0,k1,val)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,k1,val in tups:
 *             self.c_add(k0,k1,val)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.extend", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_k1);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3357
 *         for k0,k1,val in tups:
 *             self.c_add(k0,k1,val)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_33__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_33__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2_32__iter__(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_32__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":3358
 *             self.c_add(k0,k1,val)
 *     def __iter__(self):
 *         return self.item_iter()             # <<<<<<<<<<<<<<
 *     def __reduce__(self):
 *         return (VecF2,(),(),self.item_iter())
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3357
 *         for k0,k1,val in tups:
 *             self.c_add(k0,k1,val)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3359
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecF2,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_35__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_35__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2_34__reduce__(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_34__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "lurrn/sparsmat.pyx":3360
 *         return self.item_iter()
 *     def __reduce__(self):
 *         return (VecF2,(),(),self.item_iter())             # <<<<<<<<<<<<<<
 *     def __setstate__(self,state):
 *         pass
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF2)));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF2)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF2)));
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3359
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecF2,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3361
 *     def __reduce__(self):
 *         return (VecF2,(),(),self.item_iter())
 *     def __setstate__(self,state):             # <<<<<<<<<<<<<<
 *         pass
 *     def __repr__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_37__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_37__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2_36__setstate__(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self), ((PyObject *)__pyx_v_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_36__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3363
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecF2(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_39__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF2_39__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF2_38__repr__(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF2_38__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "lurrn/sparsmat.pyx":3364
 *         pass
 *     def __repr__(self):
 *         return 'VecF2(%s)'%(str(list(self)),)             # <<<<<<<<<<<<<<
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_VecF2_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3363
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecF2(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF2.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3365
 *     def __repr__(self):
 *         return 'VecF2(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

/* Python wrapper */
static void __pyx_pw_5lurrn_8sparsmat_5VecF2_41__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5lurrn_8sparsmat_5VecF2_41__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5lurrn_8sparsmat_5VecF2_40__dealloc__(((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5lurrn_8sparsmat_5VecF2_40__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lurrn/sparsmat.pyx":3367
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()             # <<<<<<<<<<<<<<
 * 
 * cdef class IVecF2_iter:
 */
  __pyx_v_self->vec.~vector();

  /* "lurrn/sparsmat.pyx":3365
 *     def __repr__(self):
 *         return 'VecF2(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":3373
 *     cdef c_VecF2 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_11IVecF2_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_11IVecF2_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_vec = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_vec,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3373; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_vec = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3373; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.IVecF2_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecF2_iter___init__(((struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter *)__pyx_v_self), __pyx_v_vec);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_11IVecF2_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter *__pyx_v_self, PyObject *__pyx_v_vec) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":3374
 *     cdef unsigned int k
 *     def __init__(self,vec):
 *         self.vec=vec             # <<<<<<<<<<<<<<
 *         self.vecC=&self.vec.vec
 *         self.k=0
 */
  if (!(likely(((__pyx_v_vec) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_vec, __pyx_ptype_5lurrn_8sparsmat_VecF2))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_vec;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->vec);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->vec));
  __pyx_v_self->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3375
 *     def __init__(self,vec):
 *         self.vec=vec
 *         self.vecC=&self.vec.vec             # <<<<<<<<<<<<<<
 *         self.k=0
 *     def __iter__(self):
 */
  __pyx_v_self->vecC = (&__pyx_v_self->vec->vec);

  /* "lurrn/sparsmat.pyx":3376
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 *         self.k=0             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self
 */
  __pyx_v_self->k = 0;

  /* "lurrn/sparsmat.pyx":3373
 *     cdef c_VecF2 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecF2_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3377
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecF2_iter_3__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecF2_iter_3__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecF2_iter_2__iter__(((struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecF2_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":3378
 *         self.k=0
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3377
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3379
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecF2_iter_5__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecF2_iter_5__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecF2_iter_4__next__(((struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecF2_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter *__pyx_v_self) {
  struct CountItem<2,float> __pyx_v_res;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "lurrn/sparsmat.pyx":3380
 *         return self
 *     def __next__(self):
 *         if self.k>=self.vecC.size():             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         cdef c_CItemF2 res=self.vecC.at(self.k)
 */
  __pyx_t_1 = ((__pyx_v_self->k >= __pyx_v_self->vecC->size()) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":3381
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         cdef c_CItemF2 res=self.vecC.at(self.k)
 *         self.k+=1
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lurrn/sparsmat.pyx":3382
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 *         cdef c_CItemF2 res=self.vecC.at(self.k)             # <<<<<<<<<<<<<<
 *         self.k+=1
 *         return (res.addr[0],
 */
  __pyx_v_res = __pyx_v_self->vecC->at(__pyx_v_self->k);

  /* "lurrn/sparsmat.pyx":3383
 *             raise StopIteration
 *         cdef c_CItemF2 res=self.vecC.at(self.k)
 *         self.k+=1             # <<<<<<<<<<<<<<
 *         return (res.addr[0],
 *                 res.addr[1],
 */
  __pyx_v_self->k = (__pyx_v_self->k + 1);

  /* "lurrn/sparsmat.pyx":3384
 *         cdef c_CItemF2 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.addr[1],
 *                 res.item)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_res.addr[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "lurrn/sparsmat.pyx":3385
 *         self.k+=1
 *         return (res.addr[0],
 *                 res.addr[1],             # <<<<<<<<<<<<<<
 *                 res.item)
 * 
 */
  __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_res.addr[1])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "lurrn/sparsmat.pyx":3386
 *         return (res.addr[0],
 *                 res.addr[1],
 *                 res.item)             # <<<<<<<<<<<<<<
 * 
 * cdef class LargeVecF2:
 */
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_res.item); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":3384
 *         cdef c_CItemF2 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.addr[1],
 *                 res.item)
 */
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3379
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecF2_iter.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3391
 *     cdef public object compact
 *     cdef public VecF2 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecF2()
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF2_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF2_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF2___init__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF2___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":3392
 *     cdef public VecF2 loose
 *     def __init__(self):
 *         self.compact=[]             # <<<<<<<<<<<<<<
 *         self.loose=VecF2()
 *         self.loose.vec.reserve(100000)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3393
 *     def __init__(self):
 *         self.compact=[]
 *         self.loose=VecF2()             # <<<<<<<<<<<<<<
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3394
 *         self.compact=[]
 *         self.loose=VecF2()
 *         self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 */
  __pyx_v_self->loose->vec.reserve(100000);

  /* "lurrn/sparsmat.pyx":3391
 *     cdef public object compact
 *     cdef public VecF2 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecF2()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF2.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3395
 *         self.loose=VecF2()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ensure_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_2ensure_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":3396
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *         self.loose=VecF2()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":3397
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *         self.loose=VecF2()
 *         while len(self.compact)>=2:
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":3398
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 *         self.loose=VecF2()             # <<<<<<<<<<<<<<
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":3399
 *             self.compact.append(self.loose)
 *         self.loose=VecF2()
 *         while len(self.compact)>=2:             # <<<<<<<<<<<<<<
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 */
  while (1) {
    __pyx_t_2 = __pyx_v_self->compact;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = ((__pyx_t_6 >= 2) != 0);
    if (!__pyx_t_4) break;

    /* "lurrn/sparsmat.pyx":3400
 *         self.loose=VecF2()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.loose.c_add(k0,k1, item)
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3400; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3400; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_1, -2, 0, NULL, NULL, &__pyx_slice__37, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3395
 *         self.loose=VecF2()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF2.ensure_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3401
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0,k1, item)
 *         if self.loose.get_size(False)>=100000:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  PyObject *__pyx_v_item = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,&__pyx_n_s_item,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3401; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_item);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3401; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3401; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3401; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_item = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3401; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF2.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_4add_count(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1, __pyx_v_item);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  float __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":3402
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.loose.c_add(k0,k1, item)             # <<<<<<<<<<<<<<
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 */
  __pyx_t_1 = __pyx_PyFloat_AsFloat(__pyx_v_item); if (unlikely((__pyx_t_1 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF2 *)__pyx_v_self->loose->__pyx_vtab)->c_add(__pyx_v_self->loose, __pyx_v_k0, __pyx_v_k1, __pyx_t_1);

  /* "lurrn/sparsmat.pyx":3403
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.loose.c_add(k0,k1, item)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_int_100000, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":3404
 *         self.loose.c_add(k0,k1, item)
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *             self.loose=VecF2()
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF2 *)__pyx_v_self->loose->__pyx_vtab)->ensure_compact(__pyx_v_self->loose);

    /* "lurrn/sparsmat.pyx":3405
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *             self.loose=VecF2()
 *             self.loose.vec.reserve(100000)
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lurrn/sparsmat.pyx":3406
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 *             self.loose=VecF2()             # <<<<<<<<<<<<<<
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 */
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->loose);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
    __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":3407
 *             self.compact.append(self.loose)
 *             self.loose=VecF2()
 *             self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 */
    __pyx_v_self->loose->vec.reserve(100000);

    /* "lurrn/sparsmat.pyx":3408
 *             self.loose=VecF2()
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and             # <<<<<<<<<<<<<<
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
    while (1) {
      __pyx_t_2 = __pyx_v_self->compact;
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_7 = ((__pyx_t_6 >= 2) != 0);
      if (__pyx_t_7) {
      } else {
        __pyx_t_4 = __pyx_t_7;
        goto __pyx_L6_bool_binop_done;
      }

      /* "lurrn/sparsmat.pyx":3409
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):             # <<<<<<<<<<<<<<
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 */
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3409; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3409; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyNumber_Multiply(__pyx_float_0_6, __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_2, __pyx_t_9, Py_GE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_4 = __pyx_t_7;
      __pyx_L6_bool_binop_done:;
      if (!__pyx_t_4) break;

      /* "lurrn/sparsmat.pyx":3410
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3410; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3410; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = PyNumber_Add(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyList_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_9, -2, 0, NULL, NULL, &__pyx_slice__39, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":3401
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0,k1, item)
 *         if self.loose.get_size(False)>=100000:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF2.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3411
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_6get_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_compact", 0);

  /* "lurrn/sparsmat.pyx":3412
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         if len(self.compact)>0:
 *             return self.compact[0]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3413
 *     def get_compact(self):
 *         self.ensure_compact()
 *         if len(self.compact)>0:             # <<<<<<<<<<<<<<
 *             return self.compact[0]
 *         else:
 */
  __pyx_t_1 = __pyx_v_self->compact;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((__pyx_t_4 > 0) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":3414
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 *             return self.compact[0]             # <<<<<<<<<<<<<<
 *         else:
 *             return VecF2()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3414; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":3416
 *             return self.compact[0]
 *         else:
 *             return VecF2()             # <<<<<<<<<<<<<<
 *     def get_size(self, compactify=True):
 *         cdef int n
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":3411
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF2.get_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3417
 *         else:
 *             return VecF2()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3417; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3417; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF2.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_8get_size(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  int __pyx_v_n;
  PyObject *__pyx_v_c = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":3419
 *     def get_size(self, compactify=True):
 *         cdef int n
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *             if self.compact:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":3420
 *         cdef int n
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *             if self.compact:
 *                 return self.compact[0].get_size()
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":3421
 *         if compactify:
 *             self.ensure_compact()
 *             if self.compact:             # <<<<<<<<<<<<<<
 *                 return self.compact[0].get_size()
 *             else:
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->compact); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":3422
 *             self.ensure_compact()
 *             if self.compact:
 *                 return self.compact[0].get_size()             # <<<<<<<<<<<<<<
 *             else:
 *                 return 0
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3422; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":3424
 *                 return self.compact[0].get_size()
 *             else:
 *                 return 0             # <<<<<<<<<<<<<<
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_int_0);
      __pyx_r = __pyx_int_0;
      goto __pyx_L0;
    }
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":3426
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_v_self->compact)) || PyTuple_CheckExact(__pyx_v_self->compact)) {
      __pyx_t_4 = __pyx_v_self->compact; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_self->compact); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_get_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":3427
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":3428
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)
 *             return n             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         self.ensure_compact()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":3417
 *         else:
 *             return VecF2()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF2.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_c);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3429
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_11__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_11__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_10__iter__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":3430
 *             return n
 *     def __iter__(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         try:
 *             return iter(self.compact[0])
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3431
 *     def __iter__(self):
 *         self.ensure_compact()
 *         try:             # <<<<<<<<<<<<<<
 *             return iter(self.compact[0])
 *         except IndexError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "lurrn/sparsmat.pyx":3432
 *         self.ensure_compact()
 *         try:
 *             return iter(self.compact[0])             # <<<<<<<<<<<<<<
 *         except IndexError:
 *             return iter([])
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3432; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3432; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L7_try_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":3433
 *         try:
 *             return iter(self.compact[0])
 *         except IndexError:             # <<<<<<<<<<<<<<
 *             return iter([])
 * 
 */
    __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_IndexError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF2.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3433; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_3);

      /* "lurrn/sparsmat.pyx":3434
 *             return iter(self.compact[0])
 *         except IndexError:
 *             return iter([])             # <<<<<<<<<<<<<<
 * 
 *     cpdef CSRMatrixF to_csr(self):
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3434; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3434; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_r = __pyx_t_9;
      __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":3429
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF2.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3436
 *             return iter([])
 * 
 *     cpdef CSRMatrixF to_csr(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return self.compact[0].to_csr()
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_13to_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_f_5lurrn_8sparsmat_10LargeVecF2_to_csr(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self, int __pyx_skip_dispatch) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_csr", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_to_csr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_13to_csr)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3437
 * 
 *     cpdef CSRMatrixF to_csr(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return self.compact[0].to_csr()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3438
 *     cpdef CSRMatrixF to_csr(self):
 *         self.ensure_compact()
 *         return self.compact[0].to_csr()             # <<<<<<<<<<<<<<
 * 
 *     def get_type_counts(self, k=0):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3438; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_to_csr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3436
 *             return iter([])
 * 
 *     cpdef CSRMatrixF to_csr(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return self.compact[0].to_csr()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF2.to_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_13to_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_13to_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_csr (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_12to_csr(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_12to_csr(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_csr", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10LargeVecF2_to_csr(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF2.to_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3440
 *         return self.compact[0].to_csr()
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_15get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_15get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3440; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3440; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_14get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_14get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);

  /* "lurrn/sparsmat.pyx":3441
 * 
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)             # <<<<<<<<<<<<<<
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_k);
    __Pyx_GIVEREF(__pyx_v_k);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3440
 *         return self.compact[0].to_csr()
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3442
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_17remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_17remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  PyObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3442; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3442; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = values[0];
    __pyx_v_filt = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3442; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_16remap(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_16remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);

  /* "lurrn/sparsmat.pyx":3443
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_remap); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_v_k);
  PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_k);
  __Pyx_GIVEREF(__pyx_v_k);
  __Pyx_INCREF(__pyx_v_filt);
  PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_filt);
  __Pyx_GIVEREF(__pyx_v_filt);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3442
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3389
 * 
 * cdef class LargeVecF2:
 *     cdef public object compact             # <<<<<<<<<<<<<<
 *     cdef public VecF2 loose
 *     def __init__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_7compact_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_7compact_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_7compact___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->compact);
  __pyx_r = __pyx_v_self->compact;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF2_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF2_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_7compact_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF2_7compact_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF2_7compact_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_7compact_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3390
 * cdef class LargeVecF2:
 *     cdef public object compact
 *     cdef public VecF2 loose             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *         self.compact=[]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_5loose_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_5loose_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_5loose___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF2_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->loose));
  __pyx_r = ((PyObject *)__pyx_v_self->loose);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF2_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF2_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_5loose_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5lurrn_8sparsmat_VecF2))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF2.loose.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF2_5loose_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF2_5loose_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_5loose_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF2_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3450
 * cdef class VecF3:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_5VecF3_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_5VecF3_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF3___init__(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_5VecF3___init__(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":3451
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     def item_iter(self):
 *         self.ensure_compact()
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":3450
 * cdef class VecF3:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3452
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecF3_iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("item_iter (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF3_2item_iter(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("item_iter", 0);

  /* "lurrn/sparsmat.pyx":3453
 *         self.is_compact=True
 *     def item_iter(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return IVecF3_iter(self)
 *     def get_size(self,compactify=True):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":3454
 *     def item_iter(self):
 *         self.ensure_compact()
 *         return IVecF3_iter(self)             # <<<<<<<<<<<<<<
 *     def get_size(self,compactify=True):
 *         if compactify:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_IVecF3_iter)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3452
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecF3_iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.item_iter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3455
 *         self.ensure_compact()
 *         return IVecF3_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3455; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3455; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF3_4get_size(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":3456
 *         return IVecF3_iter(self)
 *     def get_size(self,compactify=True):
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *         return self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":3457
 *     def get_size(self,compactify=True):
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return self.vec.size()
 *     def __len__(self):
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":3458
 *         if compactify:
 *             self.ensure_compact()
 *         return self.vec.size()             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return self.get_size(True)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_self->vec.size()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3455
 *         self.ensure_compact()
 *         return IVecF3_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3459
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecF3_7__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecF3_7__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF3_6__len__(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecF3_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":3460
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3459
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3461
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF3_8clear(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear", 0);

  /* "lurrn/sparsmat.pyx":3462
 *         return self.get_size(True)
 *     def clear(self):
 *         self.vec.resize(0)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void compactify(self):
 */
  __pyx_v_self->vec.resize(0);

  /* "lurrn/sparsmat.pyx":3463
 *     def clear(self):
 *         self.vec.resize(0)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrF3 comp
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":3461
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3464
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrF3 comp
 *         c_IVecF3_sort(self.vec.begin(),self.vec.end(),comp)
 */

static void __pyx_f_5lurrn_8sparsmat_5VecF3_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self) {
  struct smallerAddr<3,float> __pyx_v_comp;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compactify", 0);

  /* "lurrn/sparsmat.pyx":3466
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrF3 comp
 *         c_IVecF3_sort(self.vec.begin(),self.vec.end(),comp)             # <<<<<<<<<<<<<<
 *         c_compactifyF3(&self.vec)
 *         self.is_compact=True
 */
  sort(__pyx_v_self->vec.begin(), __pyx_v_self->vec.end(), __pyx_v_comp);

  /* "lurrn/sparsmat.pyx":3467
 *         cdef c_SmallerAddrF3 comp
 *         c_IVecF3_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyF3(&self.vec)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 */
  compactify((&__pyx_v_self->vec));

  /* "lurrn/sparsmat.pyx":3468
 *         c_IVecF3_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyF3(&self.vec)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":3464
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrF3 comp
 *         c_IVecF3_sort(self.vec.begin(),self.vec.end(),comp)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":3469
 *         c_compactifyF3(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

static void __pyx_f_5lurrn_8sparsmat_5VecF3_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":3470
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:             # <<<<<<<<<<<<<<
 *             self.compactify()
 *     cpdef float get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):
 */
  __pyx_t_1 = ((!(__pyx_v_self->is_compact != 0)) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":3471
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 *             self.compactify()             # <<<<<<<<<<<<<<
 *     cpdef float get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):
 *         cdef c_CItemF3 ci
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF3 *)__pyx_v_self->__pyx_vtab)->compactify(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":3469
 *         c_compactifyF3(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":3472
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef float get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF3 ci
 *         ci.addr[0]=k0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static float __pyx_f_5lurrn_8sparsmat_5VecF3_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, int __pyx_skip_dispatch) {
  struct CountItem<3,float> __pyx_v_ci;
  float __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  float __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF3_11get_count)) {
      __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_6 = __pyx_t_1; __pyx_t_7 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
          __pyx_t_8 = 1;
        }
      }
      __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_5 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_10 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_10 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_10;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3474
 *     cpdef float get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):
 *         cdef c_CItemF3 ci
 *         ci.addr[0]=k0             # <<<<<<<<<<<<<<
 *         ci.addr[1]=k1
 *         ci.addr[2]=k2
 */
  (__pyx_v_ci.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":3475
 *         cdef c_CItemF3 ci
 *         ci.addr[0]=k0
 *         ci.addr[1]=k1             # <<<<<<<<<<<<<<
 *         ci.addr[2]=k2
 *         return c_get_countF3(&self.vec,ci)
 */
  (__pyx_v_ci.addr[1]) = __pyx_v_k1;

  /* "lurrn/sparsmat.pyx":3476
 *         ci.addr[0]=k0
 *         ci.addr[1]=k1
 *         ci.addr[2]=k2             # <<<<<<<<<<<<<<
 *         return c_get_countF3(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, float item):
 */
  (__pyx_v_ci.addr[2]) = __pyx_v_k2;

  /* "lurrn/sparsmat.pyx":3477
 *         ci.addr[1]=k1
 *         ci.addr[2]=k2
 *         return c_get_countF3(&self.vec,ci)             # <<<<<<<<<<<<<<
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, float item):
 *         cdef c_CItemF3 c
 */
  __pyx_r = get_count_v((&__pyx_v_self->vec), __pyx_v_ci);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3472
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef float get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF3 ci
 *         ci.addr[0]=k0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecF3.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,&__pyx_n_s_k2,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_count", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_count", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k2 = __Pyx_PyInt_As_coordinate_t(values[2]); if (unlikely((__pyx_v_k2 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_count", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF3_10get_count(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1, __pyx_v_k2);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_5VecF3_get_count(__pyx_v_self, __pyx_v_k0, __pyx_v_k1, __pyx_v_k2, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3478
 *         ci.addr[2]=k2
 *         return c_get_countF3(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, float item):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF3 c
 *         c.addr[0]=k0
 */

static void __pyx_f_5lurrn_8sparsmat_5VecF3_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, float __pyx_v_item) {
  struct CountItem<3,float> __pyx_v_c;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_add", 0);

  /* "lurrn/sparsmat.pyx":3480
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, float item):
 *         cdef c_CItemF3 c
 *         c.addr[0]=k0             # <<<<<<<<<<<<<<
 *         c.addr[1]=k1
 *         c.addr[2]=k2
 */
  (__pyx_v_c.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":3481
 *         cdef c_CItemF3 c
 *         c.addr[0]=k0
 *         c.addr[1]=k1             # <<<<<<<<<<<<<<
 *         c.addr[2]=k2
 *         c.item=item
 */
  (__pyx_v_c.addr[1]) = __pyx_v_k1;

  /* "lurrn/sparsmat.pyx":3482
 *         c.addr[0]=k0
 *         c.addr[1]=k1
 *         c.addr[2]=k2             # <<<<<<<<<<<<<<
 *         c.item=item
 *         self.vec.push_back(c)
 */
  (__pyx_v_c.addr[2]) = __pyx_v_k2;

  /* "lurrn/sparsmat.pyx":3483
 *         c.addr[1]=k1
 *         c.addr[2]=k2
 *         c.item=item             # <<<<<<<<<<<<<<
 *         self.vec.push_back(c)
 *         self.is_compact=False
 */
  __pyx_v_c.item = __pyx_v_item;

  /* "lurrn/sparsmat.pyx":3484
 *         c.addr[2]=k2
 *         c.item=item
 *         self.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 */
  __pyx_v_self->vec.push_back(__pyx_v_c);

  /* "lurrn/sparsmat.pyx":3485
 *         c.item=item
 *         self.vec.push_back(c)
 *         self.is_compact=False             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.c_add(k0,k1,k2, item)
 */
  __pyx_v_self->is_compact = 0;

  /* "lurrn/sparsmat.pyx":3478
 *         ci.addr[2]=k2
 *         return c_get_countF3(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, float item):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF3 c
 *         c.addr[0]=k0
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":3486
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1,k2, item)
 *     def __add__(VecF3 self, VecF3 other):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  PyObject *__pyx_v_item = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,&__pyx_n_s_k2,&__pyx_n_s_item,0};
    PyObject* values[4] = {0,0,0,0};
    values[3] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 0, 3, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3486; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 0, 3, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3486; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_item);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3486; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3486; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3486; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k2 = __Pyx_PyInt_As_coordinate_t(values[2]); if (unlikely((__pyx_v_k2 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3486; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_item = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3486; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF3_12add_count(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1, __pyx_v_k2, __pyx_v_item);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  float __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":3487
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.c_add(k0,k1,k2, item)             # <<<<<<<<<<<<<<
 *     def __add__(VecF3 self, VecF3 other):
 *         cdef c_CItemF3 c1, c2
 */
  __pyx_t_1 = __pyx_PyFloat_AsFloat(__pyx_v_item); if (unlikely((__pyx_t_1 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF3 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_v_k0, __pyx_v_k1, __pyx_v_k2, __pyx_t_1);

  /* "lurrn/sparsmat.pyx":3486
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1,k2, item)
 *     def __add__(VecF3 self, VecF3 other):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3488
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.c_add(k0,k1,k2, item)
 *     def __add__(VecF3 self, VecF3 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF3 c1, c2
 *         cdef unsigned int i1, i2
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_VecF3, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_VecF3, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF3_14__add__(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_other) {
  struct CountItem<3,float> __pyx_v_c1;
  struct CountItem<3,float> __pyx_v_c2;
  unsigned int __pyx_v_i1;
  unsigned int __pyx_v_i2;
  int __pyx_v_k;
  int __pyx_v_delta;
  struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":3493
 *         cdef int k, delta
 *         cdef VecF3 result
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         other.ensure_compact()
 *         result=VecF3()
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":3494
 *         cdef VecF3 result
 *         self.ensure_compact()
 *         other.ensure_compact()             # <<<<<<<<<<<<<<
 *         result=VecF3()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF3 *)__pyx_v_other->__pyx_vtab)->ensure_compact(__pyx_v_other);

  /* "lurrn/sparsmat.pyx":3495
 *         self.ensure_compact()
 *         other.ensure_compact()
 *         result=VecF3()             # <<<<<<<<<<<<<<
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3496
 *         other.ensure_compact()
 *         result=VecF3()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))             # <<<<<<<<<<<<<<
 *         i1=0
 *         i2=0
 */
  __pyx_t_2 = __pyx_v_other->vec.size();
  __pyx_t_3 = __pyx_v_self->vec.size();
  if (((__pyx_t_2 > __pyx_t_3) != 0)) {
    __pyx_t_4 = __pyx_t_2;
  } else {
    __pyx_t_4 = __pyx_t_3;
  }
  __pyx_v_result->vec.reserve(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":3497
 *         result=VecF3()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0             # <<<<<<<<<<<<<<
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 */
  __pyx_v_i1 = 0;

  /* "lurrn/sparsmat.pyx":3498
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 *         i2=0             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 */
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":3499
 *         i1=0
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 */
  while (1) {
    __pyx_t_6 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_6 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":3500
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             delta=0
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":3501
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             delta=0
 *             for k from 0<=k<3:
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":3502
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 *             delta=0             # <<<<<<<<<<<<<<
 *             for k from 0<=k<3:
 *                 if c1.addr[k]<c2.addr[k]:
 */
    __pyx_v_delta = 0;

    /* "lurrn/sparsmat.pyx":3503
 *             c2=other.vec.at(i2)
 *             delta=0
 *             for k from 0<=k<3:             # <<<<<<<<<<<<<<
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 */
    for (__pyx_v_k = 0; __pyx_v_k < 3; __pyx_v_k++) {

      /* "lurrn/sparsmat.pyx":3504
 *             delta=0
 *             for k from 0<=k<3:
 *                 if c1.addr[k]<c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=-1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) < (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":3505
 *             for k from 0<=k<3:
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1             # <<<<<<<<<<<<<<
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 */
        __pyx_v_delta = -1;

        /* "lurrn/sparsmat.pyx":3506
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 *                     break             # <<<<<<<<<<<<<<
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 */
        goto __pyx_L8_break;
      }

      /* "lurrn/sparsmat.pyx":3507
 *                     delta=-1
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) > (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":3508
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1             # <<<<<<<<<<<<<<
 *                     break
 *             if delta==0:
 */
        __pyx_v_delta = 1;

        /* "lurrn/sparsmat.pyx":3509
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 *                     break             # <<<<<<<<<<<<<<
 *             if delta==0:
 *                 c1.item+=c2.item
 */
        goto __pyx_L8_break;
      }
    }
    __pyx_L8_break:;

    /* "lurrn/sparsmat.pyx":3515
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
    switch (__pyx_v_delta) {

      /* "lurrn/sparsmat.pyx":3510
 *                     delta=1
 *                     break
 *             if delta==0:             # <<<<<<<<<<<<<<
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)
 */
      case 0:

      /* "lurrn/sparsmat.pyx":3511
 *                     break
 *             if delta==0:
 *                 c1.item+=c2.item             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      __pyx_v_c1.item = (__pyx_v_c1.item + __pyx_v_c2.item);

      /* "lurrn/sparsmat.pyx":3512
 *             if delta==0:
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *                 i2+=1
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":3513
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *                 i2+=1
 *             elif delta==-1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);

      /* "lurrn/sparsmat.pyx":3514
 *                 result.vec.push_back(c1)
 *                 i1+=1
 *                 i2+=1             # <<<<<<<<<<<<<<
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;

      /* "lurrn/sparsmat.pyx":3515
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      case -1:

      /* "lurrn/sparsmat.pyx":3516
 *                 i2+=1
 *             elif delta==-1:
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             else:
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":3517
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             else:
 *                 result.vec.push_back(c2)
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      break;
      default:

      /* "lurrn/sparsmat.pyx":3519
 *                 i1+=1
 *             else:
 *                 result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *                 i2+=1
 *         while i1<self.vec.size():
 */
      __pyx_v_result->vec.push_back(__pyx_v_c2);

      /* "lurrn/sparsmat.pyx":3520
 *             else:
 *                 result.vec.push_back(c2)
 *                 i2+=1             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;
    }
  }

  /* "lurrn/sparsmat.pyx":3521
 *                 result.vec.push_back(c2)
 *                 i2+=1
 *         while i1<self.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":3522
 *                 i2+=1
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c1)
 *             i1+=1
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":3523
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *             i1+=1
 *         while i2<other.vec.size():
 */
    __pyx_v_result->vec.push_back(__pyx_v_c1);

    /* "lurrn/sparsmat.pyx":3524
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 *             i1+=1             # <<<<<<<<<<<<<<
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);
  }

  /* "lurrn/sparsmat.pyx":3525
 *             result.vec.push_back(c1)
 *             i1+=1
 *         while i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":3526
 *             i1+=1
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c2)
 *             i2+=1
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":3527
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *             i2+=1
 *         return result
 */
    __pyx_v_result->vec.push_back(__pyx_v_c2);

    /* "lurrn/sparsmat.pyx":3528
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 *             i2+=1             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_v_i2 = (__pyx_v_i2 + 1);
  }

  /* "lurrn/sparsmat.pyx":3529
 *             result.vec.push_back(c2)
 *             i2+=1
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def tofile(self, f):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3488
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.c_add(k0,k1,k2, item)
 *     def __add__(VecF3 self, VecF3 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemF3 c1, c2
 *         cdef unsigned int i1, i2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3531
 *         return result
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_17tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_17tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tofile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF3_16tofile(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_16tofile(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  long __pyx_v_k;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  long __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("tofile", 0);

  /* "lurrn/sparsmat.pyx":3533
 *     def tofile(self, f):
 *         cdef long i, n, k, k_max
 *         n=self.get_size()             # <<<<<<<<<<<<<<
 *         f.write('F3 %d\n'%(n,))
 *         k=0
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":3534
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 *         f.write('F3 %d\n'%(n,))             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_F3_d, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3535
 *         n=self.get_size()
 *         f.write('F3 %d\n'%(n,))
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecF3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemF3))
 */
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":3536
 *         f.write('F3 %d\n'%(n,))
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecF3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemF3))
 *             f.write(s)
 */
  __pyx_t_4 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3537
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecF3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemF3))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *             k+=CHUNK_SIZE
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), (256 * (sizeof(struct CountItem<3,float>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":3538
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecF3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemF3))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":3539
 *             s=PyString_FromStringAndSize(<char *>c_VecF3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemF3))
 *             f.write(s)
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecF3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemF3))
 */
    __pyx_v_k = (__pyx_v_k + 256);
  }

  /* "lurrn/sparsmat.pyx":3540
 *             f.write(s)
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecF3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemF3))
 *             f.write(s)
 */
  __pyx_t_7 = ((__pyx_v_k < __pyx_v_n) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":3541
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecF3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemF3))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *     def fromfile(self, f):
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), ((__pyx_v_n - __pyx_v_k) * (sizeof(struct CountItem<3,float>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":3542
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecF3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemF3))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *     def fromfile(self, f):
 *         cdef long i, n
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":3531
 *         return result
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.tofile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3543
 *             s=PyString_FromStringAndSize(<char *>c_VecF3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemF3))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_19fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_19fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fromfile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF3_18fromfile(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_18fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  PyObject *__pyx_v_line = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  long __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  size_t __pyx_t_9;
  char *__pyx_t_10;
  size_t __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromfile", 0);

  /* "lurrn/sparsmat.pyx":3545
 *     def fromfile(self, f):
 *         cdef long i, n
 *         line=f.readline().strip().split()             # <<<<<<<<<<<<<<
 *         assert line[0]=='F3'
 *         n=long(line[1])
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_readline); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_line = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3546
 *         cdef long i, n
 *         line=f.readline().strip().split()
 *         assert line[0]=='F3'             # <<<<<<<<<<<<<<
 *         n=long(line[1])
 *         self.clear()
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3546; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_F3, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_6)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":3547
 *         line=f.readline().strip().split()
 *         assert line[0]=='F3'
 *         n=long(line[1])             # <<<<<<<<<<<<<<
 *         self.clear()
 *         self.vec.resize(n)
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3547; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyLong_Type))), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_7;

  /* "lurrn/sparsmat.pyx":3548
 *         assert line[0]=='F3'
 *         n=long(line[1])
 *         self.clear()             # <<<<<<<<<<<<<<
 *         self.vec.resize(n)
 *         k=0
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clear); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3549
 *         n=long(line[1])
 *         self.clear()
 *         self.vec.resize(n)             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_v_self->vec.resize(__pyx_v_n);

  /* "lurrn/sparsmat.pyx":3550
 *         self.clear()
 *         self.vec.resize(n)
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemF3))
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_k = __pyx_int_0;

  /* "lurrn/sparsmat.pyx":3551
 *         self.vec.resize(n)
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemF3))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemF3)
 */
  __pyx_t_7 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3552
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemF3))             # <<<<<<<<<<<<<<
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemF3)
 *             memcpy(<void *>c_VecF3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemF3))
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyInt_FromSize_t((256 * (sizeof(struct CountItem<3,float>)))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":3553
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemF3))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemF3)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecF3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemF3))
 *             k+=CHUNK_SIZE
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!((__pyx_t_8 == (256 * (sizeof(struct CountItem<3,float>)))) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":3554
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemF3))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemF3)
 *             memcpy(<void *>c_VecF3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemF3))             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), (256 * (sizeof(struct CountItem<3,float>))));

    /* "lurrn/sparsmat.pyx":3555
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemF3)
 *             memcpy(<void *>c_VecF3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemF3))
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemF3))
 */
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_k, __pyx_int_256); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_1);
    __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3556
 *             memcpy(<void *>c_VecF3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemF3))
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=f.read((n-k)*sizeof(c_CItemF3))
 *             assert len(s)==(n-k)*sizeof(c_CItemF3)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":3557
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemF3))             # <<<<<<<<<<<<<<
 *             assert len(s)==(n-k)*sizeof(c_CItemF3)
 *             memcpy(<void *>c_VecF3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemF3))
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_5, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<3,float>))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":3558
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemF3))
 *             assert len(s)==(n-k)*sizeof(c_CItemF3)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecF3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemF3))
 *     cpdef int get_maxcol(self, int k=0):
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<3,float>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_6)) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":3559
 *             s=f.read((n-k)*sizeof(c_CItemF3))
 *             assert len(s)==(n-k)*sizeof(c_CItemF3)
 *             memcpy(<void *>c_VecF3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemF3))             # <<<<<<<<<<<<<<
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<3,float>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), __pyx_t_11);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":3543
 *             s=PyString_FromStringAndSize(<char *>c_VecF3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemF3))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.fromfile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_line);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3560
 *             assert len(s)==(n-k)*sizeof(c_CItemF3)
 *             memcpy(<void *>c_VecF3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemF3))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<3
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_21get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecF3_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF3_get_maxcol *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_i;
  int __pyx_v_n;
  int __pyx_v_new_val;
  int __pyx_v_col;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_maxcol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF3_21get_maxcol)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3562
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<3             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         if n==0:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_9 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_9 = ((__pyx_v_k < 3) != 0);
    __pyx_t_8 = __pyx_t_9;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_8)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":3563
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<3
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         if n==0:
 *             return -1
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":3564
 *         assert k>=0 and k<3
 *         n=self.vec.size()
 *         if n==0:             # <<<<<<<<<<<<<<
 *             return -1
 *         if k==0:
 */
  __pyx_t_8 = ((__pyx_v_n == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":3565
 *         n=self.vec.size()
 *         if n==0:
 *             return -1             # <<<<<<<<<<<<<<
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 */
    __pyx_r = -1;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":3566
 *         if n==0:
 *             return -1
 *         if k==0:             # <<<<<<<<<<<<<<
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 */
  __pyx_t_8 = ((__pyx_v_k == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":3567
 *             return -1
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]             # <<<<<<<<<<<<<<
 *         col=-1
 *         n=self.vec.size()
 */
    __pyx_r = (__pyx_v_self->vec.at((__pyx_v_n - 1)).addr[0]);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":3568
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 *         col=-1             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_v_col = -1;

  /* "lurrn/sparsmat.pyx":3569
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":3570
 *         col=-1
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 */
  __pyx_t_7 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3571
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             if new_val>col:
 *                 col=new_val
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":3572
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:             # <<<<<<<<<<<<<<
 *                 col=new_val
 *         return col
 */
    __pyx_t_8 = ((__pyx_v_new_val > __pyx_v_col) != 0);
    if (__pyx_t_8) {

      /* "lurrn/sparsmat.pyx":3573
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 *                 col=new_val             # <<<<<<<<<<<<<<
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 */
      __pyx_v_col = __pyx_v_new_val;
      goto __pyx_L9;
    }
    __pyx_L9:;
  }

  /* "lurrn/sparsmat.pyx":3574
 *             if new_val>col:
 *                 col=new_val
 *         return col             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 *         cdef int old_val, new_val, i, n, count
 */
  __pyx_r = __pyx_v_col;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3560
 *             assert len(s)==(n-k)*sizeof(c_CItemF3)
 *             memcpy(<void *>c_VecF3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemF3))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<3
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecF3.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_21get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_21get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_maxcol (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_maxcol") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3560; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3560; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_maxcol", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3560; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF3_20get_maxcol(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_20get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecF3_get_maxcol __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = __pyx_vtabptr_5lurrn_8sparsmat_VecF3->get_maxcol(__pyx_v_self, 1, &__pyx_t_2); 
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3575
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_23get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecF3_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF3_get_type_counts *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_new_val;
  int __pyx_v_i;
  int __pyx_v_n;
  PyArrayObject *__pyx_v_result = 0;
  long __pyx_v_n_types;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecF3_get_maxcol __pyx_t_11;
  PyArrayObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF3_23get_type_counts)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3578
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<3             # <<<<<<<<<<<<<<
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_8 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_k < 3) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_7)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":3579
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<3
 *         if self.vec.size()==0:             # <<<<<<<<<<<<<<
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 */
  __pyx_t_7 = ((__pyx_v_self->vec.size() == 0) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":3580
 *         assert k>=0 and k<3
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_9 = 1;
      }
    }
    __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_2) {
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":3581
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":3582
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1             # <<<<<<<<<<<<<<
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 */
  __pyx_t_11.__pyx_n = 1;
  __pyx_t_11.k = __pyx_v_k;
  __pyx_t_10 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF3 *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0, &__pyx_t_11); 
  __pyx_v_n_types = (__pyx_t_10 + 1);

  /* "lurrn/sparsmat.pyx":3583
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_n_types); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_9 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_6) {
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_12 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
    }
    __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_12 = 0;
  __pyx_v_result = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3584
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":3585
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3586
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             result[new_val]+=1
 *         return result
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":3587
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1             # <<<<<<<<<<<<<<
 *         return result
 *     cpdef VecF3 remap(self, int k, numpy.ndarray filt):
 */
    __pyx_t_16 = __pyx_v_new_val;
    __pyx_t_17 = -1;
    if (__pyx_t_16 < 0) {
      __pyx_t_16 += __pyx_pybuffernd_result.diminfo[0].shape;
      if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 0;
    } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_17 = 0;
    if (unlikely(__pyx_t_17 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_17);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_result.diminfo[0].strides) += 1;
  }

  /* "lurrn/sparsmat.pyx":3588
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 *         return result             # <<<<<<<<<<<<<<
 *     cpdef VecF3 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyArrayObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3575
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_23get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_23get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3575; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3575; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3575; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF3_22get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_22get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecF3_get_type_counts __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_5lurrn_8sparsmat_VecF3->get_type_counts(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3589
 *             result[new_val]+=1
 *         return result
 *     cpdef VecF3 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_25remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_f_5lurrn_8sparsmat_5VecF3_remap(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_wanted = 0;
  PyArrayObject *__pyx_v_target = 0;
  int __pyx_v_n;
  int __pyx_v_i;
  struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_result = 0;
  struct CountItem<3,float> __pyx_v_c;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_target;
  __Pyx_Buffer __pyx_pybuffer_target;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_wanted;
  __Pyx_Buffer __pyx_pybuffer_wanted;
  struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __pyx_pybuffer_wanted.pybuffer.buf = NULL;
  __pyx_pybuffer_wanted.refcount = 0;
  __pyx_pybuffernd_wanted.data = NULL;
  __pyx_pybuffernd_wanted.rcbuffer = &__pyx_pybuffer_wanted;
  __pyx_pybuffer_target.pybuffer.buf = NULL;
  __pyx_pybuffer_target.refcount = 0;
  __pyx_pybuffernd_target.data = NULL;
  __pyx_pybuffernd_target.rcbuffer = &__pyx_pybuffer_target;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_remap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF3_25remap)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_filt));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_filt));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_filt));
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_VecF3))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3590
 *         return result
 *     cpdef VecF3 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_wanted = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_wanted.diminfo[0].strides = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_wanted.diminfo[0].shape = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_8 = 0;
  __pyx_v_wanted = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":3591
 *     cpdef VecF3 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_cumsum); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Subtract(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_target = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_target.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_target.diminfo[0].strides = __pyx_pybuffernd_target.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_target.diminfo[0].shape = __pyx_pybuffernd_target.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_9 = 0;
  __pyx_v_target = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3592
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         cdef int n=self.vec.size()
 *         cdef int i
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":3593
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()             # <<<<<<<<<<<<<<
 *         cdef int i
 *         cdef VecF3 result=VecF3()
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":3595
 *         cdef int n=self.vec.size()
 *         cdef int i
 *         cdef VecF3 result=VecF3()             # <<<<<<<<<<<<<<
 *         cdef c_CItemF3 c
 *         for i from 0<=i<n:
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3597
 *         cdef VecF3 result=VecF3()
 *         cdef c_CItemF3 c
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3598
 *         cdef c_CItemF3 c
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)             # <<<<<<<<<<<<<<
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 */
    __pyx_v_c = __pyx_v_self->vec.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":3599
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:             # <<<<<<<<<<<<<<
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 */
    __pyx_t_11 = (__pyx_v_c.addr[__pyx_v_k]);
    __pyx_t_12 = -1;
    if (__pyx_t_11 < 0) {
      __pyx_t_11 += __pyx_pybuffernd_wanted.diminfo[0].shape;
      if (unlikely(__pyx_t_11 < 0)) __pyx_t_12 = 0;
    } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_wanted.diminfo[0].shape)) __pyx_t_12 = 0;
    if (unlikely(__pyx_t_12 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_12);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_wanted.diminfo[0].strides)) != 0);
    if (__pyx_t_13) {

      /* "lurrn/sparsmat.pyx":3600
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c)
 *         return result
 */
      __pyx_t_12 = (__pyx_v_c.addr[__pyx_v_k]);
      __pyx_t_14 = -1;
      if (__pyx_t_12 < 0) {
        __pyx_t_12 += __pyx_pybuffernd_target.diminfo[0].shape;
        if (unlikely(__pyx_t_12 < 0)) __pyx_t_14 = 0;
      } else if (unlikely(__pyx_t_12 >= __pyx_pybuffernd_target.diminfo[0].shape)) __pyx_t_14 = 0;
      if (unlikely(__pyx_t_14 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_14);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      (__pyx_v_c.addr[__pyx_v_k]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_target.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_target.diminfo[0].strides));

      /* "lurrn/sparsmat.pyx":3601
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         return result
 *     def append(self,tup):
 */
      __pyx_v_result->vec.push_back(__pyx_v_c);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "lurrn/sparsmat.pyx":3602
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 *         return result             # <<<<<<<<<<<<<<
 *     def append(self,tup):
 *         k0,k1,k2,val=tup
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3589
 *             result[new_val]+=1
 *         return result
 *     cpdef VecF3 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_wanted);
  __Pyx_XDECREF((PyObject *)__pyx_v_target);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_25remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_25remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3589; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3589; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3589; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_filt = ((PyArrayObject *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3589; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_filt), __pyx_ptype_5numpy_ndarray, 1, "filt", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF3_24remap(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_24remap(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_5VecF3_remap(__pyx_v_self, __pyx_v_k, __pyx_v_filt, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3603
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,k1,k2,val=tup
 *         self.c_add(k0,k1,k2,val)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_27append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_27append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("append (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF3_26append(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self), ((PyObject *)__pyx_v_tup));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_26append(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_k1 = NULL;
  PyObject *__pyx_v_k2 = NULL;
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  coordinate_t __pyx_t_7;
  coordinate_t __pyx_t_8;
  coordinate_t __pyx_t_9;
  float __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("append", 0);

  /* "lurrn/sparsmat.pyx":3604
 *         return result
 *     def append(self,tup):
 *         k0,k1,k2,val=tup             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1,k2,val)
 *     def extend(self,tups):
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_tup))) || (PyList_CheckExact(__pyx_v_tup))) {
    PyObject* sequence = __pyx_v_tup;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_2,&__pyx_t_3,&__pyx_t_4};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_2,&__pyx_t_3,&__pyx_t_4};
    __pyx_t_5 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_6(__pyx_t_5); if (unlikely(!item)) goto __pyx_L3_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_k0 = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_k1 = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_k2 = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_val = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "lurrn/sparsmat.pyx":3605
 *     def append(self,tup):
 *         k0,k1,k2,val=tup
 *         self.c_add(k0,k1,k2,val)             # <<<<<<<<<<<<<<
 *     def extend(self,tups):
 *         for k0,k1,k2,val in tups:
 */
  __pyx_t_7 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_7 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k1); if (unlikely((__pyx_t_8 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k2); if (unlikely((__pyx_t_9 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_10 = __pyx_PyFloat_AsFloat(__pyx_v_val); if (unlikely((__pyx_t_10 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF3 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10);

  /* "lurrn/sparsmat.pyx":3603
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,k1,k2,val=tup
 *         self.c_add(k0,k1,k2,val)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_k1);
  __Pyx_XDECREF(__pyx_v_k2);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3606
 *         k0,k1,k2,val=tup
 *         self.c_add(k0,k1,k2,val)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,k1,k2,val in tups:
 *             self.c_add(k0,k1,k2,val)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_29extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_29extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extend (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF3_28extend(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self), ((PyObject *)__pyx_v_tups));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_28extend(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_k1 = NULL;
  PyObject *__pyx_v_k2 = NULL;
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  coordinate_t __pyx_t_11;
  coordinate_t __pyx_t_12;
  coordinate_t __pyx_t_13;
  float __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("extend", 0);

  /* "lurrn/sparsmat.pyx":3607
 *         self.c_add(k0,k1,k2,val)
 *     def extend(self,tups):
 *         for k0,k1,k2,val in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,k1,k2,val)
 *     def __iter__(self):
 */
  if (likely(PyList_CheckExact(__pyx_v_tups)) || PyTuple_CheckExact(__pyx_v_tups)) {
    __pyx_t_1 = __pyx_v_tups; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_tups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 4)) {
        if (size > 4) __Pyx_RaiseTooManyValuesError(4);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); 
        __pyx_t_8 = PyTuple_GET_ITEM(sequence, 3); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 2); 
        __pyx_t_8 = PyList_GET_ITEM(sequence, 3); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_8);
      #else
      {
        Py_ssize_t i;
        PyObject** temps[4] = {&__pyx_t_5,&__pyx_t_6,&__pyx_t_7,&__pyx_t_8};
        for (i=0; i < 4; i++) {
          PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(item);
          *(temps[i]) = item;
        }
      }
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      PyObject** temps[4] = {&__pyx_t_5,&__pyx_t_6,&__pyx_t_7,&__pyx_t_8};
      __pyx_t_9 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
      for (index=0; index < 4; index++) {
        PyObject* item = __pyx_t_10(__pyx_t_9); if (unlikely(!item)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(item);
        *(temps[index]) = item;
      }
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_10 = NULL;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_10 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_k0, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_k1, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_k2, __pyx_t_7);
    __pyx_t_7 = 0;
    __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "lurrn/sparsmat.pyx":3608
 *     def extend(self,tups):
 *         for k0,k1,k2,val in tups:
 *             self.c_add(k0,k1,k2,val)             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self.item_iter()
 */
    __pyx_t_11 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_11 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_12 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k1); if (unlikely((__pyx_t_12 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_13 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k2); if (unlikely((__pyx_t_13 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_14 = __pyx_PyFloat_AsFloat(__pyx_v_val); if (unlikely((__pyx_t_14 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF3 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_11, __pyx_t_12, __pyx_t_13, __pyx_t_14);

    /* "lurrn/sparsmat.pyx":3607
 *         self.c_add(k0,k1,k2,val)
 *     def extend(self,tups):
 *         for k0,k1,k2,val in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,k1,k2,val)
 *     def __iter__(self):
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3606
 *         k0,k1,k2,val=tup
 *         self.c_add(k0,k1,k2,val)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,k1,k2,val in tups:
 *             self.c_add(k0,k1,k2,val)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.extend", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_k1);
  __Pyx_XDECREF(__pyx_v_k2);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3609
 *         for k0,k1,k2,val in tups:
 *             self.c_add(k0,k1,k2,val)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_31__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_31__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF3_30__iter__(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_30__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":3610
 *             self.c_add(k0,k1,k2,val)
 *     def __iter__(self):
 *         return self.item_iter()             # <<<<<<<<<<<<<<
 *     def __reduce__(self):
 *         return (VecF3,(),(),self.item_iter())
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3609
 *         for k0,k1,k2,val in tups:
 *             self.c_add(k0,k1,k2,val)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3611
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecF3,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_33__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_33__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF3_32__reduce__(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_32__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "lurrn/sparsmat.pyx":3612
 *         return self.item_iter()
 *     def __reduce__(self):
 *         return (VecF3,(),(),self.item_iter())             # <<<<<<<<<<<<<<
 *     def __setstate__(self,state):
 *         pass
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF3)));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF3)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF3)));
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3611
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecF3,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3613
 *     def __reduce__(self):
 *         return (VecF3,(),(),self.item_iter())
 *     def __setstate__(self,state):             # <<<<<<<<<<<<<<
 *         pass
 *     def __repr__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_35__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_35__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF3_34__setstate__(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self), ((PyObject *)__pyx_v_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_34__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3615
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecF3(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_37__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecF3_37__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecF3_36__repr__(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecF3_36__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "lurrn/sparsmat.pyx":3616
 *         pass
 *     def __repr__(self):
 *         return 'VecF3(%s)'%(str(list(self)),)             # <<<<<<<<<<<<<<
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_VecF3_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3615
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecF3(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecF3.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3617
 *     def __repr__(self):
 *         return 'VecF3(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

/* Python wrapper */
static void __pyx_pw_5lurrn_8sparsmat_5VecF3_39__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5lurrn_8sparsmat_5VecF3_39__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5lurrn_8sparsmat_5VecF3_38__dealloc__(((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5lurrn_8sparsmat_5VecF3_38__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lurrn/sparsmat.pyx":3619
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()             # <<<<<<<<<<<<<<
 * 
 * cdef class IVecF3_iter:
 */
  __pyx_v_self->vec.~vector();

  /* "lurrn/sparsmat.pyx":3617
 *     def __repr__(self):
 *         return 'VecF3(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":3625
 *     cdef c_VecF3 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_11IVecF3_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_11IVecF3_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_vec = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_vec,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_vec = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.IVecF3_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecF3_iter___init__(((struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter *)__pyx_v_self), __pyx_v_vec);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_11IVecF3_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter *__pyx_v_self, PyObject *__pyx_v_vec) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":3626
 *     cdef unsigned int k
 *     def __init__(self,vec):
 *         self.vec=vec             # <<<<<<<<<<<<<<
 *         self.vecC=&self.vec.vec
 *         self.k=0
 */
  if (!(likely(((__pyx_v_vec) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_vec, __pyx_ptype_5lurrn_8sparsmat_VecF3))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_vec;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->vec);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->vec));
  __pyx_v_self->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3627
 *     def __init__(self,vec):
 *         self.vec=vec
 *         self.vecC=&self.vec.vec             # <<<<<<<<<<<<<<
 *         self.k=0
 *     def __iter__(self):
 */
  __pyx_v_self->vecC = (&__pyx_v_self->vec->vec);

  /* "lurrn/sparsmat.pyx":3628
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 *         self.k=0             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self
 */
  __pyx_v_self->k = 0;

  /* "lurrn/sparsmat.pyx":3625
 *     cdef c_VecF3 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecF3_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3629
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecF3_iter_3__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecF3_iter_3__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecF3_iter_2__iter__(((struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecF3_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":3630
 *         self.k=0
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3629
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3631
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecF3_iter_5__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecF3_iter_5__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecF3_iter_4__next__(((struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecF3_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter *__pyx_v_self) {
  struct CountItem<3,float> __pyx_v_res;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "lurrn/sparsmat.pyx":3632
 *         return self
 *     def __next__(self):
 *         if self.k>=self.vecC.size():             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         cdef c_CItemF3 res=self.vecC.at(self.k)
 */
  __pyx_t_1 = ((__pyx_v_self->k >= __pyx_v_self->vecC->size()) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":3633
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         cdef c_CItemF3 res=self.vecC.at(self.k)
 *         self.k+=1
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lurrn/sparsmat.pyx":3634
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 *         cdef c_CItemF3 res=self.vecC.at(self.k)             # <<<<<<<<<<<<<<
 *         self.k+=1
 *         return (res.addr[0],
 */
  __pyx_v_res = __pyx_v_self->vecC->at(__pyx_v_self->k);

  /* "lurrn/sparsmat.pyx":3635
 *             raise StopIteration
 *         cdef c_CItemF3 res=self.vecC.at(self.k)
 *         self.k+=1             # <<<<<<<<<<<<<<
 *         return (res.addr[0],
 *                 res.addr[1],
 */
  __pyx_v_self->k = (__pyx_v_self->k + 1);

  /* "lurrn/sparsmat.pyx":3636
 *         cdef c_CItemF3 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.addr[1],
 *                 res.addr[2],
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_res.addr[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "lurrn/sparsmat.pyx":3637
 *         self.k+=1
 *         return (res.addr[0],
 *                 res.addr[1],             # <<<<<<<<<<<<<<
 *                 res.addr[2],
 *                 res.item)
 */
  __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_res.addr[1])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "lurrn/sparsmat.pyx":3638
 *         return (res.addr[0],
 *                 res.addr[1],
 *                 res.addr[2],             # <<<<<<<<<<<<<<
 *                 res.item)
 * 
 */
  __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_res.addr[2])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":3639
 *                 res.addr[1],
 *                 res.addr[2],
 *                 res.item)             # <<<<<<<<<<<<<<
 * 
 * cdef class LargeVecF3:
 */
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_res.item); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "lurrn/sparsmat.pyx":3636
 *         cdef c_CItemF3 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.addr[1],
 *                 res.addr[2],
 */
  __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3631
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecF3_iter.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3644
 *     cdef public object compact
 *     cdef public VecF3 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecF3()
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF3_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF3_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF3___init__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF3___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":3645
 *     cdef public VecF3 loose
 *     def __init__(self):
 *         self.compact=[]             # <<<<<<<<<<<<<<
 *         self.loose=VecF3()
 *         self.loose.vec.reserve(100000)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3646
 *     def __init__(self):
 *         self.compact=[]
 *         self.loose=VecF3()             # <<<<<<<<<<<<<<
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3647
 *         self.compact=[]
 *         self.loose=VecF3()
 *         self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 */
  __pyx_v_self->loose->vec.reserve(100000);

  /* "lurrn/sparsmat.pyx":3644
 *     cdef public object compact
 *     cdef public VecF3 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecF3()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF3.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3648
 *         self.loose=VecF3()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ensure_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_2ensure_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF3_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":3649
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *         self.loose=VecF3()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":3650
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *         self.loose=VecF3()
 *         while len(self.compact)>=2:
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":3651
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 *         self.loose=VecF3()             # <<<<<<<<<<<<<<
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":3652
 *             self.compact.append(self.loose)
 *         self.loose=VecF3()
 *         while len(self.compact)>=2:             # <<<<<<<<<<<<<<
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 */
  while (1) {
    __pyx_t_2 = __pyx_v_self->compact;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = ((__pyx_t_6 >= 2) != 0);
    if (!__pyx_t_4) break;

    /* "lurrn/sparsmat.pyx":3653
 *         self.loose=VecF3()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.loose.c_add(k0,k1,k2, item)
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3653; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3653; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_1, -2, 0, NULL, NULL, &__pyx_slice__44, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3648
 *         self.loose=VecF3()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF3.ensure_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3654
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0,k1,k2, item)
 *         if self.loose.get_size(False)>=100000:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  PyObject *__pyx_v_item = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,&__pyx_n_s_k2,&__pyx_n_s_item,0};
    PyObject* values[4] = {0,0,0,0};
    values[3] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 0, 3, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3654; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 0, 3, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3654; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_item);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3654; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3654; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3654; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k2 = __Pyx_PyInt_As_coordinate_t(values[2]); if (unlikely((__pyx_v_k2 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3654; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_item = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3654; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF3.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_4add_count(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1, __pyx_v_k2, __pyx_v_item);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF3_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  float __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":3655
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.loose.c_add(k0,k1,k2, item)             # <<<<<<<<<<<<<<
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 */
  __pyx_t_1 = __pyx_PyFloat_AsFloat(__pyx_v_item); if (unlikely((__pyx_t_1 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF3 *)__pyx_v_self->loose->__pyx_vtab)->c_add(__pyx_v_self->loose, __pyx_v_k0, __pyx_v_k1, __pyx_v_k2, __pyx_t_1);

  /* "lurrn/sparsmat.pyx":3656
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.loose.c_add(k0,k1,k2, item)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_int_100000, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":3657
 *         self.loose.c_add(k0,k1,k2, item)
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *             self.loose=VecF3()
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF3 *)__pyx_v_self->loose->__pyx_vtab)->ensure_compact(__pyx_v_self->loose);

    /* "lurrn/sparsmat.pyx":3658
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *             self.loose=VecF3()
 *             self.loose.vec.reserve(100000)
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lurrn/sparsmat.pyx":3659
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 *             self.loose=VecF3()             # <<<<<<<<<<<<<<
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 */
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->loose);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
    __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":3660
 *             self.compact.append(self.loose)
 *             self.loose=VecF3()
 *             self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 */
    __pyx_v_self->loose->vec.reserve(100000);

    /* "lurrn/sparsmat.pyx":3661
 *             self.loose=VecF3()
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and             # <<<<<<<<<<<<<<
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
    while (1) {
      __pyx_t_2 = __pyx_v_self->compact;
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_7 = ((__pyx_t_6 >= 2) != 0);
      if (__pyx_t_7) {
      } else {
        __pyx_t_4 = __pyx_t_7;
        goto __pyx_L6_bool_binop_done;
      }

      /* "lurrn/sparsmat.pyx":3662
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):             # <<<<<<<<<<<<<<
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 */
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3662; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3662; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyNumber_Multiply(__pyx_float_0_6, __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_2, __pyx_t_9, Py_GE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_4 = __pyx_t_7;
      __pyx_L6_bool_binop_done:;
      if (!__pyx_t_4) break;

      /* "lurrn/sparsmat.pyx":3663
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3663; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3663; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = PyNumber_Add(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyList_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_9, -2, 0, NULL, NULL, &__pyx_slice__46, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":3654
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0,k1,k2, item)
 *         if self.loose.get_size(False)>=100000:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF3.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3664
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_6get_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF3_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_compact", 0);

  /* "lurrn/sparsmat.pyx":3665
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         if len(self.compact)>0:
 *             return self.compact[0]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3666
 *     def get_compact(self):
 *         self.ensure_compact()
 *         if len(self.compact)>0:             # <<<<<<<<<<<<<<
 *             return self.compact[0]
 *         else:
 */
  __pyx_t_1 = __pyx_v_self->compact;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((__pyx_t_4 > 0) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":3667
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 *             return self.compact[0]             # <<<<<<<<<<<<<<
 *         else:
 *             return VecF3()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3667; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":3669
 *             return self.compact[0]
 *         else:
 *             return VecF3()             # <<<<<<<<<<<<<<
 *     def get_size(self, compactify=True):
 *         cdef int n
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":3664
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF3.get_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3670
 *         else:
 *             return VecF3()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3670; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3670; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF3.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_8get_size(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF3_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  int __pyx_v_n;
  PyObject *__pyx_v_c = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":3672
 *     def get_size(self, compactify=True):
 *         cdef int n
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *             if self.compact:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":3673
 *         cdef int n
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *             if self.compact:
 *                 return self.compact[0].get_size()
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":3674
 *         if compactify:
 *             self.ensure_compact()
 *             if self.compact:             # <<<<<<<<<<<<<<
 *                 return self.compact[0].get_size()
 *             else:
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->compact); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":3675
 *             self.ensure_compact()
 *             if self.compact:
 *                 return self.compact[0].get_size()             # <<<<<<<<<<<<<<
 *             else:
 *                 return 0
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3675; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":3677
 *                 return self.compact[0].get_size()
 *             else:
 *                 return 0             # <<<<<<<<<<<<<<
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_int_0);
      __pyx_r = __pyx_int_0;
      goto __pyx_L0;
    }
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":3679
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_v_self->compact)) || PyTuple_CheckExact(__pyx_v_self->compact)) {
      __pyx_t_4 = __pyx_v_self->compact; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_self->compact); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_get_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":3680
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":3681
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)
 *             return n             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         self.ensure_compact()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":3670
 *         else:
 *             return VecF3()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF3.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_c);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3682
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_11__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_11__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_10__iter__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF3_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":3683
 *             return n
 *     def __iter__(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         try:
 *             return iter(self.compact[0])
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3684
 *     def __iter__(self):
 *         self.ensure_compact()
 *         try:             # <<<<<<<<<<<<<<
 *             return iter(self.compact[0])
 *         except IndexError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "lurrn/sparsmat.pyx":3685
 *         self.ensure_compact()
 *         try:
 *             return iter(self.compact[0])             # <<<<<<<<<<<<<<
 *         except IndexError:
 *             return iter([])
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3685; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3685; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L7_try_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":3686
 *         try:
 *             return iter(self.compact[0])
 *         except IndexError:             # <<<<<<<<<<<<<<
 *             return iter([])
 * 
 */
    __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_IndexError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF3.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3686; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_3);

      /* "lurrn/sparsmat.pyx":3687
 *             return iter(self.compact[0])
 *         except IndexError:
 *             return iter([])             # <<<<<<<<<<<<<<
 * 
 *     def get_type_counts(self, k=0):
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3687; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3687; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_r = __pyx_t_9;
      __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":3682
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF3.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3689
 *             return iter([])
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_13get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_13get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3689; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3689; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_12get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF3_12get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);

  /* "lurrn/sparsmat.pyx":3690
 * 
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)             # <<<<<<<<<<<<<<
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_k);
    __Pyx_GIVEREF(__pyx_v_k);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3689
 *             return iter([])
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3691
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_15remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_15remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  PyObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3691; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3691; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = values[0];
    __pyx_v_filt = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3691; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_14remap(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF3_14remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);

  /* "lurrn/sparsmat.pyx":3692
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)             # <<<<<<<<<<<<<<
 * 
 * cdef class SparseVectorF:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_remap); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_v_k);
  PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_k);
  __Pyx_GIVEREF(__pyx_v_k);
  __Pyx_INCREF(__pyx_v_filt);
  PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_filt);
  __Pyx_GIVEREF(__pyx_v_filt);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3691
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3642
 * 
 * cdef class LargeVecF3:
 *     cdef public object compact             # <<<<<<<<<<<<<<
 *     cdef public VecF3 loose
 *     def __init__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_7compact_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_7compact_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_7compact___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF3_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->compact);
  __pyx_r = __pyx_v_self->compact;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF3_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF3_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_7compact_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF3_7compact_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF3_7compact_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_7compact_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3643
 * cdef class LargeVecF3:
 *     cdef public object compact
 *     cdef public VecF3 loose             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *         self.compact=[]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_5loose_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_5loose_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_5loose___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecF3_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->loose));
  __pyx_r = ((PyObject *)__pyx_v_self->loose);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF3_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF3_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_5loose_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5lurrn_8sparsmat_VecF3))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecF3.loose.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF3_5loose_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecF3_5loose_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_5loose_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecF3_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3695
 * 
 * cdef class SparseVectorF:
 *     def __init__(self, pairs=None):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         if pairs is not None:
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pairs = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pairs,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pairs);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3695; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_pairs = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3695; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF___init__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), __pyx_v_pairs);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_13SparseVectorF___init__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, PyObject *__pyx_v_pairs) {
  coordinate_t __pyx_v_i;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_y = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  unsigned int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  coordinate_t __pyx_t_10;
  float __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":3697
 *     def __init__(self, pairs=None):
 *         cdef coordinate_t i
 *         if pairs is not None:             # <<<<<<<<<<<<<<
 *             self.my_len=len(pairs)
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 */
  __pyx_t_1 = (__pyx_v_pairs != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lurrn/sparsmat.pyx":3698
 *         cdef coordinate_t i
 *         if pairs is not None:
 *             self.my_len=len(pairs)             # <<<<<<<<<<<<<<
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *             self.vals_ptr=<float *>PyMem_Malloc(self.my_len*sizeof(float))
 */
    __pyx_t_3 = PyObject_Length(__pyx_v_pairs); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_self->my_len = __pyx_t_3;

    /* "lurrn/sparsmat.pyx":3699
 *         if pairs is not None:
 *             self.my_len=len(pairs)
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *             self.vals_ptr=<float *>PyMem_Malloc(self.my_len*sizeof(float))
 *             for i from 0<=i<self.my_len:
 */
    __pyx_v_self->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_self->my_len * (sizeof(coordinate_t)))));

    /* "lurrn/sparsmat.pyx":3700
 *             self.my_len=len(pairs)
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *             self.vals_ptr=<float *>PyMem_Malloc(self.my_len*sizeof(float))             # <<<<<<<<<<<<<<
 *             for i from 0<=i<self.my_len:
 *                 x,y=pairs[i]
 */
    __pyx_v_self->vals_ptr = ((float *)PyMem_Malloc((__pyx_v_self->my_len * (sizeof(float)))));

    /* "lurrn/sparsmat.pyx":3701
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *             self.vals_ptr=<float *>PyMem_Malloc(self.my_len*sizeof(float))
 *             for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *                 x,y=pairs[i]
 *                 self.idx_ptr[i]=x
 */
    __pyx_t_4 = __pyx_v_self->my_len;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":3702
 *             self.vals_ptr=<float *>PyMem_Malloc(self.my_len*sizeof(float))
 *             for i from 0<=i<self.my_len:
 *                 x,y=pairs[i]             # <<<<<<<<<<<<<<
 *                 self.idx_ptr[i]=x
 *                 self.vals_ptr[i]=y
 */
      __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_pairs, __pyx_v_i, coordinate_t, 0, __Pyx_PyInt_From_coordinate_t, 0, 0, 1); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3702; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_5);
      if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
        PyObject* sequence = __pyx_t_5;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        #else
        __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        #endif
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_8 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
        index = 0; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L7_unpacking_done;
        __pyx_L6_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L7_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_6);
      __pyx_t_6 = 0;
      __Pyx_XDECREF_SET(__pyx_v_y, __pyx_t_7);
      __pyx_t_7 = 0;

      /* "lurrn/sparsmat.pyx":3703
 *             for i from 0<=i<self.my_len:
 *                 x,y=pairs[i]
 *                 self.idx_ptr[i]=x             # <<<<<<<<<<<<<<
 *                 self.vals_ptr[i]=y
 *         else:
 */
      __pyx_t_10 = __Pyx_PyInt_As_coordinate_t(__pyx_v_x); if (unlikely((__pyx_t_10 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      (__pyx_v_self->idx_ptr[__pyx_v_i]) = __pyx_t_10;

      /* "lurrn/sparsmat.pyx":3704
 *                 x,y=pairs[i]
 *                 self.idx_ptr[i]=x
 *                 self.vals_ptr[i]=y             # <<<<<<<<<<<<<<
 *         else:
 *             self.my_len=0
 */
      __pyx_t_11 = __pyx_PyFloat_AsFloat(__pyx_v_y); if (unlikely((__pyx_t_11 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      (__pyx_v_self->vals_ptr[__pyx_v_i]) = __pyx_t_11;
    }
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":3706
 *                 self.vals_ptr[i]=y
 *         else:
 *             self.my_len=0             # <<<<<<<<<<<<<<
 *             self.idx_ptr=NULL
 *             self.vals_ptr=NULL
 */
    __pyx_v_self->my_len = 0;

    /* "lurrn/sparsmat.pyx":3707
 *         else:
 *             self.my_len=0
 *             self.idx_ptr=NULL             # <<<<<<<<<<<<<<
 *             self.vals_ptr=NULL
 *     cpdef int from_dense(self, float[:] dense):
 */
    __pyx_v_self->idx_ptr = NULL;

    /* "lurrn/sparsmat.pyx":3708
 *             self.my_len=0
 *             self.idx_ptr=NULL
 *             self.vals_ptr=NULL             # <<<<<<<<<<<<<<
 *     cpdef int from_dense(self, float[:] dense):
 *         cdef int i, k
 */
    __pyx_v_self->vals_ptr = NULL;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":3695
 * 
 * cdef class SparseVectorF:
 *     def __init__(self, pairs=None):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         if pairs is not None:
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3709
 *             self.idx_ptr=NULL
 *             self.vals_ptr=NULL
 *     cpdef int from_dense(self, float[:] dense):             # <<<<<<<<<<<<<<
 *         cdef int i, k
 *         assert self.my_len == 0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_3from_dense(PyObject *__pyx_v_self, PyObject *__pyx_arg_dense); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_13SparseVectorF_from_dense(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, __Pyx_memviewslice __pyx_v_dense, int __pyx_skip_dispatch) {
  int __pyx_v_i;
  int __pyx_v_k;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_dense", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_from_dense); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_3from_dense)) {
      if (unlikely(!__pyx_v_dense.memview)) { __Pyx_RaiseUnboundLocalError("dense"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3709; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
      __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dense, 1, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3711
 *     cpdef int from_dense(self, float[:] dense):
 *         cdef int i, k
 *         assert self.my_len == 0             # <<<<<<<<<<<<<<
 *         k = 0
 *         for i from 0<=i<dense.shape[0]:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_self->my_len == 0) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":3712
 *         cdef int i, k
 *         assert self.my_len == 0
 *         k = 0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<dense.shape[0]:
 *             if dense[i]!=0.0:
 */
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":3713
 *         assert self.my_len == 0
 *         k = 0
 *         for i from 0<=i<dense.shape[0]:             # <<<<<<<<<<<<<<
 *             if dense[i]!=0.0:
 *                 k += 1
 */
  __pyx_t_8 = (__pyx_v_dense.shape[0]);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3714
 *         k = 0
 *         for i from 0<=i<dense.shape[0]:
 *             if dense[i]!=0.0:             # <<<<<<<<<<<<<<
 *                 k += 1
 *         self.my_len = k
 */
    __pyx_t_7 = __pyx_v_i;
    __pyx_t_9 = -1;
    if (__pyx_t_7 < 0) {
      __pyx_t_7 += __pyx_v_dense.shape[0];
      if (unlikely(__pyx_t_7 < 0)) __pyx_t_9 = 0;
    } else if (unlikely(__pyx_t_7 >= __pyx_v_dense.shape[0])) __pyx_t_9 = 0;
    if (unlikely(__pyx_t_9 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_9);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_10 = (((*((float *) ( /* dim=0 */ (__pyx_v_dense.data + __pyx_t_7 * __pyx_v_dense.strides[0]) ))) != 0.0) != 0);
    if (__pyx_t_10) {

      /* "lurrn/sparsmat.pyx":3715
 *         for i from 0<=i<dense.shape[0]:
 *             if dense[i]!=0.0:
 *                 k += 1             # <<<<<<<<<<<<<<
 *         self.my_len = k
 *         self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 */
      __pyx_v_k = (__pyx_v_k + 1);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "lurrn/sparsmat.pyx":3716
 *             if dense[i]!=0.0:
 *                 k += 1
 *         self.my_len = k             # <<<<<<<<<<<<<<
 *         self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *         self.vals_ptr=<float *>PyMem_Malloc(self.my_len*sizeof(float))
 */
  __pyx_v_self->my_len = __pyx_v_k;

  /* "lurrn/sparsmat.pyx":3717
 *                 k += 1
 *         self.my_len = k
 *         self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         self.vals_ptr=<float *>PyMem_Malloc(self.my_len*sizeof(float))
 *         k = 0
 */
  __pyx_v_self->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_self->my_len * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":3718
 *         self.my_len = k
 *         self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *         self.vals_ptr=<float *>PyMem_Malloc(self.my_len*sizeof(float))             # <<<<<<<<<<<<<<
 *         k = 0
 *         for i from 0<=i<dense.shape[0]:
 */
  __pyx_v_self->vals_ptr = ((float *)PyMem_Malloc((__pyx_v_self->my_len * (sizeof(float)))));

  /* "lurrn/sparsmat.pyx":3719
 *         self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *         self.vals_ptr=<float *>PyMem_Malloc(self.my_len*sizeof(float))
 *         k = 0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<dense.shape[0]:
 *             if dense[i] != 0.0:
 */
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":3720
 *         self.vals_ptr=<float *>PyMem_Malloc(self.my_len*sizeof(float))
 *         k = 0
 *         for i from 0<=i<dense.shape[0]:             # <<<<<<<<<<<<<<
 *             if dense[i] != 0.0:
 *                 self.idx_ptr[k] = i
 */
  __pyx_t_8 = (__pyx_v_dense.shape[0]);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3721
 *         k = 0
 *         for i from 0<=i<dense.shape[0]:
 *             if dense[i] != 0.0:             # <<<<<<<<<<<<<<
 *                 self.idx_ptr[k] = i
 *                 self.vals_ptr[k] = dense[i]
 */
    __pyx_t_9 = __pyx_v_i;
    __pyx_t_11 = -1;
    if (__pyx_t_9 < 0) {
      __pyx_t_9 += __pyx_v_dense.shape[0];
      if (unlikely(__pyx_t_9 < 0)) __pyx_t_11 = 0;
    } else if (unlikely(__pyx_t_9 >= __pyx_v_dense.shape[0])) __pyx_t_11 = 0;
    if (unlikely(__pyx_t_11 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_11);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_10 = (((*((float *) ( /* dim=0 */ (__pyx_v_dense.data + __pyx_t_9 * __pyx_v_dense.strides[0]) ))) != 0.0) != 0);
    if (__pyx_t_10) {

      /* "lurrn/sparsmat.pyx":3722
 *         for i from 0<=i<dense.shape[0]:
 *             if dense[i] != 0.0:
 *                 self.idx_ptr[k] = i             # <<<<<<<<<<<<<<
 *                 self.vals_ptr[k] = dense[i]
 *                 k += 1
 */
      (__pyx_v_self->idx_ptr[__pyx_v_k]) = __pyx_v_i;

      /* "lurrn/sparsmat.pyx":3723
 *             if dense[i] != 0.0:
 *                 self.idx_ptr[k] = i
 *                 self.vals_ptr[k] = dense[i]             # <<<<<<<<<<<<<<
 *                 k += 1
 *         return k
 */
      __pyx_t_11 = __pyx_v_i;
      __pyx_t_12 = -1;
      if (__pyx_t_11 < 0) {
        __pyx_t_11 += __pyx_v_dense.shape[0];
        if (unlikely(__pyx_t_11 < 0)) __pyx_t_12 = 0;
      } else if (unlikely(__pyx_t_11 >= __pyx_v_dense.shape[0])) __pyx_t_12 = 0;
      if (unlikely(__pyx_t_12 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_12);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      (__pyx_v_self->vals_ptr[__pyx_v_k]) = (*((float *) ( /* dim=0 */ (__pyx_v_dense.data + __pyx_t_11 * __pyx_v_dense.strides[0]) )));

      /* "lurrn/sparsmat.pyx":3724
 *                 self.idx_ptr[k] = i
 *                 self.vals_ptr[k] = dense[i]
 *                 k += 1             # <<<<<<<<<<<<<<
 *         return k
 *     cpdef float dotSelf(self):
 */
      __pyx_v_k = (__pyx_v_k + 1);
      goto __pyx_L8;
    }
    __pyx_L8:;
  }

  /* "lurrn/sparsmat.pyx":3725
 *                 self.vals_ptr[k] = dense[i]
 *                 k += 1
 *         return k             # <<<<<<<<<<<<<<
 *     cpdef float dotSelf(self):
 *         cdef float s=0
 */
  __pyx_r = __pyx_v_k;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3709
 *             self.idx_ptr=NULL
 *             self.vals_ptr=NULL
 *     cpdef int from_dense(self, float[:] dense):             # <<<<<<<<<<<<<<
 *         cdef int i, k
 *         assert self.my_len == 0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorF.from_dense", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_3from_dense(PyObject *__pyx_v_self, PyObject *__pyx_arg_dense); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_3from_dense(PyObject *__pyx_v_self, PyObject *__pyx_arg_dense) {
  __Pyx_memviewslice __pyx_v_dense = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_dense (wrapper)", 0);
  assert(__pyx_arg_dense); {
    __pyx_v_dense = __Pyx_PyObject_to_MemoryviewSlice_ds_float(__pyx_arg_dense); if (unlikely(!__pyx_v_dense.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3709; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.from_dense", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_2from_dense(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), __pyx_v_dense);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_2from_dense(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, __Pyx_memviewslice __pyx_v_dense) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_dense", 0);
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_v_dense.memview)) { __Pyx_RaiseUnboundLocalError("dense"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3709; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_5lurrn_8sparsmat_13SparseVectorF_from_dense(__pyx_v_self, __pyx_v_dense, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.from_dense", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_dense, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3726
 *                 k += 1
 *         return k
 *     cpdef float dotSelf(self):             # <<<<<<<<<<<<<<
 *         cdef float s=0
 *         cdef coordinate_t i
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_5dotSelf(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static float __pyx_f_5lurrn_8sparsmat_13SparseVectorF_dotSelf(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, int __pyx_skip_dispatch) {
  float __pyx_v_s;
  coordinate_t __pyx_v_i;
  float __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  float __pyx_t_5;
  unsigned int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotSelf", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dotSelf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_5dotSelf)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_5 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_5;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3727
 *         return k
 *     cpdef float dotSelf(self):
 *         cdef float s=0             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_s = 0.0;

  /* "lurrn/sparsmat.pyx":3729
 *         cdef float s=0
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             s+=self.vals_ptr[i]*self.vals_ptr[i]
 *         return s
 */
  __pyx_t_6 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3730
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 *             s+=self.vals_ptr[i]*self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *         return s
 *     cdef float _dotFull(self, const_float_ptr full_ptr):
 */
    __pyx_v_s = (__pyx_v_s + ((__pyx_v_self->vals_ptr[__pyx_v_i]) * (__pyx_v_self->vals_ptr[__pyx_v_i])));
  }

  /* "lurrn/sparsmat.pyx":3731
 *         for i from 0<=i<self.my_len:
 *             s+=self.vals_ptr[i]*self.vals_ptr[i]
 *         return s             # <<<<<<<<<<<<<<
 *     cdef float _dotFull(self, const_float_ptr full_ptr):
 *         cdef float s=0
 */
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3726
 *                 k += 1
 *         return k
 *     cpdef float dotSelf(self):             # <<<<<<<<<<<<<<
 *         cdef float s=0
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorF.dotSelf", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_5dotSelf(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_5dotSelf(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dotSelf (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_4dotSelf(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_4dotSelf(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotSelf", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorF_dotSelf(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.dotSelf", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3732
 *             s+=self.vals_ptr[i]*self.vals_ptr[i]
 *         return s
 *     cdef float _dotFull(self, const_float_ptr full_ptr):             # <<<<<<<<<<<<<<
 *         cdef float s=0
 *         cdef coordinate_t i
 */

static float __pyx_f_5lurrn_8sparsmat_13SparseVectorF__dotFull(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, const float * __pyx_v_full_ptr) {
  float __pyx_v_s;
  coordinate_t __pyx_v_i;
  float __pyx_r;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  __Pyx_RefNannySetupContext("_dotFull", 0);

  /* "lurrn/sparsmat.pyx":3733
 *         return s
 *     cdef float _dotFull(self, const_float_ptr full_ptr):
 *         cdef float s=0             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_s = 0.0;

  /* "lurrn/sparsmat.pyx":3735
 *         cdef float s=0
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3736
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]             # <<<<<<<<<<<<<<
 *         return s
 *     cdef float _dotFull_partial(self, const_float_ptr full_ptr, int my_len):
 */
    __pyx_v_s = (__pyx_v_s + ((__pyx_v_self->vals_ptr[__pyx_v_i]) * (__pyx_v_full_ptr[(__pyx_v_self->idx_ptr[__pyx_v_i])])));
  }

  /* "lurrn/sparsmat.pyx":3737
 *         for i from 0<=i<self.my_len:
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s             # <<<<<<<<<<<<<<
 *     cdef float _dotFull_partial(self, const_float_ptr full_ptr, int my_len):
 *         cdef float s=0
 */
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3732
 *             s+=self.vals_ptr[i]*self.vals_ptr[i]
 *         return s
 *     cdef float _dotFull(self, const_float_ptr full_ptr):             # <<<<<<<<<<<<<<
 *         cdef float s=0
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3738
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s
 *     cdef float _dotFull_partial(self, const_float_ptr full_ptr, int my_len):             # <<<<<<<<<<<<<<
 *         cdef float s=0
 *         cdef coordinate_t i
 */

static float __pyx_f_5lurrn_8sparsmat_13SparseVectorF__dotFull_partial(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, const float * __pyx_v_full_ptr, int __pyx_v_my_len) {
  float __pyx_v_s;
  coordinate_t __pyx_v_i;
  float __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_dotFull_partial", 0);

  /* "lurrn/sparsmat.pyx":3739
 *         return s
 *     cdef float _dotFull_partial(self, const_float_ptr full_ptr, int my_len):
 *         cdef float s=0             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<my_len:
 */
  __pyx_v_s = 0.0;

  /* "lurrn/sparsmat.pyx":3741
 *         cdef float s=0
 *         cdef coordinate_t i
 *         for i from 0<=i<my_len:             # <<<<<<<<<<<<<<
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s
 */
  __pyx_t_1 = __pyx_v_my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3742
 *         cdef coordinate_t i
 *         for i from 0<=i<my_len:
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]             # <<<<<<<<<<<<<<
 *         return s
 *     cpdef double jaccard(self, SparseVectorF other):
 */
    __pyx_v_s = (__pyx_v_s + ((__pyx_v_self->vals_ptr[__pyx_v_i]) * (__pyx_v_full_ptr[(__pyx_v_self->idx_ptr[__pyx_v_i])])));
  }

  /* "lurrn/sparsmat.pyx":3743
 *         for i from 0<=i<my_len:
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s             # <<<<<<<<<<<<<<
 *     cpdef double jaccard(self, SparseVectorF other):
 *         cdef double s_max=0
 */
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3738
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s
 *     cdef float _dotFull_partial(self, const_float_ptr full_ptr, int my_len):             # <<<<<<<<<<<<<<
 *         cdef float s=0
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3744
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s
 *     cpdef double jaccard(self, SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef double s_max=0
 *         cdef double s_min=0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_7jaccard(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorF_jaccard(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other, int __pyx_skip_dispatch) {
  double __pyx_v_s_max;
  double __pyx_v_s_min;
  float __pyx_v_val1;
  float __pyx_v_val2;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("jaccard", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_jaccard); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_7jaccard)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3745
 *         return s
 *     cpdef double jaccard(self, SparseVectorF other):
 *         cdef double s_max=0             # <<<<<<<<<<<<<<
 *         cdef double s_min=0
 *         cdef float val1, val2
 */
  __pyx_v_s_max = 0.0;

  /* "lurrn/sparsmat.pyx":3746
 *     cpdef double jaccard(self, SparseVectorF other):
 *         cdef double s_max=0
 *         cdef double s_min=0             # <<<<<<<<<<<<<<
 *         cdef float val1, val2
 *         cdef coordinate_t i,j, idx_i, idx_j
 */
  __pyx_v_s_min = 0.0;

  /* "lurrn/sparsmat.pyx":3749
 *         cdef float val1, val2
 *         cdef coordinate_t i,j, idx_i, idx_j
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":3750
 *         cdef coordinate_t i,j, idx_i, idx_j
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *             idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":3751
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *             idx_i=self.idx_ptr[i]
 *             idx_j=other.idx_ptr[j]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":3752
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *             idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *             idx_j=other.idx_ptr[j]
 *             if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":3753
 *         while i<self.my_len and j<other.my_len:
 *             idx_i=self.idx_ptr[i]
 *             idx_j=other.idx_ptr[j]             # <<<<<<<<<<<<<<
 *             if idx_i<idx_j:
 *                 s_max+=self.vals_ptr[i]
 */
    __pyx_v_idx_j = (__pyx_v_other->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":3754
 *             idx_i=self.idx_ptr[i]
 *             idx_j=other.idx_ptr[j]
 *             if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *                 s_max+=self.vals_ptr[i]
 *                 i+=1
 */
    __pyx_t_7 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":3755
 *             idx_j=other.idx_ptr[j]
 *             if idx_i<idx_j:
 *                 s_max+=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                 i+=1
 *             elif idx_i>idx_j:
 */
      __pyx_v_s_max = (__pyx_v_s_max + (__pyx_v_self->vals_ptr[__pyx_v_i]));

      /* "lurrn/sparsmat.pyx":3756
 *             if idx_i<idx_j:
 *                 s_max+=self.vals_ptr[i]
 *                 i+=1             # <<<<<<<<<<<<<<
 *             elif idx_i>idx_j:
 *                 s_max+=other.vals_ptr[j]
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":3757
 *                 s_max+=self.vals_ptr[i]
 *                 i+=1
 *             elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *                 s_max+=other.vals_ptr[j]
 *                 j+=1
 */
    __pyx_t_7 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":3758
 *                 i+=1
 *             elif idx_i>idx_j:
 *                 s_max+=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                 j+=1
 *             else:
 */
      __pyx_v_s_max = (__pyx_v_s_max + (__pyx_v_other->vals_ptr[__pyx_v_j]));

      /* "lurrn/sparsmat.pyx":3759
 *             elif idx_i>idx_j:
 *                 s_max+=other.vals_ptr[j]
 *                 j+=1             # <<<<<<<<<<<<<<
 *             else:
 *                 val1=self.vals_ptr[i]
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":3761
 *                 j+=1
 *             else:
 *                 val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                 val2=other.vals_ptr[j]
 *                 if val1>val2:
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":3762
 *             else:
 *                 val1=self.vals_ptr[i]
 *                 val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                 if val1>val2:
 *                     s_max+=val1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":3763
 *                 val1=self.vals_ptr[i]
 *                 val2=other.vals_ptr[j]
 *                 if val1>val2:             # <<<<<<<<<<<<<<
 *                     s_max+=val1
 *                     s_min+=val2
 */
      __pyx_t_7 = ((__pyx_v_val1 > __pyx_v_val2) != 0);
      if (__pyx_t_7) {

        /* "lurrn/sparsmat.pyx":3764
 *                 val2=other.vals_ptr[j]
 *                 if val1>val2:
 *                     s_max+=val1             # <<<<<<<<<<<<<<
 *                     s_min+=val2
 *                 else:
 */
        __pyx_v_s_max = (__pyx_v_s_max + __pyx_v_val1);

        /* "lurrn/sparsmat.pyx":3765
 *                 if val1>val2:
 *                     s_max+=val1
 *                     s_min+=val2             # <<<<<<<<<<<<<<
 *                 else:
 *                     s_max+=val2
 */
        __pyx_v_s_min = (__pyx_v_s_min + __pyx_v_val2);
        goto __pyx_L8;
      }
      /*else*/ {

        /* "lurrn/sparsmat.pyx":3767
 *                     s_min+=val2
 *                 else:
 *                     s_max+=val2             # <<<<<<<<<<<<<<
 *                     s_min+=val1
 *                 i+=1
 */
        __pyx_v_s_max = (__pyx_v_s_max + __pyx_v_val2);

        /* "lurrn/sparsmat.pyx":3768
 *                 else:
 *                     s_max+=val2
 *                     s_min+=val1             # <<<<<<<<<<<<<<
 *                 i+=1
 *                 j+=1
 */
        __pyx_v_s_min = (__pyx_v_s_min + __pyx_v_val1);
      }
      __pyx_L8:;

      /* "lurrn/sparsmat.pyx":3769
 *                     s_max+=val2
 *                     s_min+=val1
 *                 i+=1             # <<<<<<<<<<<<<<
 *                 j+=1
 *         if i<self.my_len:
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":3770
 *                     s_min+=val1
 *                 i+=1
 *                 j+=1             # <<<<<<<<<<<<<<
 *         if i<self.my_len:
 *             while i<self.my_len:
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":3771
 *                 i+=1
 *                 j+=1
 *         if i<self.my_len:             # <<<<<<<<<<<<<<
 *             while i<self.my_len:
 *                 s_max+=self.vals_ptr[i]
 */
  __pyx_t_7 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":3772
 *                 j+=1
 *         if i<self.my_len:
 *             while i<self.my_len:             # <<<<<<<<<<<<<<
 *                 s_max+=self.vals_ptr[i]
 *                 i+=1
 */
    while (1) {
      __pyx_t_7 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
      if (!__pyx_t_7) break;

      /* "lurrn/sparsmat.pyx":3773
 *         if i<self.my_len:
 *             while i<self.my_len:
 *                 s_max+=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                 i+=1
 *         else:
 */
      __pyx_v_s_max = (__pyx_v_s_max + (__pyx_v_self->vals_ptr[__pyx_v_i]));

      /* "lurrn/sparsmat.pyx":3774
 *             while i<self.my_len:
 *                 s_max+=self.vals_ptr[i]
 *                 i+=1             # <<<<<<<<<<<<<<
 *         else:
 *             while j<other.my_len:
 */
      __pyx_v_i = (__pyx_v_i + 1);
    }
    goto __pyx_L9;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":3776
 *                 i+=1
 *         else:
 *             while j<other.my_len:             # <<<<<<<<<<<<<<
 *                 s_max+=other.vals_ptr[j]
 *                 j+=1
 */
    while (1) {
      __pyx_t_7 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
      if (!__pyx_t_7) break;

      /* "lurrn/sparsmat.pyx":3777
 *         else:
 *             while j<other.my_len:
 *                 s_max+=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                 j+=1
 *         if s_max==0:
 */
      __pyx_v_s_max = (__pyx_v_s_max + (__pyx_v_other->vals_ptr[__pyx_v_j]));

      /* "lurrn/sparsmat.pyx":3778
 *             while j<other.my_len:
 *                 s_max+=other.vals_ptr[j]
 *                 j+=1             # <<<<<<<<<<<<<<
 *         if s_max==0:
 *             return 0.0
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
  }
  __pyx_L9:;

  /* "lurrn/sparsmat.pyx":3779
 *                 s_max+=other.vals_ptr[j]
 *                 j+=1
 *         if s_max==0:             # <<<<<<<<<<<<<<
 *             return 0.0
 *         else:
 */
  __pyx_t_7 = ((__pyx_v_s_max == 0.0) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":3780
 *                 j+=1
 *         if s_max==0:
 *             return 0.0             # <<<<<<<<<<<<<<
 *         else:
 *             return s_min/s_max
 */
    __pyx_r = 0.0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":3782
 *             return 0.0
 *         else:
 *             return s_min/s_max             # <<<<<<<<<<<<<<
 *     cpdef float dotSparse(self, SparseVectorF other):
 *         cdef float product=0
 */
    if (unlikely(__pyx_v_s_max == 0)) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      #ifdef WITH_THREAD
      PyGILState_Release(__pyx_gilstate_save);
      #endif
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_r = (__pyx_v_s_min / __pyx_v_s_max);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":3744
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s
 *     cpdef double jaccard(self, SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef double s_max=0
 *         cdef double s_min=0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorF.jaccard", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_7jaccard(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_7jaccard(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("jaccard (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorF, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_6jaccard(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_6jaccard(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("jaccard", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorF_jaccard(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.jaccard", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3783
 *         else:
 *             return s_min/s_max
 *     cpdef float dotSparse(self, SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef float product=0
 *         cdef float val1, val2
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_9dotSparse(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static float __pyx_f_5lurrn_8sparsmat_13SparseVectorF_dotSparse(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other, int __pyx_skip_dispatch) {
  float __pyx_v_product;
  float __pyx_v_val1;
  float __pyx_v_val2;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  float __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  float __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotSparse", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dotSparse); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_9dotSparse)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_6 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3784
 *             return s_min/s_max
 *     cpdef float dotSparse(self, SparseVectorF other):
 *         cdef float product=0             # <<<<<<<<<<<<<<
 *         cdef float val1, val2
 *         cdef coordinate_t i, j, idx_i, idx_j
 */
  __pyx_v_product = 0.0;

  /* "lurrn/sparsmat.pyx":3787
 *         cdef float val1, val2
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":3788
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":3789
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":3790
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":3791
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]             # <<<<<<<<<<<<<<
 *            if idx_i<idx_j:
 *               i+=1
 */
    __pyx_v_idx_j = (__pyx_v_other->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":3792
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *               i+=1
 *            elif idx_i>idx_j:
 */
    __pyx_t_7 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":3793
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 *               i+=1             # <<<<<<<<<<<<<<
 *            elif idx_i>idx_j:
 *               j+=1
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":3794
 *            if idx_i<idx_j:
 *               i+=1
 *            elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *               j+=1
 *            else:
 */
    __pyx_t_7 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":3795
 *               i+=1
 *            elif idx_i>idx_j:
 *               j+=1             # <<<<<<<<<<<<<<
 *            else:
 *               val1=self.vals_ptr[i]
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":3797
 *               j+=1
 *            else:
 *               val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *               val2=other.vals_ptr[j]
 *               product+=val1*val2
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":3798
 *            else:
 *               val1=self.vals_ptr[i]
 *               val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *               product+=val1*val2
 *               i+=1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":3799
 *               val1=self.vals_ptr[i]
 *               val2=other.vals_ptr[j]
 *               product+=val1*val2             # <<<<<<<<<<<<<<
 *               i+=1
 *               j+=1
 */
      __pyx_v_product = (__pyx_v_product + (__pyx_v_val1 * __pyx_v_val2));

      /* "lurrn/sparsmat.pyx":3800
 *               val2=other.vals_ptr[j]
 *               product+=val1*val2
 *               i+=1             # <<<<<<<<<<<<<<
 *               j+=1
 *         return product
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":3801
 *               product+=val1*val2
 *               i+=1
 *               j+=1             # <<<<<<<<<<<<<<
 *         return product
 *     def count_intersection(self, SparseVectorF other):
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":3802
 *               i+=1
 *               j+=1
 *         return product             # <<<<<<<<<<<<<<
 *     def count_intersection(self, SparseVectorF other):
 *         cdef coordinate_t i, j, idx_i, idx_j
 */
  __pyx_r = __pyx_v_product;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3783
 *         else:
 *             return s_min/s_max
 *     cpdef float dotSparse(self, SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef float product=0
 *         cdef float val1, val2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorF.dotSparse", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_9dotSparse(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_9dotSparse(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dotSparse (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorF, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_8dotSparse(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_8dotSparse(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotSparse", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorF_dotSparse(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.dotSparse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3803
 *               j+=1
 *         return product
 *     def count_intersection(self, SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         cdef int n_ab=0
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_11count_intersection(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_11count_intersection(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("count_intersection (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorF, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_10count_intersection(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_10count_intersection(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other) {
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  int __pyx_v_n_ab;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("count_intersection", 0);

  /* "lurrn/sparsmat.pyx":3805
 *     def count_intersection(self, SparseVectorF other):
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         cdef int n_ab=0             # <<<<<<<<<<<<<<
 *         i=0
 *         j=0
 */
  __pyx_v_n_ab = 0;

  /* "lurrn/sparsmat.pyx":3806
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         cdef int n_ab=0
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":3807
 *         cdef int n_ab=0
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":3808
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_1) break;

    /* "lurrn/sparsmat.pyx":3809
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":3810
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]             # <<<<<<<<<<<<<<
 *            if idx_i<idx_j:
 *               i+=1
 */
    __pyx_v_idx_j = (__pyx_v_other->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":3811
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *               i+=1
 *            elif idx_i>idx_j:
 */
    __pyx_t_1 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":3812
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 *               i+=1             # <<<<<<<<<<<<<<
 *            elif idx_i>idx_j:
 *               j+=1
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":3813
 *            if idx_i<idx_j:
 *               i+=1
 *            elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *               j+=1
 *            else:
 */
    __pyx_t_1 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":3814
 *               i+=1
 *            elif idx_i>idx_j:
 *               j+=1             # <<<<<<<<<<<<<<
 *            else:
 *               i+=1
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":3816
 *               j+=1
 *            else:
 *               i+=1             # <<<<<<<<<<<<<<
 *               j+=1
 *               n_ab+=1
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":3817
 *            else:
 *               i+=1
 *               j+=1             # <<<<<<<<<<<<<<
 *               n_ab+=1
 *         return n_ab
 */
      __pyx_v_j = (__pyx_v_j + 1);

      /* "lurrn/sparsmat.pyx":3818
 *               i+=1
 *               j+=1
 *               n_ab+=1             # <<<<<<<<<<<<<<
 *         return n_ab
 *     cpdef double min_sum(self, SparseVectorF other):
 */
      __pyx_v_n_ab = (__pyx_v_n_ab + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":3819
 *               j+=1
 *               n_ab+=1
 *         return n_ab             # <<<<<<<<<<<<<<
 *     cpdef double min_sum(self, SparseVectorF other):
 *         cdef double product=0.0
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n_ab); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3803
 *               j+=1
 *         return product
 *     def count_intersection(self, SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         cdef int n_ab=0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.count_intersection", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3820
 *               n_ab+=1
 *         return n_ab
 *     cpdef double min_sum(self, SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef double product=0.0
 *         cdef float val1, val2
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_13min_sum(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorF_min_sum(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other, int __pyx_skip_dispatch) {
  double __pyx_v_product;
  float __pyx_v_val1;
  float __pyx_v_val2;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("min_sum", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_min_sum); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_13min_sum)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3821
 *         return n_ab
 *     cpdef double min_sum(self, SparseVectorF other):
 *         cdef double product=0.0             # <<<<<<<<<<<<<<
 *         cdef float val1, val2
 *         cdef coordinate_t i, j, idx_i, idx_j
 */
  __pyx_v_product = 0.0;

  /* "lurrn/sparsmat.pyx":3824
 *         cdef float val1, val2
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":3825
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":3826
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":3827
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":3828
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]             # <<<<<<<<<<<<<<
 *            if idx_i<idx_j:
 *               i+=1
 */
    __pyx_v_idx_j = (__pyx_v_other->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":3829
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *               i+=1
 *            elif idx_i>idx_j:
 */
    __pyx_t_7 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":3830
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 *               i+=1             # <<<<<<<<<<<<<<
 *            elif idx_i>idx_j:
 *               j+=1
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":3831
 *            if idx_i<idx_j:
 *               i+=1
 *            elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *               j+=1
 *            else:
 */
    __pyx_t_7 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":3832
 *               i+=1
 *            elif idx_i>idx_j:
 *               j+=1             # <<<<<<<<<<<<<<
 *            else:
 *               val1=self.vals_ptr[i]
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":3834
 *               j+=1
 *            else:
 *               val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *               val2=other.vals_ptr[j]
 *               if val1<val2:
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":3835
 *            else:
 *               val1=self.vals_ptr[i]
 *               val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *               if val1<val2:
 *                   product+=val1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":3836
 *               val1=self.vals_ptr[i]
 *               val2=other.vals_ptr[j]
 *               if val1<val2:             # <<<<<<<<<<<<<<
 *                   product+=val1
 *               else:
 */
      __pyx_t_7 = ((__pyx_v_val1 < __pyx_v_val2) != 0);
      if (__pyx_t_7) {

        /* "lurrn/sparsmat.pyx":3837
 *               val2=other.vals_ptr[j]
 *               if val1<val2:
 *                   product+=val1             # <<<<<<<<<<<<<<
 *               else:
 *                   product+=val2
 */
        __pyx_v_product = (__pyx_v_product + __pyx_v_val1);
        goto __pyx_L8;
      }
      /*else*/ {

        /* "lurrn/sparsmat.pyx":3839
 *                   product+=val1
 *               else:
 *                   product+=val2             # <<<<<<<<<<<<<<
 *               i+=1
 *               j+=1
 */
        __pyx_v_product = (__pyx_v_product + __pyx_v_val2);
      }
      __pyx_L8:;

      /* "lurrn/sparsmat.pyx":3840
 *               else:
 *                   product+=val2
 *               i+=1             # <<<<<<<<<<<<<<
 *               j+=1
 *         return product
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":3841
 *                   product+=val2
 *               i+=1
 *               j+=1             # <<<<<<<<<<<<<<
 *         return product
 *     cpdef double cosine(self, SparseVectorF other):
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":3842
 *               i+=1
 *               j+=1
 *         return product             # <<<<<<<<<<<<<<
 *     cpdef double cosine(self, SparseVectorF other):
 *         cdef double sqsum_self=0.0
 */
  __pyx_r = __pyx_v_product;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3820
 *               n_ab+=1
 *         return n_ab
 *     cpdef double min_sum(self, SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef double product=0.0
 *         cdef float val1, val2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorF.min_sum", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_13min_sum(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_13min_sum(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("min_sum (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorF, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_12min_sum(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_12min_sum(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("min_sum", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorF_min_sum(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.min_sum", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3843
 *               j+=1
 *         return product
 *     cpdef double cosine(self, SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef double sqsum_self=0.0
 *         cdef double sqsum_other=0.0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_15cosine(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorF_cosine(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other, int __pyx_skip_dispatch) {
  double __pyx_v_sqsum_self;
  double __pyx_v_sqsum_other;
  double __pyx_v_product;
  float __pyx_v_val1;
  float __pyx_v_val2;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("cosine", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_cosine); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_15cosine)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3844
 *         return product
 *     cpdef double cosine(self, SparseVectorF other):
 *         cdef double sqsum_self=0.0             # <<<<<<<<<<<<<<
 *         cdef double sqsum_other=0.0
 *         cdef double product=0.0
 */
  __pyx_v_sqsum_self = 0.0;

  /* "lurrn/sparsmat.pyx":3845
 *     cpdef double cosine(self, SparseVectorF other):
 *         cdef double sqsum_self=0.0
 *         cdef double sqsum_other=0.0             # <<<<<<<<<<<<<<
 *         cdef double product=0.0
 *         cdef float val1, val2
 */
  __pyx_v_sqsum_other = 0.0;

  /* "lurrn/sparsmat.pyx":3846
 *         cdef double sqsum_self=0.0
 *         cdef double sqsum_other=0.0
 *         cdef double product=0.0             # <<<<<<<<<<<<<<
 *         cdef float val1, val2
 *         cdef coordinate_t i, j, idx_i, idx_j
 */
  __pyx_v_product = 0.0;

  /* "lurrn/sparsmat.pyx":3849
 *         cdef float val1, val2
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":3850
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":3851
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":3852
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":3853
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]             # <<<<<<<<<<<<<<
 *            if idx_i<idx_j:
 *               val1=self.vals_ptr[i]
 */
    __pyx_v_idx_j = (__pyx_v_other->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":3854
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *               val1=self.vals_ptr[i]
 *               sqsum_self+=val1*val1
 */
    __pyx_t_7 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":3855
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 *               val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *               sqsum_self+=val1*val1
 *               i+=1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":3856
 *            if idx_i<idx_j:
 *               val1=self.vals_ptr[i]
 *               sqsum_self+=val1*val1             # <<<<<<<<<<<<<<
 *               i+=1
 *            elif idx_i>idx_j:
 */
      __pyx_v_sqsum_self = (__pyx_v_sqsum_self + (__pyx_v_val1 * __pyx_v_val1));

      /* "lurrn/sparsmat.pyx":3857
 *               val1=self.vals_ptr[i]
 *               sqsum_self+=val1*val1
 *               i+=1             # <<<<<<<<<<<<<<
 *            elif idx_i>idx_j:
 *               val2=other.vals_ptr[j]
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":3858
 *               sqsum_self+=val1*val1
 *               i+=1
 *            elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *               val2=other.vals_ptr[j]
 *               sqsum_other+=val2*val2
 */
    __pyx_t_7 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":3859
 *               i+=1
 *            elif idx_i>idx_j:
 *               val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *               sqsum_other+=val2*val2
 *               j+=1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":3860
 *            elif idx_i>idx_j:
 *               val2=other.vals_ptr[j]
 *               sqsum_other+=val2*val2             # <<<<<<<<<<<<<<
 *               j+=1
 *            else:
 */
      __pyx_v_sqsum_other = (__pyx_v_sqsum_other + (__pyx_v_val2 * __pyx_v_val2));

      /* "lurrn/sparsmat.pyx":3861
 *               val2=other.vals_ptr[j]
 *               sqsum_other+=val2*val2
 *               j+=1             # <<<<<<<<<<<<<<
 *            else:
 *               val1=self.vals_ptr[i]
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":3863
 *               j+=1
 *            else:
 *               val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *               val2=other.vals_ptr[j]
 *               sqsum_self+=val1*val1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":3864
 *            else:
 *               val1=self.vals_ptr[i]
 *               val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *               sqsum_self+=val1*val1
 *               sqsum_other+=val2*val2
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":3865
 *               val1=self.vals_ptr[i]
 *               val2=other.vals_ptr[j]
 *               sqsum_self+=val1*val1             # <<<<<<<<<<<<<<
 *               sqsum_other+=val2*val2
 *               product+=val1*val2
 */
      __pyx_v_sqsum_self = (__pyx_v_sqsum_self + (__pyx_v_val1 * __pyx_v_val1));

      /* "lurrn/sparsmat.pyx":3866
 *               val2=other.vals_ptr[j]
 *               sqsum_self+=val1*val1
 *               sqsum_other+=val2*val2             # <<<<<<<<<<<<<<
 *               product+=val1*val2
 *               i+=1
 */
      __pyx_v_sqsum_other = (__pyx_v_sqsum_other + (__pyx_v_val2 * __pyx_v_val2));

      /* "lurrn/sparsmat.pyx":3867
 *               sqsum_self+=val1*val1
 *               sqsum_other+=val2*val2
 *               product+=val1*val2             # <<<<<<<<<<<<<<
 *               i+=1
 *               j+=1
 */
      __pyx_v_product = (__pyx_v_product + (__pyx_v_val1 * __pyx_v_val2));

      /* "lurrn/sparsmat.pyx":3868
 *               sqsum_other+=val2*val2
 *               product+=val1*val2
 *               i+=1             # <<<<<<<<<<<<<<
 *               j+=1
 *         if i<self.my_len:
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":3869
 *               product+=val1*val2
 *               i+=1
 *               j+=1             # <<<<<<<<<<<<<<
 *         if i<self.my_len:
 *             while i<self.my_len:
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":3870
 *               i+=1
 *               j+=1
 *         if i<self.my_len:             # <<<<<<<<<<<<<<
 *             while i<self.my_len:
 *                 val1=self.vals_ptr[i]
 */
  __pyx_t_7 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":3871
 *               j+=1
 *         if i<self.my_len:
 *             while i<self.my_len:             # <<<<<<<<<<<<<<
 *                 val1=self.vals_ptr[i]
 *                 sqsum_self+=val1*val1
 */
    while (1) {
      __pyx_t_7 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
      if (!__pyx_t_7) break;

      /* "lurrn/sparsmat.pyx":3872
 *         if i<self.my_len:
 *             while i<self.my_len:
 *                 val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                 sqsum_self+=val1*val1
 *                 i+=1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":3873
 *             while i<self.my_len:
 *                 val1=self.vals_ptr[i]
 *                 sqsum_self+=val1*val1             # <<<<<<<<<<<<<<
 *                 i+=1
 *         else:
 */
      __pyx_v_sqsum_self = (__pyx_v_sqsum_self + (__pyx_v_val1 * __pyx_v_val1));

      /* "lurrn/sparsmat.pyx":3874
 *                 val1=self.vals_ptr[i]
 *                 sqsum_self+=val1*val1
 *                 i+=1             # <<<<<<<<<<<<<<
 *         else:
 *             while j<other.my_len:
 */
      __pyx_v_i = (__pyx_v_i + 1);
    }
    goto __pyx_L8;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":3876
 *                 i+=1
 *         else:
 *             while j<other.my_len:             # <<<<<<<<<<<<<<
 *                 val2=other.vals_ptr[j]
 *                 sqsum_other+=val2*val2
 */
    while (1) {
      __pyx_t_7 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
      if (!__pyx_t_7) break;

      /* "lurrn/sparsmat.pyx":3877
 *         else:
 *             while j<other.my_len:
 *                 val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                 sqsum_other+=val2*val2
 *                 j+=1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":3878
 *             while j<other.my_len:
 *                 val2=other.vals_ptr[j]
 *                 sqsum_other+=val2*val2             # <<<<<<<<<<<<<<
 *                 j+=1
 *         return product/sqrt(sqsum_self*sqsum_other)
 */
      __pyx_v_sqsum_other = (__pyx_v_sqsum_other + (__pyx_v_val2 * __pyx_v_val2));

      /* "lurrn/sparsmat.pyx":3879
 *                 val2=other.vals_ptr[j]
 *                 sqsum_other+=val2*val2
 *                 j+=1             # <<<<<<<<<<<<<<
 *         return product/sqrt(sqsum_self*sqsum_other)
 *     cpdef double jsd_unnorm(self, SparseVectorF other):
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
  }
  __pyx_L8:;

  /* "lurrn/sparsmat.pyx":3880
 *                 sqsum_other+=val2*val2
 *                 j+=1
 *         return product/sqrt(sqsum_self*sqsum_other)             # <<<<<<<<<<<<<<
 *     cpdef double jsd_unnorm(self, SparseVectorF other):
 *         cdef double sum=0.0
 */
  __pyx_t_6 = sqrt((__pyx_v_sqsum_self * __pyx_v_sqsum_other));
  if (unlikely(__pyx_t_6 == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_r = (__pyx_v_product / __pyx_t_6);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3843
 *               j+=1
 *         return product
 *     cpdef double cosine(self, SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef double sqsum_self=0.0
 *         cdef double sqsum_other=0.0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorF.cosine", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_15cosine(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_15cosine(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("cosine (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorF, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_14cosine(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_14cosine(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("cosine", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorF_cosine(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.cosine", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3881
 *                 j+=1
 *         return product/sqrt(sqsum_self*sqsum_other)
 *     cpdef double jsd_unnorm(self, SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef double val1, val2, avg
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_17jsd_unnorm(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorF_jsd_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other, int __pyx_skip_dispatch) {
  double __pyx_v_sum;
  double __pyx_v_val1;
  double __pyx_v_val2;
  double __pyx_v_avg;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("jsd_unnorm", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_jsd_unnorm); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_17jsd_unnorm)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3882
 *         return product/sqrt(sqsum_self*sqsum_other)
 *     cpdef double jsd_unnorm(self, SparseVectorF other):
 *         cdef double sum=0.0             # <<<<<<<<<<<<<<
 *         cdef double val1, val2, avg
 *         cdef coordinate_t i, j, idx_i, idx_j
 */
  __pyx_v_sum = 0.0;

  /* "lurrn/sparsmat.pyx":3885
 *         cdef double val1, val2, avg
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":3886
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":3887
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":3888
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":3889
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]             # <<<<<<<<<<<<<<
 *            if idx_i<idx_j:
 *                val1=self.vals_ptr[i]
 */
    __pyx_v_idx_j = (__pyx_v_other->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":3890
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *                val1=self.vals_ptr[i]
 *                sum+=val1*M_LN2
 */
    __pyx_t_7 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":3891
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 *                val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                sum+=val1*M_LN2
 *                i+=1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":3892
 *            if idx_i<idx_j:
 *                val1=self.vals_ptr[i]
 *                sum+=val1*M_LN2             # <<<<<<<<<<<<<<
 *                i+=1
 *            elif idx_i>idx_j:
 */
      __pyx_v_sum = (__pyx_v_sum + (__pyx_v_val1 * M_LN2));

      /* "lurrn/sparsmat.pyx":3893
 *                val1=self.vals_ptr[i]
 *                sum+=val1*M_LN2
 *                i+=1             # <<<<<<<<<<<<<<
 *            elif idx_i>idx_j:
 *                val2=other.vals_ptr[j]
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":3894
 *                sum+=val1*M_LN2
 *                i+=1
 *            elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *                val2=other.vals_ptr[j]
 *                sum+=val2*M_LN2
 */
    __pyx_t_7 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":3895
 *                i+=1
 *            elif idx_i>idx_j:
 *                val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                sum+=val2*M_LN2
 *                j+=1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":3896
 *            elif idx_i>idx_j:
 *                val2=other.vals_ptr[j]
 *                sum+=val2*M_LN2             # <<<<<<<<<<<<<<
 *                j+=1
 *            else:
 */
      __pyx_v_sum = (__pyx_v_sum + (__pyx_v_val2 * M_LN2));

      /* "lurrn/sparsmat.pyx":3897
 *                val2=other.vals_ptr[j]
 *                sum+=val2*M_LN2
 *                j+=1             # <<<<<<<<<<<<<<
 *            else:
 *                val1=self.vals_ptr[i]
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":3899
 *                j+=1
 *            else:
 *                val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                val2=other.vals_ptr[j]
 *                i+=1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":3900
 *            else:
 *                val1=self.vals_ptr[i]
 *                val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                i+=1
 *                j+=1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":3901
 *                val1=self.vals_ptr[i]
 *                val2=other.vals_ptr[j]
 *                i+=1             # <<<<<<<<<<<<<<
 *                j+=1
 *                avg=(val1+val2)/2.0
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":3902
 *                val2=other.vals_ptr[j]
 *                i+=1
 *                j+=1             # <<<<<<<<<<<<<<
 *                avg=(val1+val2)/2.0
 *                sum+=val1*log(val1/avg)+val2*log(val2/avg)
 */
      __pyx_v_j = (__pyx_v_j + 1);

      /* "lurrn/sparsmat.pyx":3903
 *                i+=1
 *                j+=1
 *                avg=(val1+val2)/2.0             # <<<<<<<<<<<<<<
 *                sum+=val1*log(val1/avg)+val2*log(val2/avg)
 *         while i<self.my_len:
 */
      __pyx_v_avg = ((__pyx_v_val1 + __pyx_v_val2) / 2.0);

      /* "lurrn/sparsmat.pyx":3904
 *                j+=1
 *                avg=(val1+val2)/2.0
 *                sum+=val1*log(val1/avg)+val2*log(val2/avg)             # <<<<<<<<<<<<<<
 *         while i<self.my_len:
 *            val1=self.vals_ptr[i]
 */
      if (unlikely(__pyx_v_avg == 0)) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        #ifdef WITH_THREAD
        PyGILState_Release(__pyx_gilstate_save);
        #endif
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      if (unlikely(__pyx_v_avg == 0)) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        #ifdef WITH_THREAD
        PyGILState_Release(__pyx_gilstate_save);
        #endif
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_v_sum = (__pyx_v_sum + ((__pyx_v_val1 * log((__pyx_v_val1 / __pyx_v_avg))) + (__pyx_v_val2 * log((__pyx_v_val2 / __pyx_v_avg)))));
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":3905
 *                avg=(val1+val2)/2.0
 *                sum+=val1*log(val1/avg)+val2*log(val2/avg)
 *         while i<self.my_len:             # <<<<<<<<<<<<<<
 *            val1=self.vals_ptr[i]
 *            i+=1
 */
  while (1) {
    __pyx_t_7 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":3906
 *                sum+=val1*log(val1/avg)+val2*log(val2/avg)
 *         while i<self.my_len:
 *            val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *            i+=1
 *            sum+=val1*M_LN2
 */
    __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":3907
 *         while i<self.my_len:
 *            val1=self.vals_ptr[i]
 *            i+=1             # <<<<<<<<<<<<<<
 *            sum+=val1*M_LN2
 *         while j<other.my_len:
 */
    __pyx_v_i = (__pyx_v_i + 1);

    /* "lurrn/sparsmat.pyx":3908
 *            val1=self.vals_ptr[i]
 *            i+=1
 *            sum+=val1*M_LN2             # <<<<<<<<<<<<<<
 *         while j<other.my_len:
 *            val2=other.vals_ptr[j]
 */
    __pyx_v_sum = (__pyx_v_sum + (__pyx_v_val1 * M_LN2));
  }

  /* "lurrn/sparsmat.pyx":3909
 *            i+=1
 *            sum+=val1*M_LN2
 *         while j<other.my_len:             # <<<<<<<<<<<<<<
 *            val2=other.vals_ptr[j]
 *            j+=1
 */
  while (1) {
    __pyx_t_7 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":3910
 *            sum+=val1*M_LN2
 *         while j<other.my_len:
 *            val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *            j+=1
 *            sum+=val2*M_LN2
 */
    __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":3911
 *         while j<other.my_len:
 *            val2=other.vals_ptr[j]
 *            j+=1             # <<<<<<<<<<<<<<
 *            sum+=val2*M_LN2
 *         return sum/(2.0*M_LN2)
 */
    __pyx_v_j = (__pyx_v_j + 1);

    /* "lurrn/sparsmat.pyx":3912
 *            val2=other.vals_ptr[j]
 *            j+=1
 *            sum+=val2*M_LN2             # <<<<<<<<<<<<<<
 *         return sum/(2.0*M_LN2)
 *     cpdef double skew_unnorm(self, SparseVectorF other, double alpha):
 */
    __pyx_v_sum = (__pyx_v_sum + (__pyx_v_val2 * M_LN2));
  }

  /* "lurrn/sparsmat.pyx":3913
 *            j+=1
 *            sum+=val2*M_LN2
 *         return sum/(2.0*M_LN2)             # <<<<<<<<<<<<<<
 *     cpdef double skew_unnorm(self, SparseVectorF other, double alpha):
 *         cdef double sum=0.0
 */
  __pyx_t_6 = (2.0 * M_LN2);
  if (unlikely(__pyx_t_6 == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_r = (__pyx_v_sum / __pyx_t_6);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3881
 *                 j+=1
 *         return product/sqrt(sqsum_self*sqsum_other)
 *     cpdef double jsd_unnorm(self, SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef double val1, val2, avg
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorF.jsd_unnorm", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_17jsd_unnorm(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_17jsd_unnorm(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("jsd_unnorm (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorF, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_16jsd_unnorm(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_16jsd_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("jsd_unnorm", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorF_jsd_unnorm(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.jsd_unnorm", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3914
 *            sum+=val2*M_LN2
 *         return sum/(2.0*M_LN2)
 *     cpdef double skew_unnorm(self, SparseVectorF other, double alpha):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef double beta=1.0-alpha
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_19skew_unnorm(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorF_skew_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other, double __pyx_v_alpha, int __pyx_skip_dispatch) {
  double __pyx_v_sum;
  double __pyx_v_beta;
  double __pyx_v_val1;
  double __pyx_v_val2;
  double __pyx_v_avg;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  double __pyx_v_log_invbeta;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  double __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("skew_unnorm", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_skew_unnorm); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_19skew_unnorm)) {
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_alpha); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_other));
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_other));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_8;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3915
 *         return sum/(2.0*M_LN2)
 *     cpdef double skew_unnorm(self, SparseVectorF other, double alpha):
 *         cdef double sum=0.0             # <<<<<<<<<<<<<<
 *         cdef double beta=1.0-alpha
 *         cdef double val1, val2, avg
 */
  __pyx_v_sum = 0.0;

  /* "lurrn/sparsmat.pyx":3916
 *     cpdef double skew_unnorm(self, SparseVectorF other, double alpha):
 *         cdef double sum=0.0
 *         cdef double beta=1.0-alpha             # <<<<<<<<<<<<<<
 *         cdef double val1, val2, avg
 *         cdef coordinate_t i, j, idx_i, idx_j
 */
  __pyx_v_beta = (1.0 - __pyx_v_alpha);

  /* "lurrn/sparsmat.pyx":3919
 *         cdef double val1, val2, avg
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         cdef double log_invbeta=log(1.0/beta)             # <<<<<<<<<<<<<<
 *         i=0
 *         j=0
 */
  if (unlikely(__pyx_v_beta == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_log_invbeta = log((1.0 / __pyx_v_beta));

  /* "lurrn/sparsmat.pyx":3920
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         cdef double log_invbeta=log(1.0/beta)
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":3921
 *         cdef double log_invbeta=log(1.0/beta)
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":3922
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *            idx_i=self.idx_ptr[i]
 *            idx_j=self.idx_ptr[j]
 */
  while (1) {
    __pyx_t_10 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_10) {
    } else {
      __pyx_t_9 = __pyx_t_10;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_10 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_9 = __pyx_t_10;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_9) break;

    /* "lurrn/sparsmat.pyx":3923
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *            idx_j=self.idx_ptr[j]
 *            if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":3924
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 *            idx_j=self.idx_ptr[j]             # <<<<<<<<<<<<<<
 *            if idx_i<idx_j:
 *                val1=self.vals_ptr[i]
 */
    __pyx_v_idx_j = (__pyx_v_self->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":3925
 *            idx_i=self.idx_ptr[i]
 *            idx_j=self.idx_ptr[j]
 *            if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *                val1=self.vals_ptr[i]
 *                sum+=val1*log_invbeta
 */
    __pyx_t_9 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_9) {

      /* "lurrn/sparsmat.pyx":3926
 *            idx_j=self.idx_ptr[j]
 *            if idx_i<idx_j:
 *                val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                sum+=val1*log_invbeta
 *                i+=1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":3927
 *            if idx_i<idx_j:
 *                val1=self.vals_ptr[i]
 *                sum+=val1*log_invbeta             # <<<<<<<<<<<<<<
 *                i+=1
 *            elif idx_i>idx_j:
 */
      __pyx_v_sum = (__pyx_v_sum + (__pyx_v_val1 * __pyx_v_log_invbeta));

      /* "lurrn/sparsmat.pyx":3928
 *                val1=self.vals_ptr[i]
 *                sum+=val1*log_invbeta
 *                i+=1             # <<<<<<<<<<<<<<
 *            elif idx_i>idx_j:
 *                j+=1
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":3929
 *                sum+=val1*log_invbeta
 *                i+=1
 *            elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *                j+=1
 *            else:
 */
    __pyx_t_9 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_9) {

      /* "lurrn/sparsmat.pyx":3930
 *                i+=1
 *            elif idx_i>idx_j:
 *                j+=1             # <<<<<<<<<<<<<<
 *            else:
 *                val1=self.vals_ptr[i]
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":3932
 *                j+=1
 *            else:
 *                val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                val2=other.vals_ptr[j]
 *                avg=alpha*val2+beta*val1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":3933
 *            else:
 *                val1=self.vals_ptr[i]
 *                val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                avg=alpha*val2+beta*val1
 *                sum+=log(val1/avg)
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":3934
 *                val1=self.vals_ptr[i]
 *                val2=other.vals_ptr[j]
 *                avg=alpha*val2+beta*val1             # <<<<<<<<<<<<<<
 *                sum+=log(val1/avg)
 *                i+=1
 */
      __pyx_v_avg = ((__pyx_v_alpha * __pyx_v_val2) + (__pyx_v_beta * __pyx_v_val1));

      /* "lurrn/sparsmat.pyx":3935
 *                val2=other.vals_ptr[j]
 *                avg=alpha*val2+beta*val1
 *                sum+=log(val1/avg)             # <<<<<<<<<<<<<<
 *                i+=1
 *                j+=1
 */
      if (unlikely(__pyx_v_avg == 0)) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        #ifdef WITH_THREAD
        PyGILState_Release(__pyx_gilstate_save);
        #endif
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_v_sum = (__pyx_v_sum + log((__pyx_v_val1 / __pyx_v_avg)));

      /* "lurrn/sparsmat.pyx":3936
 *                avg=alpha*val2+beta*val1
 *                sum+=log(val1/avg)
 *                i+=1             # <<<<<<<<<<<<<<
 *                j+=1
 *         return sum
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":3937
 *                sum+=log(val1/avg)
 *                i+=1
 *                j+=1             # <<<<<<<<<<<<<<
 *         return sum
 *     cpdef double norm_l1(self):
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":3938
 *                i+=1
 *                j+=1
 *         return sum             # <<<<<<<<<<<<<<
 *     cpdef double norm_l1(self):
 *         cdef double sum=0.0
 */
  __pyx_r = __pyx_v_sum;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3914
 *            sum+=val2*M_LN2
 *         return sum/(2.0*M_LN2)
 *     cpdef double skew_unnorm(self, SparseVectorF other, double alpha):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef double beta=1.0-alpha
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorF.skew_unnorm", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_19skew_unnorm(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_19skew_unnorm(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other = 0;
  double __pyx_v_alpha;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("skew_unnorm (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_other,&__pyx_n_s_alpha,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_other)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alpha)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("skew_unnorm", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3914; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "skew_unnorm") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3914; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_other = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)values[0]);
    __pyx_v_alpha = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_alpha == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3914; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("skew_unnorm", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3914; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.skew_unnorm", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorF, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_18skew_unnorm(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), __pyx_v_other, __pyx_v_alpha);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_18skew_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other, double __pyx_v_alpha) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("skew_unnorm", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorF_skew_unnorm(__pyx_v_self, __pyx_v_other, __pyx_v_alpha, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.skew_unnorm", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3939
 *                j+=1
 *         return sum
 *     cpdef double norm_l1(self):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef unsigned int i
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_21norm_l1(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorF_norm_l1(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, int __pyx_skip_dispatch) {
  double __pyx_v_sum;
  unsigned int __pyx_v_i;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  double __pyx_t_5;
  unsigned int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("norm_l1", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_norm_l1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_21norm_l1)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_5;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3940
 *         return sum
 *     cpdef double norm_l1(self):
 *         cdef double sum=0.0             # <<<<<<<<<<<<<<
 *         cdef unsigned int i
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_sum = 0.0;

  /* "lurrn/sparsmat.pyx":3942
 *         cdef double sum=0.0
 *         cdef unsigned int i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             sum+=fabs(self.vals_ptr[i])
 *         return sum
 */
  __pyx_t_6 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3943
 *         cdef unsigned int i
 *         for i from 0<=i<self.my_len:
 *             sum+=fabs(self.vals_ptr[i])             # <<<<<<<<<<<<<<
 *         return sum
 *     cpdef double norm_l2(self):
 */
    __pyx_v_sum = (__pyx_v_sum + fabs((__pyx_v_self->vals_ptr[__pyx_v_i])));
  }

  /* "lurrn/sparsmat.pyx":3944
 *         for i from 0<=i<self.my_len:
 *             sum+=fabs(self.vals_ptr[i])
 *         return sum             # <<<<<<<<<<<<<<
 *     cpdef double norm_l2(self):
 *         cdef double sum=0.0
 */
  __pyx_r = __pyx_v_sum;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3939
 *                j+=1
 *         return sum
 *     cpdef double norm_l1(self):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef unsigned int i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorF.norm_l1", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_21norm_l1(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_21norm_l1(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("norm_l1 (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_20norm_l1(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_20norm_l1(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("norm_l1", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorF_norm_l1(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.norm_l1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3945
 *             sum+=fabs(self.vals_ptr[i])
 *         return sum
 *     cpdef double norm_l2(self):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef double val
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_23norm_l2(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorF_norm_l2(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, int __pyx_skip_dispatch) {
  double __pyx_v_sum;
  double __pyx_v_val;
  unsigned int __pyx_v_i;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  double __pyx_t_5;
  unsigned int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("norm_l2", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_norm_l2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_23norm_l2)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_5;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3946
 *         return sum
 *     cpdef double norm_l2(self):
 *         cdef double sum=0.0             # <<<<<<<<<<<<<<
 *         cdef double val
 *         cdef unsigned int i
 */
  __pyx_v_sum = 0.0;

  /* "lurrn/sparsmat.pyx":3949
 *         cdef double val
 *         cdef unsigned int i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             val=self.vals_ptr[i];
 *             sum+=val*val
 */
  __pyx_t_6 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3950
 *         cdef unsigned int i
 *         for i from 0<=i<self.my_len:
 *             val=self.vals_ptr[i];             # <<<<<<<<<<<<<<
 *             sum+=val*val
 *         return sqrt(sum)
 */
    __pyx_v_val = (__pyx_v_self->vals_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":3951
 *         for i from 0<=i<self.my_len:
 *             val=self.vals_ptr[i];
 *             sum+=val*val             # <<<<<<<<<<<<<<
 *         return sqrt(sum)
 *     cpdef double norm_lp(self, double p):
 */
    __pyx_v_sum = (__pyx_v_sum + (__pyx_v_val * __pyx_v_val));
  }

  /* "lurrn/sparsmat.pyx":3952
 *             val=self.vals_ptr[i];
 *             sum+=val*val
 *         return sqrt(sum)             # <<<<<<<<<<<<<<
 *     cpdef double norm_lp(self, double p):
 *         cdef double sum=0.0
 */
  __pyx_r = sqrt(__pyx_v_sum);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3945
 *             sum+=fabs(self.vals_ptr[i])
 *         return sum
 *     cpdef double norm_l2(self):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef double val
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorF.norm_l2", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_23norm_l2(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_23norm_l2(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("norm_l2 (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_22norm_l2(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_22norm_l2(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("norm_l2", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorF_norm_l2(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.norm_l2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3953
 *             sum+=val*val
 *         return sqrt(sum)
 *     cpdef double norm_lp(self, double p):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef int i
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_25norm_lp(PyObject *__pyx_v_self, PyObject *__pyx_arg_p); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorF_norm_lp(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, double __pyx_v_p, int __pyx_skip_dispatch) {
  double __pyx_v_sum;
  int __pyx_v_i;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  double __pyx_t_7;
  unsigned int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("norm_lp", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_norm_lp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_25norm_lp)) {
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_p); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3954
 *         return sqrt(sum)
 *     cpdef double norm_lp(self, double p):
 *         cdef double sum=0.0             # <<<<<<<<<<<<<<
 *         cdef int i
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_sum = 0.0;

  /* "lurrn/sparsmat.pyx":3956
 *         cdef double sum=0.0
 *         cdef int i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             sum+=pow(fabs(self.vals_ptr[i]),p)
 *         return pow(sum,1.0/p)
 */
  __pyx_t_8 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3957
 *         cdef int i
 *         for i from 0<=i<self.my_len:
 *             sum+=pow(fabs(self.vals_ptr[i]),p)             # <<<<<<<<<<<<<<
 *         return pow(sum,1.0/p)
 *     def dotFull(self, numpy.ndarray[float,ndim=1] full):
 */
    __pyx_v_sum = (__pyx_v_sum + pow(fabs((__pyx_v_self->vals_ptr[__pyx_v_i])), __pyx_v_p));
  }

  /* "lurrn/sparsmat.pyx":3958
 *         for i from 0<=i<self.my_len:
 *             sum+=pow(fabs(self.vals_ptr[i]),p)
 *         return pow(sum,1.0/p)             # <<<<<<<<<<<<<<
 *     def dotFull(self, numpy.ndarray[float,ndim=1] full):
 *         cdef float *full_ptr
 */
  if (unlikely(__pyx_v_p == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_r = pow(__pyx_v_sum, (1.0 / __pyx_v_p));
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3953
 *             sum+=val*val
 *         return sqrt(sum)
 *     cpdef double norm_lp(self, double p):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef int i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorF.norm_lp", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_25norm_lp(PyObject *__pyx_v_self, PyObject *__pyx_arg_p); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_25norm_lp(PyObject *__pyx_v_self, PyObject *__pyx_arg_p) {
  double __pyx_v_p;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("norm_lp (wrapper)", 0);
  assert(__pyx_arg_p); {
    __pyx_v_p = __pyx_PyFloat_AsDouble(__pyx_arg_p); if (unlikely((__pyx_v_p == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3953; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.norm_lp", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_24norm_lp(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((double)__pyx_v_p));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_24norm_lp(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, double __pyx_v_p) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("norm_lp", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorF_norm_lp(__pyx_v_self, __pyx_v_p, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.norm_lp", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3959
 *             sum+=pow(fabs(self.vals_ptr[i]),p)
 *         return pow(sum,1.0/p)
 *     def dotFull(self, numpy.ndarray[float,ndim=1] full):             # <<<<<<<<<<<<<<
 *         cdef float *full_ptr
 *         cdef unsigned int my_len=self.my_len
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_27dotFull(PyObject *__pyx_v_self, PyObject *__pyx_v_full); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_27dotFull(PyObject *__pyx_v_self, PyObject *__pyx_v_full) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dotFull (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_full), __pyx_ptype_5numpy_ndarray, 1, "full", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_26dotFull(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((PyArrayObject *)__pyx_v_full));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_26dotFull(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, PyArrayObject *__pyx_v_full) {
  float *__pyx_v_full_ptr;
  unsigned int __pyx_v_my_len;
  unsigned int __pyx_v_full_len;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_full;
  __Pyx_Buffer __pyx_pybuffer_full;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotFull", 0);
  __pyx_pybuffer_full.pybuffer.buf = NULL;
  __pyx_pybuffer_full.refcount = 0;
  __pyx_pybuffernd_full.data = NULL;
  __pyx_pybuffernd_full.rcbuffer = &__pyx_pybuffer_full;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_full.rcbuffer->pybuffer, (PyObject*)__pyx_v_full, &__Pyx_TypeInfo_float, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_full.diminfo[0].strides = __pyx_pybuffernd_full.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_full.diminfo[0].shape = __pyx_pybuffernd_full.rcbuffer->pybuffer.shape[0];

  /* "lurrn/sparsmat.pyx":3961
 *     def dotFull(self, numpy.ndarray[float,ndim=1] full):
 *         cdef float *full_ptr
 *         cdef unsigned int my_len=self.my_len             # <<<<<<<<<<<<<<
 *         cdef unsigned int full_len=len(full)
 *         # treat nonpresent values as 0
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  __pyx_v_my_len = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":3962
 *         cdef float *full_ptr
 *         cdef unsigned int my_len=self.my_len
 *         cdef unsigned int full_len=len(full)             # <<<<<<<<<<<<<<
 *         # treat nonpresent values as 0
 *         while my_len>0 and self.idx_ptr[my_len-1]>full_len:
 */
  __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_full)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_full_len = __pyx_t_2;

  /* "lurrn/sparsmat.pyx":3964
 *         cdef unsigned int full_len=len(full)
 *         # treat nonpresent values as 0
 *         while my_len>0 and self.idx_ptr[my_len-1]>full_len:             # <<<<<<<<<<<<<<
 *             my_len-=1
 *         full_ptr=<float*>full.data
 */
  while (1) {
    __pyx_t_4 = ((__pyx_v_my_len > 0) != 0);
    if (__pyx_t_4) {
    } else {
      __pyx_t_3 = __pyx_t_4;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_4 = (((__pyx_v_self->idx_ptr[(__pyx_v_my_len - 1)]) > __pyx_v_full_len) != 0);
    __pyx_t_3 = __pyx_t_4;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_3) break;

    /* "lurrn/sparsmat.pyx":3965
 *         # treat nonpresent values as 0
 *         while my_len>0 and self.idx_ptr[my_len-1]>full_len:
 *             my_len-=1             # <<<<<<<<<<<<<<
 *         full_ptr=<float*>full.data
 *         return self._dotFull_partial(full_ptr,my_len)
 */
    __pyx_v_my_len = (__pyx_v_my_len - 1);
  }

  /* "lurrn/sparsmat.pyx":3966
 *         while my_len>0 and self.idx_ptr[my_len-1]>full_len:
 *             my_len-=1
 *         full_ptr=<float*>full.data             # <<<<<<<<<<<<<<
 *         return self._dotFull_partial(full_ptr,my_len)
 *     def dotFull_check(self, numpy.ndarray[float,ndim=1] full):
 */
  __pyx_v_full_ptr = ((float *)__pyx_v_full->data);

  /* "lurrn/sparsmat.pyx":3967
 *             my_len-=1
 *         full_ptr=<float*>full.data
 *         return self._dotFull_partial(full_ptr,my_len)             # <<<<<<<<<<<<<<
 *     def dotFull_check(self, numpy.ndarray[float,ndim=1] full):
 *         cdef float *full_ptr
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = PyFloat_FromDouble(((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self->__pyx_vtab)->_dotFull_partial(__pyx_v_self, __pyx_v_full_ptr, __pyx_v_my_len)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3959
 *             sum+=pow(fabs(self.vals_ptr[i]),p)
 *         return pow(sum,1.0/p)
 *     def dotFull(self, numpy.ndarray[float,ndim=1] full):             # <<<<<<<<<<<<<<
 *         cdef float *full_ptr
 *         cdef unsigned int my_len=self.my_len
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_full.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.dotFull", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_full.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3968
 *         full_ptr=<float*>full.data
 *         return self._dotFull_partial(full_ptr,my_len)
 *     def dotFull_check(self, numpy.ndarray[float,ndim=1] full):             # <<<<<<<<<<<<<<
 *         cdef float *full_ptr
 *         cdef int my_len=self.my_len
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_29dotFull_check(PyObject *__pyx_v_self, PyObject *__pyx_v_full); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_29dotFull_check(PyObject *__pyx_v_self, PyObject *__pyx_v_full) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dotFull_check (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_full), __pyx_ptype_5numpy_ndarray, 1, "full", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_28dotFull_check(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((PyArrayObject *)__pyx_v_full));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_28dotFull_check(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, PyArrayObject *__pyx_v_full) {
  float *__pyx_v_full_ptr;
  CYTHON_UNUSED int __pyx_v_my_len;
  CYTHON_UNUSED int __pyx_v_full_len;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_full;
  __Pyx_Buffer __pyx_pybuffer_full;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  coordinate_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotFull_check", 0);
  __pyx_pybuffer_full.pybuffer.buf = NULL;
  __pyx_pybuffer_full.refcount = 0;
  __pyx_pybuffernd_full.data = NULL;
  __pyx_pybuffernd_full.rcbuffer = &__pyx_pybuffer_full;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_full.rcbuffer->pybuffer, (PyObject*)__pyx_v_full, &__Pyx_TypeInfo_float, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_full.diminfo[0].strides = __pyx_pybuffernd_full.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_full.diminfo[0].shape = __pyx_pybuffernd_full.rcbuffer->pybuffer.shape[0];

  /* "lurrn/sparsmat.pyx":3970
 *     def dotFull_check(self, numpy.ndarray[float,ndim=1] full):
 *         cdef float *full_ptr
 *         cdef int my_len=self.my_len             # <<<<<<<<<<<<<<
 *         cdef int full_len=len(full)
 *         # boundary check
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  __pyx_v_my_len = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":3971
 *         cdef float *full_ptr
 *         cdef int my_len=self.my_len
 *         cdef int full_len=len(full)             # <<<<<<<<<<<<<<
 *         # boundary check
 *         full[self.idx_ptr[self.my_len-1]]
 */
  __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_full)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_full_len = __pyx_t_2;

  /* "lurrn/sparsmat.pyx":3973
 *         cdef int full_len=len(full)
 *         # boundary check
 *         full[self.idx_ptr[self.my_len-1]]             # <<<<<<<<<<<<<<
 *         full_ptr=<float*>full.data
 *         return self._dotFull(full_ptr)
 */
  __pyx_t_3 = (__pyx_v_self->idx_ptr[(__pyx_v_self->my_len - 1)]);
  __pyx_t_4 = -1;
  if (unlikely(__pyx_t_3 >= (size_t)__pyx_pybuffernd_full.diminfo[0].shape)) __pyx_t_4 = 0;
  if (unlikely(__pyx_t_4 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_4);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  (*__Pyx_BufPtrStrided1d(float *, __pyx_pybuffernd_full.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_full.diminfo[0].strides));

  /* "lurrn/sparsmat.pyx":3974
 *         # boundary check
 *         full[self.idx_ptr[self.my_len-1]]
 *         full_ptr=<float*>full.data             # <<<<<<<<<<<<<<
 *         return self._dotFull(full_ptr)
 *     def dotMatrix(self, numpy.ndarray[float,ndim=2] full):
 */
  __pyx_v_full_ptr = ((float *)__pyx_v_full->data);

  /* "lurrn/sparsmat.pyx":3975
 *         full[self.idx_ptr[self.my_len-1]]
 *         full_ptr=<float*>full.data
 *         return self._dotFull(full_ptr)             # <<<<<<<<<<<<<<
 *     def dotMatrix(self, numpy.ndarray[float,ndim=2] full):
 *         cdef numpy.ndarray[float,ndim=1] result
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = PyFloat_FromDouble(((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self->__pyx_vtab)->_dotFull(__pyx_v_self, __pyx_v_full_ptr)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3968
 *         full_ptr=<float*>full.data
 *         return self._dotFull_partial(full_ptr,my_len)
 *     def dotFull_check(self, numpy.ndarray[float,ndim=1] full):             # <<<<<<<<<<<<<<
 *         cdef float *full_ptr
 *         cdef int my_len=self.my_len
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_full.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.dotFull_check", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_full.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3976
 *         full_ptr=<float*>full.data
 *         return self._dotFull(full_ptr)
 *     def dotMatrix(self, numpy.ndarray[float,ndim=2] full):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[float,ndim=1] result
 *         result = numpy.zeros(full.shape[1], numpy.float32)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_31dotMatrix(PyObject *__pyx_v_self, PyObject *__pyx_v_full); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_31dotMatrix(PyObject *__pyx_v_self, PyObject *__pyx_v_full) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dotMatrix (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_full), __pyx_ptype_5numpy_ndarray, 1, "full", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_30dotMatrix(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((PyArrayObject *)__pyx_v_full));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_30dotMatrix(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, PyArrayObject *__pyx_v_full) {
  PyArrayObject *__pyx_v_result = 0;
  long __pyx_v_i;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_full;
  __Pyx_Buffer __pyx_pybuffer_full;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  unsigned int __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotMatrix", 0);
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
  __pyx_pybuffer_full.pybuffer.buf = NULL;
  __pyx_pybuffer_full.refcount = 0;
  __pyx_pybuffernd_full.data = NULL;
  __pyx_pybuffernd_full.rcbuffer = &__pyx_pybuffer_full;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_full.rcbuffer->pybuffer, (PyObject*)__pyx_v_full, &__Pyx_TypeInfo_float, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_full.diminfo[0].strides = __pyx_pybuffernd_full.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_full.diminfo[0].shape = __pyx_pybuffernd_full.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_full.diminfo[1].strides = __pyx_pybuffernd_full.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_full.diminfo[1].shape = __pyx_pybuffernd_full.rcbuffer->pybuffer.shape[1];

  /* "lurrn/sparsmat.pyx":3978
 *     def dotMatrix(self, numpy.ndarray[float,ndim=2] full):
 *         cdef numpy.ndarray[float,ndim=1] result
 *         result = numpy.zeros(full.shape[1], numpy.float32)             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result += full[self.idx_ptr[i]] * self.vals_ptr[i]
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_full->dimensions[1])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_float, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_float, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __pyx_v_result = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":3979
 *         cdef numpy.ndarray[float,ndim=1] result
 *         result = numpy.zeros(full.shape[1], numpy.float32)
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result += full[self.idx_ptr[i]] * self.vals_ptr[i]
 *         return result
 */
  __pyx_t_13 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_13; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3980
 *         result = numpy.zeros(full.shape[1], numpy.float32)
 *         for i from 0<=i<self.my_len:
 *             result += full[self.idx_ptr[i]] * self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *         return result
 *     cdef void _axpy(self, float *x_ptr, float a):
 */
    __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_full), (__pyx_v_self->idx_ptr[__pyx_v_i]), coordinate_t, 0, __Pyx_PyInt_From_coordinate_t, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3980; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyFloat_FromDouble((__pyx_v_self->vals_ptr[__pyx_v_i])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = PyNumber_Multiply(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), __pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = ((PyArrayObject *)__pyx_t_3);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
      __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_float, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_9 < 0)) {
        PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_float, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_12, __pyx_t_11, __pyx_t_10);
        }
      }
      __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_8 = 0;
    __Pyx_DECREF_SET(__pyx_v_result, ((PyArrayObject *)__pyx_t_3));
    __pyx_t_3 = 0;
  }

  /* "lurrn/sparsmat.pyx":3981
 *         for i from 0<=i<self.my_len:
 *             result += full[self.idx_ptr[i]] * self.vals_ptr[i]
 *         return result             # <<<<<<<<<<<<<<
 *     cdef void _axpy(self, float *x_ptr, float a):
 *         for i from 0<=i<self.my_len:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3976
 *         full_ptr=<float*>full.data
 *         return self._dotFull(full_ptr)
 *     def dotMatrix(self, numpy.ndarray[float,ndim=2] full):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[float,ndim=1] result
 *         result = numpy.zeros(full.shape[1], numpy.float32)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_full.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.dotMatrix", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_full.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3982
 *             result += full[self.idx_ptr[i]] * self.vals_ptr[i]
 *         return result
 *     cdef void _axpy(self, float *x_ptr, float a):             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             x_ptr[self.idx_ptr[i]]+=a*self.vals_ptr[i]
 */

static void __pyx_f_5lurrn_8sparsmat_13SparseVectorF__axpy(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, float *__pyx_v_x_ptr, float __pyx_v_a) {
  long __pyx_v_i;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  coordinate_t __pyx_t_2;
  __Pyx_RefNannySetupContext("_axpy", 0);

  /* "lurrn/sparsmat.pyx":3983
 *         return result
 *     cdef void _axpy(self, float *x_ptr, float a):
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             x_ptr[self.idx_ptr[i]]+=a*self.vals_ptr[i]
 *     def axpy(self, numpy.ndarray[float,ndim=1] x, float a=1):
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":3984
 *     cdef void _axpy(self, float *x_ptr, float a):
 *         for i from 0<=i<self.my_len:
 *             x_ptr[self.idx_ptr[i]]+=a*self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *     def axpy(self, numpy.ndarray[float,ndim=1] x, float a=1):
 *         # boundary check
 */
    __pyx_t_2 = (__pyx_v_self->idx_ptr[__pyx_v_i]);
    (__pyx_v_x_ptr[__pyx_t_2]) = ((__pyx_v_x_ptr[__pyx_t_2]) + (__pyx_v_a * (__pyx_v_self->vals_ptr[__pyx_v_i])));
  }

  /* "lurrn/sparsmat.pyx":3982
 *             result += full[self.idx_ptr[i]] * self.vals_ptr[i]
 *         return result
 *     cdef void _axpy(self, float *x_ptr, float a):             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             x_ptr[self.idx_ptr[i]]+=a*self.vals_ptr[i]
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":3985
 *         for i from 0<=i<self.my_len:
 *             x_ptr[self.idx_ptr[i]]+=a*self.vals_ptr[i]
 *     def axpy(self, numpy.ndarray[float,ndim=1] x, float a=1):             # <<<<<<<<<<<<<<
 *         # boundary check
 *         x[self.idx_ptr[self.my_len-1]]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_33axpy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_33axpy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_x = 0;
  float __pyx_v_a;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("axpy (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_a,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "axpy") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3985; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_x = ((PyArrayObject *)values[0]);
    if (values[1]) {
      __pyx_v_a = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_a == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3985; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_a = ((float)1.0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("axpy", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3985; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.axpy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_32axpy(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), __pyx_v_x, __pyx_v_a);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_32axpy(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, PyArrayObject *__pyx_v_x, float __pyx_v_a) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_x;
  __Pyx_Buffer __pyx_pybuffer_x;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  coordinate_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("axpy", 0);
  __pyx_pybuffer_x.pybuffer.buf = NULL;
  __pyx_pybuffer_x.refcount = 0;
  __pyx_pybuffernd_x.data = NULL;
  __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_float, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0];

  /* "lurrn/sparsmat.pyx":3987
 *     def axpy(self, numpy.ndarray[float,ndim=1] x, float a=1):
 *         # boundary check
 *         x[self.idx_ptr[self.my_len-1]]             # <<<<<<<<<<<<<<
 *         self._axpy(<float *>x.data,a)
 *     cpdef float sqdist(self, SparseVectorF other):
 */
  __pyx_t_1 = (__pyx_v_self->idx_ptr[(__pyx_v_self->my_len - 1)]);
  __pyx_t_2 = -1;
  if (unlikely(__pyx_t_1 >= (size_t)__pyx_pybuffernd_x.diminfo[0].shape)) __pyx_t_2 = 0;
  if (unlikely(__pyx_t_2 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_2);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  (*__Pyx_BufPtrStrided1d(float *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_x.diminfo[0].strides));

  /* "lurrn/sparsmat.pyx":3988
 *         # boundary check
 *         x[self.idx_ptr[self.my_len-1]]
 *         self._axpy(<float *>x.data,a)             # <<<<<<<<<<<<<<
 *     cpdef float sqdist(self, SparseVectorF other):
 *         """computes ||x-y||^2"""
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self->__pyx_vtab)->_axpy(__pyx_v_self, ((float *)__pyx_v_x->data), __pyx_v_a);

  /* "lurrn/sparsmat.pyx":3985
 *         for i from 0<=i<self.my_len:
 *             x_ptr[self.idx_ptr[i]]+=a*self.vals_ptr[i]
 *     def axpy(self, numpy.ndarray[float,ndim=1] x, float a=1):             # <<<<<<<<<<<<<<
 *         # boundary check
 *         x[self.idx_ptr[self.my_len-1]]
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.axpy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":3989
 *         x[self.idx_ptr[self.my_len-1]]
 *         self._axpy(<float *>x.data,a)
 *     cpdef float sqdist(self, SparseVectorF other):             # <<<<<<<<<<<<<<
 *         """computes ||x-y||^2"""
 *         cdef float s=0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_35sqdist(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static float __pyx_f_5lurrn_8sparsmat_13SparseVectorF_sqdist(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other, int __pyx_skip_dispatch) {
  float __pyx_v_s;
  float __pyx_v_val;
  int __pyx_v_i1;
  int __pyx_v_i2;
  float __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  float __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sqdist", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_sqdist); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_35sqdist)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_6 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":3991
 *     cpdef float sqdist(self, SparseVectorF other):
 *         """computes ||x-y||^2"""
 *         cdef float s=0             # <<<<<<<<<<<<<<
 *         cdef float val
 *         cdef int i1=0,i2=0
 */
  __pyx_v_s = 0.0;

  /* "lurrn/sparsmat.pyx":3993
 *         cdef float s=0
 *         cdef float val
 *         cdef int i1=0,i2=0             # <<<<<<<<<<<<<<
 *         while i1<self.my_len and i2<other.my_len:
 *             if self.idx_ptr[i1]<other.idx_ptr[i2]:
 */
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":3994
 *         cdef float val
 *         cdef int i1=0,i2=0
 *         while i1<self.my_len and i2<other.my_len:             # <<<<<<<<<<<<<<
 *             if self.idx_ptr[i1]<other.idx_ptr[i2]:
 *                 val=self.vals_ptr[i1]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i1 < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_i2 < __pyx_v_other->my_len) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":3995
 *         cdef int i1=0,i2=0
 *         while i1<self.my_len and i2<other.my_len:
 *             if self.idx_ptr[i1]<other.idx_ptr[i2]:             # <<<<<<<<<<<<<<
 *                 val=self.vals_ptr[i1]
 *                 s+=val*val
 */
    __pyx_t_7 = (((__pyx_v_self->idx_ptr[__pyx_v_i1]) < (__pyx_v_other->idx_ptr[__pyx_v_i2])) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":3996
 *         while i1<self.my_len and i2<other.my_len:
 *             if self.idx_ptr[i1]<other.idx_ptr[i2]:
 *                 val=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                 s+=val*val
 *                 i1+=1
 */
      __pyx_v_val = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

      /* "lurrn/sparsmat.pyx":3997
 *             if self.idx_ptr[i1]<other.idx_ptr[i2]:
 *                 val=self.vals_ptr[i1]
 *                 s+=val*val             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             elif self.idx_ptr[i1]>other.idx_ptr[i2]:
 */
      __pyx_v_s = (__pyx_v_s + (__pyx_v_val * __pyx_v_val));

      /* "lurrn/sparsmat.pyx":3998
 *                 val=self.vals_ptr[i1]
 *                 s+=val*val
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             elif self.idx_ptr[i1]>other.idx_ptr[i2]:
 *                 val=other.vals_ptr[i2]
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":3999
 *                 s+=val*val
 *                 i1+=1
 *             elif self.idx_ptr[i1]>other.idx_ptr[i2]:             # <<<<<<<<<<<<<<
 *                 val=other.vals_ptr[i2]
 *                 s+=val*val
 */
    __pyx_t_7 = (((__pyx_v_self->idx_ptr[__pyx_v_i1]) > (__pyx_v_other->idx_ptr[__pyx_v_i2])) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":4000
 *                 i1+=1
 *             elif self.idx_ptr[i1]>other.idx_ptr[i2]:
 *                 val=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 s+=val*val
 *                 i2+=1
 */
      __pyx_v_val = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":4001
 *             elif self.idx_ptr[i1]>other.idx_ptr[i2]:
 *                 val=other.vals_ptr[i2]
 *                 s+=val*val             # <<<<<<<<<<<<<<
 *                 i2+=1
 *             else:
 */
      __pyx_v_s = (__pyx_v_s + (__pyx_v_val * __pyx_v_val));

      /* "lurrn/sparsmat.pyx":4002
 *                 val=other.vals_ptr[i2]
 *                 s+=val*val
 *                 i2+=1             # <<<<<<<<<<<<<<
 *             else:
 *                 val=self.vals_ptr[i1]-other.vals_ptr[i2]
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":4004
 *                 i2+=1
 *             else:
 *                 val=self.vals_ptr[i1]-other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 s+=val*val
 *                 i1+=1
 */
      __pyx_v_val = ((__pyx_v_self->vals_ptr[__pyx_v_i1]) - (__pyx_v_other->vals_ptr[__pyx_v_i2]));

      /* "lurrn/sparsmat.pyx":4005
 *             else:
 *                 val=self.vals_ptr[i1]-other.vals_ptr[i2]
 *                 s+=val*val             # <<<<<<<<<<<<<<
 *                 i1+=1
 *                 i2+=1
 */
      __pyx_v_s = (__pyx_v_s + (__pyx_v_val * __pyx_v_val));

      /* "lurrn/sparsmat.pyx":4006
 *                 val=self.vals_ptr[i1]-other.vals_ptr[i2]
 *                 s+=val*val
 *                 i1+=1             # <<<<<<<<<<<<<<
 *                 i2+=1
 *         while i1<self.my_len:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);

      /* "lurrn/sparsmat.pyx":4007
 *                 s+=val*val
 *                 i1+=1
 *                 i2+=1             # <<<<<<<<<<<<<<
 *         while i1<self.my_len:
 *             val=self.vals_ptr[i1]
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":4008
 *                 i1+=1
 *                 i2+=1
 *         while i1<self.my_len:             # <<<<<<<<<<<<<<
 *             val=self.vals_ptr[i1]
 *             s+=val*val
 */
  while (1) {
    __pyx_t_7 = ((__pyx_v_i1 < __pyx_v_self->my_len) != 0);
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":4009
 *                 i2+=1
 *         while i1<self.my_len:
 *             val=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *             s+=val*val
 *             i1+=1
 */
    __pyx_v_val = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":4010
 *         while i1<self.my_len:
 *             val=self.vals_ptr[i1]
 *             s+=val*val             # <<<<<<<<<<<<<<
 *             i1+=1
 *         while i2<other.my_len:
 */
    __pyx_v_s = (__pyx_v_s + (__pyx_v_val * __pyx_v_val));

    /* "lurrn/sparsmat.pyx":4011
 *             val=self.vals_ptr[i1]
 *             s+=val*val
 *             i1+=1             # <<<<<<<<<<<<<<
 *         while i2<other.my_len:
 *             val=other.vals_ptr[i2]
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);
  }

  /* "lurrn/sparsmat.pyx":4012
 *             s+=val*val
 *             i1+=1
 *         while i2<other.my_len:             # <<<<<<<<<<<<<<
 *             val=other.vals_ptr[i2]
 *             s+=val*val
 */
  while (1) {
    __pyx_t_7 = ((__pyx_v_i2 < __pyx_v_other->my_len) != 0);
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":4013
 *             i1+=1
 *         while i2<other.my_len:
 *             val=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *             s+=val*val
 *             i2+=1
 */
    __pyx_v_val = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":4014
 *         while i2<other.my_len:
 *             val=other.vals_ptr[i2]
 *             s+=val*val             # <<<<<<<<<<<<<<
 *             i2+=1
 *         return s
 */
    __pyx_v_s = (__pyx_v_s + (__pyx_v_val * __pyx_v_val));

    /* "lurrn/sparsmat.pyx":4015
 *             val=other.vals_ptr[i2]
 *             s+=val*val
 *             i2+=1             # <<<<<<<<<<<<<<
 *         return s
 *     def write_pairs(self, f, delim=':'):
 */
    __pyx_v_i2 = (__pyx_v_i2 + 1);
  }

  /* "lurrn/sparsmat.pyx":4016
 *             s+=val*val
 *             i2+=1
 *         return s             # <<<<<<<<<<<<<<
 *     def write_pairs(self, f, delim=':'):
 *         cdef int i
 */
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":3989
 *         x[self.idx_ptr[self.my_len-1]]
 *         self._axpy(<float *>x.data,a)
 *     cpdef float sqdist(self, SparseVectorF other):             # <<<<<<<<<<<<<<
 *         """computes ||x-y||^2"""
 *         cdef float s=0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorF.sqdist", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_35sqdist(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_5lurrn_8sparsmat_13SparseVectorF_34sqdist[] = "computes ||x-y||^2";
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_35sqdist(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sqdist (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorF, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_34sqdist(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_34sqdist(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sqdist", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorF_sqdist(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.sqdist", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4017
 *             i2+=1
 *         return s
 *     def write_pairs(self, f, delim=':'):             # <<<<<<<<<<<<<<
 *         cdef int i
 *         w_func=f.write
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_37write_pairs(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_37write_pairs(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_f = 0;
  PyObject *__pyx_v_delim = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_pairs (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_f,&__pyx_n_s_delim,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_kp_s__24);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_f)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_delim);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_pairs") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4017; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_f = values[0];
    __pyx_v_delim = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_pairs", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4017; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.write_pairs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_36write_pairs(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), __pyx_v_f, __pyx_v_delim);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_36write_pairs(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, PyObject *__pyx_v_f, PyObject *__pyx_v_delim) {
  int __pyx_v_i;
  PyObject *__pyx_v_w_func = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  unsigned int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("write_pairs", 0);

  /* "lurrn/sparsmat.pyx":4019
 *     def write_pairs(self, f, delim=':'):
 *         cdef int i
 *         w_func=f.write             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             # svmlight does not want 0 as index
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_w_func = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4020
 *         cdef int i
 *         w_func=f.write
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             # svmlight does not want 0 as index
 *             w_func(' %d%s%s'%(self.idx_ptr[i]+1,delim,self.vals_ptr[i]))
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4022
 *         for i from 0<=i<self.my_len:
 *             # svmlight does not want 0 as index
 *             w_func(' %d%s%s'%(self.idx_ptr[i]+1,delim,self.vals_ptr[i]))             # <<<<<<<<<<<<<<
 *     def __imul__(self, float a):
 *         cdef coordinate_t i
 */
    __pyx_t_3 = __Pyx_PyInt_From_long(((__pyx_v_self->idx_ptr[__pyx_v_i]) + 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyFloat_FromDouble((__pyx_v_self->vals_ptr[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_delim);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_delim);
    __Pyx_GIVEREF(__pyx_v_delim);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_d_s_s, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_INCREF(__pyx_v_w_func);
    __pyx_t_5 = __pyx_v_w_func; __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4017
 *             i2+=1
 *         return s
 *     def write_pairs(self, f, delim=':'):             # <<<<<<<<<<<<<<
 *         cdef int i
 *         w_func=f.write
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.write_pairs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_w_func);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4023
 *             # svmlight does not want 0 as index
 *             w_func(' %d%s%s'%(self.idx_ptr[i]+1,delim,self.vals_ptr[i]))
 *     def __imul__(self, float a):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_39__imul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_a); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_39__imul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_a) {
  float __pyx_v_a;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__imul__ (wrapper)", 0);
  assert(__pyx_arg_a); {
    __pyx_v_a = __pyx_PyFloat_AsFloat(__pyx_arg_a); if (unlikely((__pyx_v_a == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4023; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.__imul__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_38__imul__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((float)__pyx_v_a));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_38__imul__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, float __pyx_v_a) {
  coordinate_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  coordinate_t __pyx_t_2;
  __Pyx_RefNannySetupContext("__imul__", 0);

  /* "lurrn/sparsmat.pyx":4025
 *     def __imul__(self, float a):
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             self.vals_ptr[i] *= a
 *         return self
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4026
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 *             self.vals_ptr[i] *= a             # <<<<<<<<<<<<<<
 *         return self
 *     def __idiv__(self, float a):
 */
    __pyx_t_2 = __pyx_v_i;
    (__pyx_v_self->vals_ptr[__pyx_t_2]) = ((__pyx_v_self->vals_ptr[__pyx_t_2]) * __pyx_v_a);
  }

  /* "lurrn/sparsmat.pyx":4027
 *         for i from 0<=i<self.my_len:
 *             self.vals_ptr[i] *= a
 *         return self             # <<<<<<<<<<<<<<
 *     def __idiv__(self, float a):
 *         cdef coordinate_t i
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4023
 *             # svmlight does not want 0 as index
 *             w_func(' %d%s%s'%(self.idx_ptr[i]+1,delim,self.vals_ptr[i]))
 *     def __imul__(self, float a):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4028
 *             self.vals_ptr[i] *= a
 *         return self
 *     def __idiv__(self, float a):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 */

/* Python wrapper */
#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_41__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_a); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_41__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_a) {
  float __pyx_v_a;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__idiv__ (wrapper)", 0);
  assert(__pyx_arg_a); {
    __pyx_v_a = __pyx_PyFloat_AsFloat(__pyx_arg_a); if (unlikely((__pyx_v_a == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4028; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.__idiv__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_40__idiv__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((float)__pyx_v_a));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_40__idiv__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, float __pyx_v_a) {
  coordinate_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  coordinate_t __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__idiv__", 0);

  /* "lurrn/sparsmat.pyx":4030
 *     def __idiv__(self, float a):
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             self.vals_ptr[i] /= a
 *         return self
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4031
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 *             self.vals_ptr[i] /= a             # <<<<<<<<<<<<<<
 *         return self
 *     cpdef SparseVectorF min_vals(self, SparseVectorF other):
 */
    __pyx_t_2 = __pyx_v_i;
    if (unlikely(__pyx_v_a == 0)) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      #ifdef WITH_THREAD
      PyGILState_Release(__pyx_gilstate_save);
      #endif
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    (__pyx_v_self->vals_ptr[__pyx_t_2]) = ((__pyx_v_self->vals_ptr[__pyx_t_2]) / __pyx_v_a);
  }

  /* "lurrn/sparsmat.pyx":4032
 *         for i from 0<=i<self.my_len:
 *             self.vals_ptr[i] /= a
 *         return self             # <<<<<<<<<<<<<<
 *     cpdef SparseVectorF min_vals(self, SparseVectorF other):
 *         cdef SparseVectorF result
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4028
 *             self.vals_ptr[i] *= a
 *         return self
 *     def __idiv__(self, float a):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.__idiv__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

/* "lurrn/sparsmat.pyx":4033
 *             self.vals_ptr[i] /= a
 *         return self
 *     cpdef SparseVectorF min_vals(self, SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorF result
 *         cdef coordinate_t i1, i2, k, idx1, idx2
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_43min_vals(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_f_5lurrn_8sparsmat_13SparseVectorF_min_vals(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other, int __pyx_skip_dispatch) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_result = 0;
  coordinate_t __pyx_v_i1;
  coordinate_t __pyx_v_i2;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_idx1;
  coordinate_t __pyx_v_idx2;
  PyObject *__pyx_v_val1 = NULL;
  PyObject *__pyx_v_val2 = NULL;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  unsigned int __pyx_t_7;
  int __pyx_t_8;
  float __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("min_vals", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_min_vals); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_43min_vals)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_SparseVectorF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4036
 *         cdef SparseVectorF result
 *         cdef coordinate_t i1, i2, k, idx1, idx2
 *         result=SparseVectorF()             # <<<<<<<<<<<<<<
 *         if self.my_len<other.my_len:
 *             result.my_len=self.my_len
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorF)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4037
 *         cdef coordinate_t i1, i2, k, idx1, idx2
 *         result=SparseVectorF()
 *         if self.my_len<other.my_len:             # <<<<<<<<<<<<<<
 *             result.my_len=self.my_len
 *         else:
 */
  __pyx_t_6 = ((__pyx_v_self->my_len < __pyx_v_other->my_len) != 0);
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":4038
 *         result=SparseVectorF()
 *         if self.my_len<other.my_len:
 *             result.my_len=self.my_len             # <<<<<<<<<<<<<<
 *         else:
 *             result.my_len=other.my_len
 */
    __pyx_t_7 = __pyx_v_self->my_len;
    __pyx_v_result->my_len = __pyx_t_7;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":4040
 *             result.my_len=self.my_len
 *         else:
 *             result.my_len=other.my_len             # <<<<<<<<<<<<<<
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))
 */
    __pyx_t_7 = __pyx_v_other->my_len;
    __pyx_v_result->my_len = __pyx_t_7;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":4041
 *         else:
 *             result.my_len=other.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))
 *         i1=i2=k=0
 */
  __pyx_v_result->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":4042
 *             result.my_len=other.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))             # <<<<<<<<<<<<<<
 *         i1=i2=k=0
 *         while i1<self.my_len and i2<other.my_len:
 */
  __pyx_v_result->vals_ptr = ((float *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(float)))));

  /* "lurrn/sparsmat.pyx":4043
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))
 *         i1=i2=k=0             # <<<<<<<<<<<<<<
 *         while i1<self.my_len and i2<other.my_len:
 *            idx1=self.idx_ptr[i1]
 */
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":4044
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))
 *         i1=i2=k=0
 *         while i1<self.my_len and i2<other.my_len:             # <<<<<<<<<<<<<<
 *            idx1=self.idx_ptr[i1]
 *            idx2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i1 < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_6 = __pyx_t_8;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_i2 < __pyx_v_other->my_len) != 0);
    __pyx_t_6 = __pyx_t_8;
    __pyx_L6_bool_binop_done:;
    if (!__pyx_t_6) break;

    /* "lurrn/sparsmat.pyx":4045
 *         i1=i2=k=0
 *         while i1<self.my_len and i2<other.my_len:
 *            idx1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *            idx2=other.idx_ptr[i2]
 *            if idx1<idx2:
 */
    __pyx_v_idx1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":4046
 *         while i1<self.my_len and i2<other.my_len:
 *            idx1=self.idx_ptr[i1]
 *            idx2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *            if idx1<idx2:
 *                i1+=1
 */
    __pyx_v_idx2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":4047
 *            idx1=self.idx_ptr[i1]
 *            idx2=other.idx_ptr[i2]
 *            if idx1<idx2:             # <<<<<<<<<<<<<<
 *                i1+=1
 *            elif idx1>idx2:
 */
    __pyx_t_6 = ((__pyx_v_idx1 < __pyx_v_idx2) != 0);
    if (__pyx_t_6) {

      /* "lurrn/sparsmat.pyx":4048
 *            idx2=other.idx_ptr[i2]
 *            if idx1<idx2:
 *                i1+=1             # <<<<<<<<<<<<<<
 *            elif idx1>idx2:
 *                i2+=1
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L8;
    }

    /* "lurrn/sparsmat.pyx":4049
 *            if idx1<idx2:
 *                i1+=1
 *            elif idx1>idx2:             # <<<<<<<<<<<<<<
 *                i2+=1
 *            else:
 */
    __pyx_t_6 = ((__pyx_v_idx1 > __pyx_v_idx2) != 0);
    if (__pyx_t_6) {

      /* "lurrn/sparsmat.pyx":4050
 *                i1+=1
 *            elif idx1>idx2:
 *                i2+=1             # <<<<<<<<<<<<<<
 *            else:
 *                result.idx_ptr[k]=idx1
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      goto __pyx_L8;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":4052
 *                i2+=1
 *            else:
 *                result.idx_ptr[k]=idx1             # <<<<<<<<<<<<<<
 *                val1=self.vals_ptr[i1]
 *                val2=other.vals_ptr[i2]
 */
      (__pyx_v_result->idx_ptr[__pyx_v_k]) = __pyx_v_idx1;

      /* "lurrn/sparsmat.pyx":4053
 *            else:
 *                result.idx_ptr[k]=idx1
 *                val1=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                val2=other.vals_ptr[i2]
 *                if val1<val2:
 */
      __pyx_t_1 = PyFloat_FromDouble((__pyx_v_self->vals_ptr[__pyx_v_i1])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_val1, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "lurrn/sparsmat.pyx":4054
 *                result.idx_ptr[k]=idx1
 *                val1=self.vals_ptr[i1]
 *                val2=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                if val1<val2:
 *                    result.vals_ptr[k]=val1
 */
      __pyx_t_1 = PyFloat_FromDouble((__pyx_v_other->vals_ptr[__pyx_v_i2])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_val2, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "lurrn/sparsmat.pyx":4055
 *                val1=self.vals_ptr[i1]
 *                val2=other.vals_ptr[i2]
 *                if val1<val2:             # <<<<<<<<<<<<<<
 *                    result.vals_ptr[k]=val1
 *                else:
 */
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_val1, __pyx_v_val2, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_6) {

        /* "lurrn/sparsmat.pyx":4056
 *                val2=other.vals_ptr[i2]
 *                if val1<val2:
 *                    result.vals_ptr[k]=val1             # <<<<<<<<<<<<<<
 *                else:
 *                    result.vals_ptr[k]=val2
 */
        __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_v_val1); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        (__pyx_v_result->vals_ptr[__pyx_v_k]) = __pyx_t_9;
        goto __pyx_L9;
      }
      /*else*/ {

        /* "lurrn/sparsmat.pyx":4058
 *                    result.vals_ptr[k]=val1
 *                else:
 *                    result.vals_ptr[k]=val2             # <<<<<<<<<<<<<<
 *                i1+=1
 *                i2+=1
 */
        __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_v_val2); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        (__pyx_v_result->vals_ptr[__pyx_v_k]) = __pyx_t_9;
      }
      __pyx_L9:;

      /* "lurrn/sparsmat.pyx":4059
 *                else:
 *                    result.vals_ptr[k]=val2
 *                i1+=1             # <<<<<<<<<<<<<<
 *                i2+=1
 *                k+=1
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);

      /* "lurrn/sparsmat.pyx":4060
 *                    result.vals_ptr[k]=val2
 *                i1+=1
 *                i2+=1             # <<<<<<<<<<<<<<
 *                k+=1
 *         result.my_len=k
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":4061
 *                i1+=1
 *                i2+=1
 *                k+=1             # <<<<<<<<<<<<<<
 *         result.my_len=k
 *         return result
 */
      __pyx_v_k = (__pyx_v_k + 1);
    }
    __pyx_L8:;
  }

  /* "lurrn/sparsmat.pyx":4062
 *                i2+=1
 *                k+=1
 *         result.my_len=k             # <<<<<<<<<<<<<<
 *         return result
 *     def scale_array(SparseVectorF self, numpy.ndarray[float, ndim=1] a):
 */
  __pyx_v_result->my_len = __pyx_v_k;

  /* "lurrn/sparsmat.pyx":4063
 *                k+=1
 *         result.my_len=k
 *         return result             # <<<<<<<<<<<<<<
 *     def scale_array(SparseVectorF self, numpy.ndarray[float, ndim=1] a):
 *         cdef SparseVectorF result
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4033
 *             self.vals_ptr[i] /= a
 *         return self
 *     cpdef SparseVectorF min_vals(self, SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorF result
 *         cdef coordinate_t i1, i2, k, idx1, idx2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.min_vals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_val1);
  __Pyx_XDECREF(__pyx_v_val2);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_43min_vals(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_43min_vals(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("min_vals (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorF, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_42min_vals(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_42min_vals(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("min_vals", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_13SparseVectorF_min_vals(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.min_vals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4064
 *         result.my_len=k
 *         return result
 *     def scale_array(SparseVectorF self, numpy.ndarray[float, ndim=1] a):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorF result
 *         cdef coordinate_t i
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_45scale_array(PyObject *__pyx_v_self, PyObject *__pyx_v_a); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_45scale_array(PyObject *__pyx_v_self, PyObject *__pyx_v_a) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("scale_array (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_5numpy_ndarray, 1, "a", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_44scale_array(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((PyArrayObject *)__pyx_v_a));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_44scale_array(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, PyArrayObject *__pyx_v_a) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_result = 0;
  coordinate_t __pyx_v_i;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_a;
  __Pyx_Buffer __pyx_pybuffer_a;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  unsigned int __pyx_t_2;
  coordinate_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("scale_array", 0);
  __pyx_pybuffer_a.pybuffer.buf = NULL;
  __pyx_pybuffer_a.refcount = 0;
  __pyx_pybuffernd_a.data = NULL;
  __pyx_pybuffernd_a.rcbuffer = &__pyx_pybuffer_a;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_a.rcbuffer->pybuffer, (PyObject*)__pyx_v_a, &__Pyx_TypeInfo_float, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_a.diminfo[0].strides = __pyx_pybuffernd_a.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_a.diminfo[0].shape = __pyx_pybuffernd_a.rcbuffer->pybuffer.shape[0];

  /* "lurrn/sparsmat.pyx":4067
 *         cdef SparseVectorF result
 *         cdef coordinate_t i
 *         result=SparseVectorF()             # <<<<<<<<<<<<<<
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorF)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4068
 *         cdef coordinate_t i
 *         result=SparseVectorF()
 *         result.my_len=self.my_len             # <<<<<<<<<<<<<<
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  __pyx_v_result->my_len = __pyx_t_2;

  /* "lurrn/sparsmat.pyx":4069
 *         result=SparseVectorF()
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_result->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":4070
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]
 */
  __pyx_v_result->vals_ptr = ((float *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(float)))));

  /* "lurrn/sparsmat.pyx":4071
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result.idx_ptr[i]=self.idx_ptr[i]
 *         for i from 0<=i<self.my_len:
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4072
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]*a[self.idx_ptr[i]]
 */
    (__pyx_v_result->idx_ptr[__pyx_v_i]) = (__pyx_v_self->idx_ptr[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":4073
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result.vals_ptr[i]=self.vals_ptr[i]*a[self.idx_ptr[i]]
 *         return result
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4074
 *             result.idx_ptr[i]=self.idx_ptr[i]
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]*a[self.idx_ptr[i]]             # <<<<<<<<<<<<<<
 *         return result
 *     def __div__(SparseVectorF self, float a):
 */
    __pyx_t_3 = (__pyx_v_self->idx_ptr[__pyx_v_i]);
    __pyx_t_4 = -1;
    if (unlikely(__pyx_t_3 >= (size_t)__pyx_pybuffernd_a.diminfo[0].shape)) __pyx_t_4 = 0;
    if (unlikely(__pyx_t_4 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_4);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    (__pyx_v_result->vals_ptr[__pyx_v_i]) = ((__pyx_v_self->vals_ptr[__pyx_v_i]) * (*__Pyx_BufPtrStrided1d(float *, __pyx_pybuffernd_a.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_a.diminfo[0].strides)));
  }

  /* "lurrn/sparsmat.pyx":4075
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]*a[self.idx_ptr[i]]
 *         return result             # <<<<<<<<<<<<<<
 *     def __div__(SparseVectorF self, float a):
 *         cdef SparseVectorF result
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4064
 *         result.my_len=k
 *         return result
 *     def scale_array(SparseVectorF self, numpy.ndarray[float, ndim=1] a):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorF result
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_a.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.scale_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_a.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4076
 *             result.vals_ptr[i]=self.vals_ptr[i]*a[self.idx_ptr[i]]
 *         return result
 *     def __div__(SparseVectorF self, float a):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorF result
 *         cdef coordinate_t i
 */

/* Python wrapper */
#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_47__div__(PyObject *__pyx_v_self, PyObject *__pyx_arg_a); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_47__div__(PyObject *__pyx_v_self, PyObject *__pyx_arg_a) {
  float __pyx_v_a;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__div__ (wrapper)", 0);
  assert(__pyx_arg_a); {
    __pyx_v_a = __pyx_PyFloat_AsFloat(__pyx_arg_a); if (unlikely((__pyx_v_a == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4076; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.__div__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_SparseVectorF, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_46__div__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((float)__pyx_v_a));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_46__div__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, float __pyx_v_a) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_result = 0;
  coordinate_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  unsigned int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__div__", 0);

  /* "lurrn/sparsmat.pyx":4079
 *         cdef SparseVectorF result
 *         cdef coordinate_t i
 *         result=SparseVectorF()             # <<<<<<<<<<<<<<
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorF)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4080
 *         cdef coordinate_t i
 *         result=SparseVectorF()
 *         result.my_len=self.my_len             # <<<<<<<<<<<<<<
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  __pyx_v_result->my_len = __pyx_t_2;

  /* "lurrn/sparsmat.pyx":4081
 *         result=SparseVectorF()
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_result->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":4082
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]
 */
  __pyx_v_result->vals_ptr = ((float *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(float)))));

  /* "lurrn/sparsmat.pyx":4083
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result.idx_ptr[i]=self.idx_ptr[i]
 *         for i from 0<=i<self.my_len:
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4084
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]/a
 */
    (__pyx_v_result->idx_ptr[__pyx_v_i]) = (__pyx_v_self->idx_ptr[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":4085
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result.vals_ptr[i]=self.vals_ptr[i]/a
 *         return result
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4086
 *             result.idx_ptr[i]=self.idx_ptr[i]
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]/a             # <<<<<<<<<<<<<<
 *         return result
 *     def __len__(self):
 */
    if (unlikely(__pyx_v_a == 0)) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      #ifdef WITH_THREAD
      PyGILState_Release(__pyx_gilstate_save);
      #endif
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    (__pyx_v_result->vals_ptr[__pyx_v_i]) = ((__pyx_v_self->vals_ptr[__pyx_v_i]) / __pyx_v_a);
  }

  /* "lurrn/sparsmat.pyx":4087
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]/a
 *         return result             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return self.my_len
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4076
 *             result.vals_ptr[i]=self.vals_ptr[i]*a[self.idx_ptr[i]]
 *         return result
 *     def __div__(SparseVectorF self, float a):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorF result
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.__div__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

/* "lurrn/sparsmat.pyx":4088
 *             result.vals_ptr[i]=self.vals_ptr[i]/a
 *         return result
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.my_len
 *     def __add__(SparseVectorF self,SparseVectorF other):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_49__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_49__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_48__len__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_48__len__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":4089
 *         return result
 *     def __len__(self):
 *         return self.my_len             # <<<<<<<<<<<<<<
 *     def __add__(SparseVectorF self,SparseVectorF other):
 *         cdef coordinate_t *new_idx
 */
  __pyx_r = __pyx_v_self->my_len;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4088
 *             result.vals_ptr[i]=self.vals_ptr[i]/a
 *         return result
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.my_len
 *     def __add__(SparseVectorF self,SparseVectorF other):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4090
 *     def __len__(self):
 *         return self.my_len
 *     def __add__(SparseVectorF self,SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *new_idx
 *         cdef float *new_vals
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_51__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_51__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_SparseVectorF, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4090; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorF, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4090; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_50__add__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_50__add__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other) {
  coordinate_t *__pyx_v_new_idx;
  float *__pyx_v_new_vals;
  coordinate_t __pyx_v_i1;
  coordinate_t __pyx_v_i2;
  coordinate_t __pyx_v_i_all;
  coordinate_t __pyx_v_n1;
  coordinate_t __pyx_v_n2;
  coordinate_t __pyx_v_n_all;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  coordinate_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":4098
 *         cdef SparseVectorF result
 *         # first pass: determine how much space we need
 *         n1=self.my_len             # <<<<<<<<<<<<<<
 *         n2=other.my_len
 *         n_all=i1=i2=0
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  __pyx_v_n1 = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":4099
 *         # first pass: determine how much space we need
 *         n1=self.my_len
 *         n2=other.my_len             # <<<<<<<<<<<<<<
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:
 */
  __pyx_t_1 = __pyx_v_other->my_len;
  __pyx_v_n2 = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":4100
 *         n1=self.my_len
 *         n2=other.my_len
 *         n_all=i1=i2=0             # <<<<<<<<<<<<<<
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 */
  __pyx_v_n_all = 0;
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":4101
 *         n2=other.my_len
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:             # <<<<<<<<<<<<<<
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":4102
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1
 */
    __pyx_v_k1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":4103
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1
 */
    __pyx_v_k2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":4104
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1             # <<<<<<<<<<<<<<
 *             if k2>=k1: i1+=1
 *             n_all+=1
 */
    __pyx_t_2 = ((__pyx_v_k1 >= __pyx_v_k2) != 0);
    if (__pyx_t_2) {
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "lurrn/sparsmat.pyx":4105
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1             # <<<<<<<<<<<<<<
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1
 */
    __pyx_t_2 = ((__pyx_v_k2 >= __pyx_v_k1) != 0);
    if (__pyx_t_2) {
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "lurrn/sparsmat.pyx":4106
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1
 *             n_all+=1             # <<<<<<<<<<<<<<
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2
 */
    __pyx_v_n_all = (__pyx_v_n_all + 1);
  }

  /* "lurrn/sparsmat.pyx":4107
 *             if k2>=k1: i1+=1
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1             # <<<<<<<<<<<<<<
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 */
  __pyx_t_2 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
  if (__pyx_t_2) {
    __pyx_v_n_all = (__pyx_v_n_all + (__pyx_v_n1 - __pyx_v_i1));
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "lurrn/sparsmat.pyx":4108
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2             # <<<<<<<<<<<<<<
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 *         new_vals=<float *>PyMem_Malloc(n_all*sizeof(float))
 */
  __pyx_t_2 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
  if (__pyx_t_2) {
    __pyx_v_n_all = (__pyx_v_n_all + (__pyx_v_n2 - __pyx_v_i2));
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "lurrn/sparsmat.pyx":4109
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         new_vals=<float *>PyMem_Malloc(n_all*sizeof(float))
 *         # second pass: fill in the actual values
 */
  __pyx_v_new_idx = ((coordinate_t *)PyMem_Malloc((__pyx_v_n_all * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":4110
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 *         new_vals=<float *>PyMem_Malloc(n_all*sizeof(float))             # <<<<<<<<<<<<<<
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0
 */
  __pyx_v_new_vals = ((float *)PyMem_Malloc((__pyx_v_n_all * (sizeof(float)))));

  /* "lurrn/sparsmat.pyx":4112
 *         new_vals=<float *>PyMem_Malloc(n_all*sizeof(float))
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0             # <<<<<<<<<<<<<<
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 */
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;
  __pyx_v_i_all = 0;

  /* "lurrn/sparsmat.pyx":4113
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0
 *         while i1<n1 and i2<n2:             # <<<<<<<<<<<<<<
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L13_bool_binop_done:;
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":4114
 *         i1=i2=i_all=0
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:
 */
    __pyx_v_k1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":4115
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *             if k1>=k2:
 *                 new_idx[i_all]=k2
 */
    __pyx_v_k2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":4116
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=other.vals_ptr[i2]
 */
    __pyx_t_2 = ((__pyx_v_k1 >= __pyx_v_k2) != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":4117
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:
 *                 new_idx[i_all]=k2             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = __pyx_v_k2;

      /* "lurrn/sparsmat.pyx":4118
 *             if k1>=k2:
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 i2+=1
 *                 if k1==k2:
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":4119
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1             # <<<<<<<<<<<<<<
 *                 if k1==k2:
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":4120
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 *                 if k1==k2:             # <<<<<<<<<<<<<<
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 *                     i1+=1
 */
      __pyx_t_2 = ((__pyx_v_k1 == __pyx_v_k2) != 0);
      if (__pyx_t_2) {

        /* "lurrn/sparsmat.pyx":4121
 *                 i2+=1
 *                 if k1==k2:
 *                     new_vals[i_all]+=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                     i1+=1
 *             elif k2>=k1:
 */
        __pyx_t_4 = __pyx_v_i_all;
        (__pyx_v_new_vals[__pyx_t_4]) = ((__pyx_v_new_vals[__pyx_t_4]) + (__pyx_v_self->vals_ptr[__pyx_v_i1]));

        /* "lurrn/sparsmat.pyx":4122
 *                 if k1==k2:
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 *                     i1+=1             # <<<<<<<<<<<<<<
 *             elif k2>=k1:
 *                 new_idx[i_all]=k1
 */
        __pyx_v_i1 = (__pyx_v_i1 + 1);
        goto __pyx_L16;
      }
      __pyx_L16:;
      goto __pyx_L15;
    }

    /* "lurrn/sparsmat.pyx":4123
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 *                     i1+=1
 *             elif k2>=k1:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]
 */
    __pyx_t_2 = ((__pyx_v_k2 >= __pyx_v_k1) != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":4124
 *                     i1+=1
 *             elif k2>=k1:
 *                 new_idx[i_all]=k1             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = __pyx_v_k1;

      /* "lurrn/sparsmat.pyx":4125
 *             elif k2>=k1:
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             i_all+=1
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

      /* "lurrn/sparsmat.pyx":4126
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             i_all+=1
 *         while i1<n1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L15;
    }
    __pyx_L15:;

    /* "lurrn/sparsmat.pyx":4127
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1
 *             i_all+=1             # <<<<<<<<<<<<<<
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]
 */
    __pyx_v_i_all = (__pyx_v_i_all + 1);
  }

  /* "lurrn/sparsmat.pyx":4128
 *                 i1+=1
 *             i_all+=1
 *         while i1<n1:             # <<<<<<<<<<<<<<
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":4129
 *             i_all+=1
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1
 */
    (__pyx_v_new_idx[__pyx_v_i_all]) = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":4130
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *             i1+=1
 *             i_all+=1
 */
    (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":4131
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1             # <<<<<<<<<<<<<<
 *             i_all+=1
 *         else:
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);

    /* "lurrn/sparsmat.pyx":4132
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1
 *             i_all+=1             # <<<<<<<<<<<<<<
 *         else:
 *             while i2<n2:
 */
    __pyx_v_i_all = (__pyx_v_i_all + 1);
  }

  /* "lurrn/sparsmat.pyx":4134
 *             i_all+=1
 *         else:
 *             while i2<n2:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=other.vals_ptr[i2]
 */
  /*else*/ {
    while (1) {
      __pyx_t_2 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
      if (!__pyx_t_2) break;

      /* "lurrn/sparsmat.pyx":4135
 *         else:
 *             while i2<n2:
 *                 new_idx[i_all]=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":4136
 *             while i2<n2:
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 i2+=1
 *                 i_all+=1
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":4137
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1             # <<<<<<<<<<<<<<
 *                 i_all+=1
 *         assert i_all==n_all
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":4138
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 *                 i_all+=1             # <<<<<<<<<<<<<<
 *         assert i_all==n_all
 *         result=SparseVectorF()
 */
      __pyx_v_i_all = (__pyx_v_i_all + 1);
    }
  }

  /* "lurrn/sparsmat.pyx":4139
 *                 i2+=1
 *                 i_all+=1
 *         assert i_all==n_all             # <<<<<<<<<<<<<<
 *         result=SparseVectorF()
 *         result.my_len=n_all
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_i_all == __pyx_v_n_all) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":4140
 *                 i_all+=1
 *         assert i_all==n_all
 *         result=SparseVectorF()             # <<<<<<<<<<<<<<
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx
 */
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorF)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "lurrn/sparsmat.pyx":4141
 *         assert i_all==n_all
 *         result=SparseVectorF()
 *         result.my_len=n_all             # <<<<<<<<<<<<<<
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals
 */
  __pyx_v_result->my_len = __pyx_v_n_all;

  /* "lurrn/sparsmat.pyx":4142
 *         result=SparseVectorF()
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx             # <<<<<<<<<<<<<<
 *         result.vals_ptr=new_vals
 *         return result
 */
  __pyx_v_result->idx_ptr = __pyx_v_new_idx;

  /* "lurrn/sparsmat.pyx":4143
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals             # <<<<<<<<<<<<<<
 *         return result
 *     def __sub__(SparseVectorF self,SparseVectorF other):
 */
  __pyx_v_result->vals_ptr = __pyx_v_new_vals;

  /* "lurrn/sparsmat.pyx":4144
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals
 *         return result             # <<<<<<<<<<<<<<
 *     def __sub__(SparseVectorF self,SparseVectorF other):
 *         cdef coordinate_t *new_idx
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4090
 *     def __len__(self):
 *         return self.my_len
 *     def __add__(SparseVectorF self,SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *new_idx
 *         cdef float *new_vals
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4145
 *         result.vals_ptr=new_vals
 *         return result
 *     def __sub__(SparseVectorF self,SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *new_idx
 *         cdef float *new_vals
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_53__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_53__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__sub__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_SparseVectorF, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorF, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_52__sub__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_52__sub__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other) {
  coordinate_t *__pyx_v_new_idx;
  float *__pyx_v_new_vals;
  coordinate_t __pyx_v_i1;
  coordinate_t __pyx_v_i2;
  coordinate_t __pyx_v_i_all;
  coordinate_t __pyx_v_n1;
  coordinate_t __pyx_v_n2;
  coordinate_t __pyx_v_n_all;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  coordinate_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__sub__", 0);

  /* "lurrn/sparsmat.pyx":4153
 *         cdef SparseVectorF result
 *         # first pass: determine how much space we need
 *         n1=self.my_len             # <<<<<<<<<<<<<<
 *         n2=other.my_len
 *         n_all=i1=i2=0
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  __pyx_v_n1 = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":4154
 *         # first pass: determine how much space we need
 *         n1=self.my_len
 *         n2=other.my_len             # <<<<<<<<<<<<<<
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:
 */
  __pyx_t_1 = __pyx_v_other->my_len;
  __pyx_v_n2 = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":4155
 *         n1=self.my_len
 *         n2=other.my_len
 *         n_all=i1=i2=0             # <<<<<<<<<<<<<<
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 */
  __pyx_v_n_all = 0;
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":4156
 *         n2=other.my_len
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:             # <<<<<<<<<<<<<<
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":4157
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1
 */
    __pyx_v_k1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":4158
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1
 */
    __pyx_v_k2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":4159
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1             # <<<<<<<<<<<<<<
 *             if k2>=k1: i1+=1
 *             n_all+=1
 */
    __pyx_t_2 = ((__pyx_v_k1 >= __pyx_v_k2) != 0);
    if (__pyx_t_2) {
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "lurrn/sparsmat.pyx":4160
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1             # <<<<<<<<<<<<<<
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1
 */
    __pyx_t_2 = ((__pyx_v_k2 >= __pyx_v_k1) != 0);
    if (__pyx_t_2) {
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "lurrn/sparsmat.pyx":4161
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1
 *             n_all+=1             # <<<<<<<<<<<<<<
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2
 */
    __pyx_v_n_all = (__pyx_v_n_all + 1);
  }

  /* "lurrn/sparsmat.pyx":4162
 *             if k2>=k1: i1+=1
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1             # <<<<<<<<<<<<<<
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 */
  __pyx_t_2 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
  if (__pyx_t_2) {
    __pyx_v_n_all = (__pyx_v_n_all + (__pyx_v_n1 - __pyx_v_i1));
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "lurrn/sparsmat.pyx":4163
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2             # <<<<<<<<<<<<<<
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 *         new_vals=<float *>PyMem_Malloc(n_all*sizeof(float))
 */
  __pyx_t_2 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
  if (__pyx_t_2) {
    __pyx_v_n_all = (__pyx_v_n_all + (__pyx_v_n2 - __pyx_v_i2));
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "lurrn/sparsmat.pyx":4164
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         new_vals=<float *>PyMem_Malloc(n_all*sizeof(float))
 *         # second pass: fill in the actual values
 */
  __pyx_v_new_idx = ((coordinate_t *)PyMem_Malloc((__pyx_v_n_all * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":4165
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 *         new_vals=<float *>PyMem_Malloc(n_all*sizeof(float))             # <<<<<<<<<<<<<<
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0
 */
  __pyx_v_new_vals = ((float *)PyMem_Malloc((__pyx_v_n_all * (sizeof(float)))));

  /* "lurrn/sparsmat.pyx":4167
 *         new_vals=<float *>PyMem_Malloc(n_all*sizeof(float))
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0             # <<<<<<<<<<<<<<
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 */
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;
  __pyx_v_i_all = 0;

  /* "lurrn/sparsmat.pyx":4168
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0
 *         while i1<n1 and i2<n2:             # <<<<<<<<<<<<<<
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L13_bool_binop_done:;
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":4169
 *         i1=i2=i_all=0
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:
 */
    __pyx_v_k1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":4170
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *             if k1>=k2:
 *                 new_idx[i_all]=k2
 */
    __pyx_v_k2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":4171
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 */
    __pyx_t_2 = ((__pyx_v_k1 >= __pyx_v_k2) != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":4172
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:
 *                 new_idx[i_all]=k2             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 *                 i2+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = __pyx_v_k2;

      /* "lurrn/sparsmat.pyx":4173
 *             if k1>=k2:
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=-other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 i2+=1
 *                 if k1==k2:
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (-(__pyx_v_other->vals_ptr[__pyx_v_i2]));

      /* "lurrn/sparsmat.pyx":4174
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 *                 i2+=1             # <<<<<<<<<<<<<<
 *                 if k1==k2:
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":4175
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 *                 i2+=1
 *                 if k1==k2:             # <<<<<<<<<<<<<<
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 *                     i1+=1
 */
      __pyx_t_2 = ((__pyx_v_k1 == __pyx_v_k2) != 0);
      if (__pyx_t_2) {

        /* "lurrn/sparsmat.pyx":4176
 *                 i2+=1
 *                 if k1==k2:
 *                     new_vals[i_all]+=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                     i1+=1
 *             elif k2>=k1:
 */
        __pyx_t_4 = __pyx_v_i_all;
        (__pyx_v_new_vals[__pyx_t_4]) = ((__pyx_v_new_vals[__pyx_t_4]) + (__pyx_v_self->vals_ptr[__pyx_v_i1]));

        /* "lurrn/sparsmat.pyx":4177
 *                 if k1==k2:
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 *                     i1+=1             # <<<<<<<<<<<<<<
 *             elif k2>=k1:
 *                 new_idx[i_all]=k1
 */
        __pyx_v_i1 = (__pyx_v_i1 + 1);
        goto __pyx_L16;
      }
      __pyx_L16:;
      goto __pyx_L15;
    }

    /* "lurrn/sparsmat.pyx":4178
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 *                     i1+=1
 *             elif k2>=k1:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]
 */
    __pyx_t_2 = ((__pyx_v_k2 >= __pyx_v_k1) != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":4179
 *                     i1+=1
 *             elif k2>=k1:
 *                 new_idx[i_all]=k1             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = __pyx_v_k1;

      /* "lurrn/sparsmat.pyx":4180
 *             elif k2>=k1:
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             i_all+=1
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

      /* "lurrn/sparsmat.pyx":4181
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             i_all+=1
 *         while i1<n1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L15;
    }
    __pyx_L15:;

    /* "lurrn/sparsmat.pyx":4182
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1
 *             i_all+=1             # <<<<<<<<<<<<<<
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]
 */
    __pyx_v_i_all = (__pyx_v_i_all + 1);
  }

  /* "lurrn/sparsmat.pyx":4183
 *                 i1+=1
 *             i_all+=1
 *         while i1<n1:             # <<<<<<<<<<<<<<
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":4184
 *             i_all+=1
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1
 */
    (__pyx_v_new_idx[__pyx_v_i_all]) = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":4185
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *             i1+=1
 *             i_all+=1
 */
    (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":4186
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1             # <<<<<<<<<<<<<<
 *             i_all+=1
 *         else:
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);

    /* "lurrn/sparsmat.pyx":4187
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1
 *             i_all+=1             # <<<<<<<<<<<<<<
 *         else:
 *             while i2<n2:
 */
    __pyx_v_i_all = (__pyx_v_i_all + 1);
  }

  /* "lurrn/sparsmat.pyx":4189
 *             i_all+=1
 *         else:
 *             while i2<n2:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 */
  /*else*/ {
    while (1) {
      __pyx_t_2 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
      if (!__pyx_t_2) break;

      /* "lurrn/sparsmat.pyx":4190
 *         else:
 *             while i2<n2:
 *                 new_idx[i_all]=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 *                 i2+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":4191
 *             while i2<n2:
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=-other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 i2+=1
 *                 i_all+=1
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (-(__pyx_v_other->vals_ptr[__pyx_v_i2]));

      /* "lurrn/sparsmat.pyx":4192
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 *                 i2+=1             # <<<<<<<<<<<<<<
 *                 i_all+=1
 *         assert i_all==n_all
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":4193
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 *                 i2+=1
 *                 i_all+=1             # <<<<<<<<<<<<<<
 *         assert i_all==n_all
 *         result=SparseVectorF()
 */
      __pyx_v_i_all = (__pyx_v_i_all + 1);
    }
  }

  /* "lurrn/sparsmat.pyx":4194
 *                 i2+=1
 *                 i_all+=1
 *         assert i_all==n_all             # <<<<<<<<<<<<<<
 *         result=SparseVectorF()
 *         result.my_len=n_all
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_i_all == __pyx_v_n_all) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":4195
 *                 i_all+=1
 *         assert i_all==n_all
 *         result=SparseVectorF()             # <<<<<<<<<<<<<<
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx
 */
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorF)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "lurrn/sparsmat.pyx":4196
 *         assert i_all==n_all
 *         result=SparseVectorF()
 *         result.my_len=n_all             # <<<<<<<<<<<<<<
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals
 */
  __pyx_v_result->my_len = __pyx_v_n_all;

  /* "lurrn/sparsmat.pyx":4197
 *         result=SparseVectorF()
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx             # <<<<<<<<<<<<<<
 *         result.vals_ptr=new_vals
 *         return result
 */
  __pyx_v_result->idx_ptr = __pyx_v_new_idx;

  /* "lurrn/sparsmat.pyx":4198
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals             # <<<<<<<<<<<<<<
 *         return result
 *     def __or__(SparseVectorF self,SparseVectorF other):
 */
  __pyx_v_result->vals_ptr = __pyx_v_new_vals;

  /* "lurrn/sparsmat.pyx":4199
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals
 *         return result             # <<<<<<<<<<<<<<
 *     def __or__(SparseVectorF self,SparseVectorF other):
 *         cdef coordinate_t *new_idx
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4145
 *         result.vals_ptr=new_vals
 *         return result
 *     def __sub__(SparseVectorF self,SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *new_idx
 *         cdef float *new_vals
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.__sub__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4200
 *         result.vals_ptr=new_vals
 *         return result
 *     def __or__(SparseVectorF self,SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *new_idx
 *         cdef float *new_vals
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_55__or__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_55__or__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__or__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_SparseVectorF, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorF, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_54__or__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_54__or__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_other) {
  coordinate_t *__pyx_v_new_idx;
  float *__pyx_v_new_vals;
  coordinate_t __pyx_v_i1;
  coordinate_t __pyx_v_i2;
  coordinate_t __pyx_v_i_all;
  coordinate_t __pyx_v_n1;
  coordinate_t __pyx_v_n2;
  coordinate_t __pyx_v_n_all;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_result = 0;
  float __pyx_v_val;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__or__", 0);

  /* "lurrn/sparsmat.pyx":4209
 *         cdef float val
 *         # first pass: determine how much space we need
 *         n1=self.my_len             # <<<<<<<<<<<<<<
 *         n2=other.my_len
 *         n_all=i1=i2=0
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  __pyx_v_n1 = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":4210
 *         # first pass: determine how much space we need
 *         n1=self.my_len
 *         n2=other.my_len             # <<<<<<<<<<<<<<
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:
 */
  __pyx_t_1 = __pyx_v_other->my_len;
  __pyx_v_n2 = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":4211
 *         n1=self.my_len
 *         n2=other.my_len
 *         n_all=i1=i2=0             # <<<<<<<<<<<<<<
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 */
  __pyx_v_n_all = 0;
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":4212
 *         n2=other.my_len
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:             # <<<<<<<<<<<<<<
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":4213
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1
 */
    __pyx_v_k1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":4214
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1
 */
    __pyx_v_k2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":4215
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1             # <<<<<<<<<<<<<<
 *             if k2>=k1: i1+=1
 *             n_all+=1
 */
    __pyx_t_2 = ((__pyx_v_k1 >= __pyx_v_k2) != 0);
    if (__pyx_t_2) {
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "lurrn/sparsmat.pyx":4216
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1             # <<<<<<<<<<<<<<
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1
 */
    __pyx_t_2 = ((__pyx_v_k2 >= __pyx_v_k1) != 0);
    if (__pyx_t_2) {
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "lurrn/sparsmat.pyx":4217
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1
 *             n_all+=1             # <<<<<<<<<<<<<<
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2
 */
    __pyx_v_n_all = (__pyx_v_n_all + 1);
  }

  /* "lurrn/sparsmat.pyx":4218
 *             if k2>=k1: i1+=1
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1             # <<<<<<<<<<<<<<
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 */
  __pyx_t_2 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
  if (__pyx_t_2) {
    __pyx_v_n_all = (__pyx_v_n_all + (__pyx_v_n1 - __pyx_v_i1));
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "lurrn/sparsmat.pyx":4219
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2             # <<<<<<<<<<<<<<
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 *         new_vals=<float *>PyMem_Malloc(n_all*sizeof(float))
 */
  __pyx_t_2 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
  if (__pyx_t_2) {
    __pyx_v_n_all = (__pyx_v_n_all + (__pyx_v_n2 - __pyx_v_i2));
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "lurrn/sparsmat.pyx":4220
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         new_vals=<float *>PyMem_Malloc(n_all*sizeof(float))
 *         # second pass: fill in the actual values
 */
  __pyx_v_new_idx = ((coordinate_t *)PyMem_Malloc((__pyx_v_n_all * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":4221
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 *         new_vals=<float *>PyMem_Malloc(n_all*sizeof(float))             # <<<<<<<<<<<<<<
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0
 */
  __pyx_v_new_vals = ((float *)PyMem_Malloc((__pyx_v_n_all * (sizeof(float)))));

  /* "lurrn/sparsmat.pyx":4223
 *         new_vals=<float *>PyMem_Malloc(n_all*sizeof(float))
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0             # <<<<<<<<<<<<<<
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 */
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;
  __pyx_v_i_all = 0;

  /* "lurrn/sparsmat.pyx":4224
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0
 *         while i1<n1 and i2<n2:             # <<<<<<<<<<<<<<
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L13_bool_binop_done:;
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":4225
 *         i1=i2=i_all=0
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:
 */
    __pyx_v_k1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":4226
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *             if k1>=k2:
 *                 new_idx[i_all]=k2
 */
    __pyx_v_k2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":4227
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=other.vals_ptr[i2]
 */
    __pyx_t_2 = ((__pyx_v_k1 >= __pyx_v_k2) != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":4228
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:
 *                 new_idx[i_all]=k2             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = __pyx_v_k2;

      /* "lurrn/sparsmat.pyx":4229
 *             if k1>=k2:
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 i2+=1
 *                 if k1==k2:
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":4230
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1             # <<<<<<<<<<<<<<
 *                 if k1==k2:
 *                     val=self.vals_ptr[i1]
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":4231
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 *                 if k1==k2:             # <<<<<<<<<<<<<<
 *                     val=self.vals_ptr[i1]
 *                     if new_vals[i_all]<val:
 */
      __pyx_t_2 = ((__pyx_v_k1 == __pyx_v_k2) != 0);
      if (__pyx_t_2) {

        /* "lurrn/sparsmat.pyx":4232
 *                 i2+=1
 *                 if k1==k2:
 *                     val=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                     if new_vals[i_all]<val:
 *                         new_vals[i_all]=val
 */
        __pyx_v_val = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

        /* "lurrn/sparsmat.pyx":4233
 *                 if k1==k2:
 *                     val=self.vals_ptr[i1]
 *                     if new_vals[i_all]<val:             # <<<<<<<<<<<<<<
 *                         new_vals[i_all]=val
 *                     i1+=1
 */
        __pyx_t_2 = (((__pyx_v_new_vals[__pyx_v_i_all]) < __pyx_v_val) != 0);
        if (__pyx_t_2) {

          /* "lurrn/sparsmat.pyx":4234
 *                     val=self.vals_ptr[i1]
 *                     if new_vals[i_all]<val:
 *                         new_vals[i_all]=val             # <<<<<<<<<<<<<<
 *                     i1+=1
 *             else: # k2>k1:
 */
          (__pyx_v_new_vals[__pyx_v_i_all]) = __pyx_v_val;
          goto __pyx_L17;
        }
        __pyx_L17:;

        /* "lurrn/sparsmat.pyx":4235
 *                     if new_vals[i_all]<val:
 *                         new_vals[i_all]=val
 *                     i1+=1             # <<<<<<<<<<<<<<
 *             else: # k2>k1:
 *                 new_idx[i_all]=k1
 */
        __pyx_v_i1 = (__pyx_v_i1 + 1);
        goto __pyx_L16;
      }
      __pyx_L16:;
      goto __pyx_L15;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":4237
 *                     i1+=1
 *             else: # k2>k1:
 *                 new_idx[i_all]=k1             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = __pyx_v_k1;

      /* "lurrn/sparsmat.pyx":4238
 *             else: # k2>k1:
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             i_all+=1
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

      /* "lurrn/sparsmat.pyx":4239
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             i_all+=1
 *         while i1<n1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
    }
    __pyx_L15:;

    /* "lurrn/sparsmat.pyx":4240
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1
 *             i_all+=1             # <<<<<<<<<<<<<<
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]
 */
    __pyx_v_i_all = (__pyx_v_i_all + 1);
  }

  /* "lurrn/sparsmat.pyx":4241
 *                 i1+=1
 *             i_all+=1
 *         while i1<n1:             # <<<<<<<<<<<<<<
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":4242
 *             i_all+=1
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1
 */
    (__pyx_v_new_idx[__pyx_v_i_all]) = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":4243
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *             i1+=1
 *             i_all+=1
 */
    (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":4244
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1             # <<<<<<<<<<<<<<
 *             i_all+=1
 *         else:
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);

    /* "lurrn/sparsmat.pyx":4245
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1
 *             i_all+=1             # <<<<<<<<<<<<<<
 *         else:
 *             while i2<n2:
 */
    __pyx_v_i_all = (__pyx_v_i_all + 1);
  }

  /* "lurrn/sparsmat.pyx":4247
 *             i_all+=1
 *         else:
 *             while i2<n2:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=other.vals_ptr[i2]
 */
  /*else*/ {
    while (1) {
      __pyx_t_2 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
      if (!__pyx_t_2) break;

      /* "lurrn/sparsmat.pyx":4248
 *         else:
 *             while i2<n2:
 *                 new_idx[i_all]=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":4249
 *             while i2<n2:
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 i2+=1
 *                 i_all+=1
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":4250
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1             # <<<<<<<<<<<<<<
 *                 i_all+=1
 *         assert i_all==n_all
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":4251
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 *                 i_all+=1             # <<<<<<<<<<<<<<
 *         assert i_all==n_all
 *         result=SparseVectorF()
 */
      __pyx_v_i_all = (__pyx_v_i_all + 1);
    }
  }

  /* "lurrn/sparsmat.pyx":4252
 *                 i2+=1
 *                 i_all+=1
 *         assert i_all==n_all             # <<<<<<<<<<<<<<
 *         result=SparseVectorF()
 *         result.my_len=n_all
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_i_all == __pyx_v_n_all) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":4253
 *                 i_all+=1
 *         assert i_all==n_all
 *         result=SparseVectorF()             # <<<<<<<<<<<<<<
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx
 */
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorF)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "lurrn/sparsmat.pyx":4254
 *         assert i_all==n_all
 *         result=SparseVectorF()
 *         result.my_len=n_all             # <<<<<<<<<<<<<<
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals
 */
  __pyx_v_result->my_len = __pyx_v_n_all;

  /* "lurrn/sparsmat.pyx":4255
 *         result=SparseVectorF()
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx             # <<<<<<<<<<<<<<
 *         result.vals_ptr=new_vals
 *         return result
 */
  __pyx_v_result->idx_ptr = __pyx_v_new_idx;

  /* "lurrn/sparsmat.pyx":4256
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals             # <<<<<<<<<<<<<<
 *         return result
 *     def __lshift__(self, int k):
 */
  __pyx_v_result->vals_ptr = __pyx_v_new_vals;

  /* "lurrn/sparsmat.pyx":4257
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals
 *         return result             # <<<<<<<<<<<<<<
 *     def __lshift__(self, int k):
 *         cdef SparseVectorF result
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4200
 *         result.vals_ptr=new_vals
 *         return result
 *     def __or__(SparseVectorF self,SparseVectorF other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *new_idx
 *         cdef float *new_vals
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.__or__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4258
 *         result.vals_ptr=new_vals
 *         return result
 *     def __lshift__(self, int k):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorF result
 *         cdef coordinate_t i
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_57__lshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_57__lshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__lshift__ (wrapper)", 0);
  assert(__pyx_arg_k); {
    __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4258; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.__lshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_56__lshift__(((PyObject *)__pyx_v_self), ((int)__pyx_v_k));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_56__lshift__(PyObject *__pyx_v_self, int __pyx_v_k) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_result = 0;
  coordinate_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  unsigned int __pyx_t_2;
  coordinate_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  coordinate_t __pyx_t_6;
  float __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__lshift__", 0);

  /* "lurrn/sparsmat.pyx":4261
 *         cdef SparseVectorF result
 *         cdef coordinate_t i
 *         result=SparseVectorF()             # <<<<<<<<<<<<<<
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorF)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4262
 *         cdef coordinate_t i
 *         result=SparseVectorF()
 *         result.my_len=self.my_len             # <<<<<<<<<<<<<<
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_my_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_unsigned_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_result->my_len = __pyx_t_2;

  /* "lurrn/sparsmat.pyx":4263
 *         result=SparseVectorF()
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_result->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":4264
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]+k
 */
  __pyx_v_result->vals_ptr = ((float *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(float)))));

  /* "lurrn/sparsmat.pyx":4265
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result.idx_ptr[i]=self.idx_ptr[i]+k
 *         for i from 0<=i<self.my_len:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_my_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_coordinate_t(__pyx_t_1); if (unlikely((__pyx_t_3 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4266
 *         result.vals_ptr=<float *>PyMem_Malloc(result.my_len*sizeof(float))
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]+k             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_idx_ptr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_i, coordinate_t, 0, __Pyx_PyInt_From_coordinate_t, 0, 0, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4266; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = __Pyx_PyInt_As_coordinate_t(__pyx_t_5); if (unlikely((__pyx_t_6 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    (__pyx_v_result->idx_ptr[__pyx_v_i]) = __pyx_t_6;
  }

  /* "lurrn/sparsmat.pyx":4267
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]+k
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result.vals_ptr[i]=self.vals_ptr[i]
 *         return result
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_my_len); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyInt_As_coordinate_t(__pyx_t_5); if (unlikely((__pyx_t_3 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4268
 *             result.idx_ptr[i]=self.idx_ptr[i]+k
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *         return result
 *     def __ilshift__(self, int k):
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_vals_ptr); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_5, __pyx_v_i, coordinate_t, 0, __Pyx_PyInt_From_coordinate_t, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4268; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_7 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    (__pyx_v_result->vals_ptr[__pyx_v_i]) = __pyx_t_7;
  }

  /* "lurrn/sparsmat.pyx":4269
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]
 *         return result             # <<<<<<<<<<<<<<
 *     def __ilshift__(self, int k):
 *         cdef SparseVectorF result
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4258
 *         result.vals_ptr=new_vals
 *         return result
 *     def __lshift__(self, int k):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorF result
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.__lshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4270
 *             result.vals_ptr[i]=self.vals_ptr[i]
 *         return result
 *     def __ilshift__(self, int k):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorF result
 *         cdef coordinate_t i
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_59__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_59__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ilshift__ (wrapper)", 0);
  assert(__pyx_arg_k); {
    __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4270; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.__ilshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_58__ilshift__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((int)__pyx_v_k));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_58__ilshift__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, int __pyx_v_k) {
  coordinate_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  coordinate_t __pyx_t_2;
  __Pyx_RefNannySetupContext("__ilshift__", 0);

  /* "lurrn/sparsmat.pyx":4273
 *         cdef SparseVectorF result
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             self.idx_ptr[i]+=k
 *         return self
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4274
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 *             self.idx_ptr[i]+=k             # <<<<<<<<<<<<<<
 *         return self
 *     def __getitem__(self, int i):
 */
    __pyx_t_2 = __pyx_v_i;
    (__pyx_v_self->idx_ptr[__pyx_t_2]) = ((__pyx_v_self->idx_ptr[__pyx_t_2]) + __pyx_v_k);
  }

  /* "lurrn/sparsmat.pyx":4275
 *         for i from 0<=i<self.my_len:
 *             self.idx_ptr[i]+=k
 *         return self             # <<<<<<<<<<<<<<
 *     def __getitem__(self, int i):
 *         if i<0:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4270
 *             result.vals_ptr[i]=self.vals_ptr[i]
 *         return result
 *     def __ilshift__(self, int k):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorF result
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4276
 *             self.idx_ptr[i]+=k
 *         return self
 *     def __getitem__(self, int i):             # <<<<<<<<<<<<<<
 *         if i<0:
 *             i=self.my_len+i
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_61__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_i); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_61__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_i) {
  int __pyx_v_i;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  assert(__pyx_arg_i); {
    __pyx_v_i = __Pyx_PyInt_As_int(__pyx_arg_i); if (unlikely((__pyx_v_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4276; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_60__getitem__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((int)__pyx_v_i));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_60__getitem__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, int __pyx_v_i) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "lurrn/sparsmat.pyx":4277
 *         return self
 *     def __getitem__(self, int i):
 *         if i<0:             # <<<<<<<<<<<<<<
 *             i=self.my_len+i
 *         if i>=self.my_len or i<0:
 */
  __pyx_t_1 = ((__pyx_v_i < 0) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":4278
 *     def __getitem__(self, int i):
 *         if i<0:
 *             i=self.my_len+i             # <<<<<<<<<<<<<<
 *         if i>=self.my_len or i<0:
 *             raise IndexError
 */
    __pyx_v_i = (__pyx_v_self->my_len + __pyx_v_i);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":4279
 *         if i<0:
 *             i=self.my_len+i
 *         if i>=self.my_len or i<0:             # <<<<<<<<<<<<<<
 *             raise IndexError
 *         return (self.idx_ptr[i],self.vals_ptr[i])
 */
  __pyx_t_2 = ((__pyx_v_i >= __pyx_v_self->my_len) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_i < 0) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":4280
 *             i=self.my_len+i
 *         if i>=self.my_len or i<0:
 *             raise IndexError             # <<<<<<<<<<<<<<
 *         return (self.idx_ptr[i],self.vals_ptr[i])
 *     def __repr__(self):
 */
    __Pyx_Raise(__pyx_builtin_IndexError, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lurrn/sparsmat.pyx":4281
 *         if i>=self.my_len or i<0:
 *             raise IndexError
 *         return (self.idx_ptr[i],self.vals_ptr[i])             # <<<<<<<<<<<<<<
 *     def __repr__(self):
 *         cdef unsigned int i
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->idx_ptr[__pyx_v_i])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble((__pyx_v_self->vals_ptr[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4276
 *             self.idx_ptr[i]+=k
 *         return self
 *     def __getitem__(self, int i):             # <<<<<<<<<<<<<<
 *         if i<0:
 *             i=self.my_len+i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4282
 *             raise IndexError
 *         return (self.idx_ptr[i],self.vals_ptr[i])
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         cdef unsigned int i
 *         ss=[]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_63__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_63__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_62__repr__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_62__repr__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self) {
  unsigned int __pyx_v_i;
  PyObject *__pyx_v_ss = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  unsigned int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "lurrn/sparsmat.pyx":4284
 *     def __repr__(self):
 *         cdef unsigned int i
 *         ss=[]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             ss.append('(%d,%s)'%(self.idx_ptr[i],self.vals_ptr[i]))
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ss = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4285
 *         cdef unsigned int i
 *         ss=[]
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             ss.append('(%d,%s)'%(self.idx_ptr[i],self.vals_ptr[i]))
 *         return 'SparseVectorF([%s])'%(','.join(ss))
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4286
 *         ss=[]
 *         for i from 0<=i<self.my_len:
 *             ss.append('(%d,%s)'%(self.idx_ptr[i],self.vals_ptr[i]))             # <<<<<<<<<<<<<<
 *         return 'SparseVectorF([%s])'%(','.join(ss))
 *     def __reduce_ex__(self,protocol):
 */
    __pyx_t_1 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->idx_ptr[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyFloat_FromDouble((__pyx_v_self->vals_ptr[__pyx_v_i])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_d_s, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyList_Append(__pyx_v_ss, __pyx_t_3); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }

  /* "lurrn/sparsmat.pyx":4287
 *         for i from 0<=i<self.my_len:
 *             ss.append('(%d,%s)'%(self.idx_ptr[i],self.vals_ptr[i]))
 *         return 'SparseVectorF([%s])'%(','.join(ss))             # <<<<<<<<<<<<<<
 *     def __reduce_ex__(self,protocol):
 *         if protocol==0:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyString_Join(__pyx_kp_s__25, __pyx_v_ss); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_SparseVectorF_s, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4282
 *             raise IndexError
 *         return (self.idx_ptr[i],self.vals_ptr[i])
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         cdef unsigned int i
 *         ss=[]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ss);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4288
 *             ss.append('(%d,%s)'%(self.idx_ptr[i],self.vals_ptr[i]))
 *         return 'SparseVectorF([%s])'%(','.join(ss))
 *     def __reduce_ex__(self,protocol):             # <<<<<<<<<<<<<<
 *         if protocol==0:
 *             # choose compatibility over performance.
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_65__reduce_ex__(PyObject *__pyx_v_self, PyObject *__pyx_v_protocol); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_65__reduce_ex__(PyObject *__pyx_v_self, PyObject *__pyx_v_protocol) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_ex__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_64__reduce_ex__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((PyObject *)__pyx_v_protocol));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_64__reduce_ex__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, PyObject *__pyx_v_protocol) {
  PyObject *__pyx_v_s_idx = NULL;
  PyObject *__pyx_v_s_vals = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_ex__", 0);

  /* "lurrn/sparsmat.pyx":4289
 *         return 'SparseVectorF([%s])'%(','.join(ss))
 *     def __reduce_ex__(self,protocol):
 *         if protocol==0:             # <<<<<<<<<<<<<<
 *             # choose compatibility over performance.
 *             return (SparseVectorF,(list(self),),())
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_protocol, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "lurrn/sparsmat.pyx":4291
 *         if protocol==0:
 *             # choose compatibility over performance.
 *             return (SparseVectorF,(list(self),),())             # <<<<<<<<<<<<<<
 *         else:
 *             s_idx=PyString_FromStringAndSize(<char *>self.idx_ptr,self.my_len*sizeof(coordinate_t))
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorF)));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorF)));
    __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorF)));
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_empty_tuple);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_empty_tuple);
    __Pyx_GIVEREF(__pyx_empty_tuple);
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":4293
 *             return (SparseVectorF,(list(self),),())
 *         else:
 *             s_idx=PyString_FromStringAndSize(<char *>self.idx_ptr,self.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *             s_vals=PyString_FromStringAndSize(<char *>self.vals_ptr,self.my_len*sizeof(float))
 *             return (SparseVectorF,(None,),(s_idx,s_vals))
 */
    __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->idx_ptr), (__pyx_v_self->my_len * (sizeof(coordinate_t)))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_s_idx = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "lurrn/sparsmat.pyx":4294
 *         else:
 *             s_idx=PyString_FromStringAndSize(<char *>self.idx_ptr,self.my_len*sizeof(coordinate_t))
 *             s_vals=PyString_FromStringAndSize(<char *>self.vals_ptr,self.my_len*sizeof(float))             # <<<<<<<<<<<<<<
 *             return (SparseVectorF,(None,),(s_idx,s_vals))
 *     def __setstate__(self,state):
 */
    __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->vals_ptr), (__pyx_v_self->my_len * (sizeof(float)))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_s_vals = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "lurrn/sparsmat.pyx":4295
 *             s_idx=PyString_FromStringAndSize(<char *>self.idx_ptr,self.my_len*sizeof(coordinate_t))
 *             s_vals=PyString_FromStringAndSize(<char *>self.vals_ptr,self.my_len*sizeof(float))
 *             return (SparseVectorF,(None,),(s_idx,s_vals))             # <<<<<<<<<<<<<<
 *     def __setstate__(self,state):
 *         cdef coordinate_t *p_idx
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_s_idx);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_s_idx);
    __Pyx_GIVEREF(__pyx_v_s_idx);
    __Pyx_INCREF(__pyx_v_s_vals);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_s_vals);
    __Pyx_GIVEREF(__pyx_v_s_vals);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorF)));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorF)));
    __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorF)));
    __Pyx_INCREF(__pyx_tuple__49);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_tuple__49);
    __Pyx_GIVEREF(__pyx_tuple__49);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":4288
 *             ss.append('(%d,%s)'%(self.idx_ptr[i],self.vals_ptr[i]))
 *         return 'SparseVectorF([%s])'%(','.join(ss))
 *     def __reduce_ex__(self,protocol):             # <<<<<<<<<<<<<<
 *         if protocol==0:
 *             # choose compatibility over performance.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.__reduce_ex__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s_idx);
  __Pyx_XDECREF(__pyx_v_s_vals);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4296
 *             s_vals=PyString_FromStringAndSize(<char *>self.vals_ptr,self.my_len*sizeof(float))
 *             return (SparseVectorF,(None,),(s_idx,s_vals))
 *     def __setstate__(self,state):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *p_idx
 *         cdef float *p_vals
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_67__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_67__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_66__setstate__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self), ((PyObject *)__pyx_v_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_66__setstate__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self, PyObject *__pyx_v_state) {
  coordinate_t *__pyx_v_p_idx;
  float *__pyx_v_p_vals;
  PyObject *__pyx_v_s_idx = NULL;
  PyObject *__pyx_v_s_vals = NULL;
  long __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  char *__pyx_t_7;
  size_t __pyx_t_8;
  unsigned int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* "lurrn/sparsmat.pyx":4299
 *         cdef coordinate_t *p_idx
 *         cdef float *p_vals
 *         if len(state)==0:             # <<<<<<<<<<<<<<
 *             pass
 *         elif len(state)==2:
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_state); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((__pyx_t_1 == 0) != 0);
  if (__pyx_t_2) {
    goto __pyx_L3;
  }

  /* "lurrn/sparsmat.pyx":4301
 *         if len(state)==0:
 *             pass
 *         elif len(state)==2:             # <<<<<<<<<<<<<<
 *             assert (self.idx_ptr==NULL)
 *             (s_idx, s_vals)=state
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_state); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((__pyx_t_1 == 2) != 0);
  if (__pyx_t_2) {

    /* "lurrn/sparsmat.pyx":4302
 *             pass
 *         elif len(state)==2:
 *             assert (self.idx_ptr==NULL)             # <<<<<<<<<<<<<<
 *             (s_idx, s_vals)=state
 *             p_idx=<coordinate_t *>(<char *>s_idx)
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      if (unlikely(!((__pyx_v_self->idx_ptr == NULL) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":4303
 *         elif len(state)==2:
 *             assert (self.idx_ptr==NULL)
 *             (s_idx, s_vals)=state             # <<<<<<<<<<<<<<
 *             p_idx=<coordinate_t *>(<char *>s_idx)
 *             p_vals=<float *>(<char *>s_vals)
 */
    if ((likely(PyTuple_CheckExact(__pyx_v_state))) || (PyList_CheckExact(__pyx_v_state))) {
      PyObject* sequence = __pyx_v_state;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      #endif
    } else {
      Py_ssize_t index = -1;
      __pyx_t_5 = PyObject_GetIter(__pyx_v_state); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = NULL;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L5_unpacking_done;
      __pyx_L4_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L5_unpacking_done:;
    }
    __pyx_v_s_idx = __pyx_t_3;
    __pyx_t_3 = 0;
    __pyx_v_s_vals = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":4304
 *             assert (self.idx_ptr==NULL)
 *             (s_idx, s_vals)=state
 *             p_idx=<coordinate_t *>(<char *>s_idx)             # <<<<<<<<<<<<<<
 *             p_vals=<float *>(<char *>s_vals)
 *             self.my_len=len(s_idx)/sizeof(coordinate_t)
 */
    __pyx_t_7 = __Pyx_PyObject_AsString(__pyx_v_s_idx); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_p_idx = ((coordinate_t *)((char *)__pyx_t_7));

    /* "lurrn/sparsmat.pyx":4305
 *             (s_idx, s_vals)=state
 *             p_idx=<coordinate_t *>(<char *>s_idx)
 *             p_vals=<float *>(<char *>s_vals)             # <<<<<<<<<<<<<<
 *             self.my_len=len(s_idx)/sizeof(coordinate_t)
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 */
    __pyx_t_7 = __Pyx_PyObject_AsString(__pyx_v_s_vals); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_p_vals = ((float *)((char *)__pyx_t_7));

    /* "lurrn/sparsmat.pyx":4306
 *             p_idx=<coordinate_t *>(<char *>s_idx)
 *             p_vals=<float *>(<char *>s_vals)
 *             self.my_len=len(s_idx)/sizeof(coordinate_t)             # <<<<<<<<<<<<<<
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *             self.vals_ptr=<float *>PyMem_Malloc(self.my_len*sizeof(float))
 */
    __pyx_t_1 = PyObject_Length(__pyx_v_s_idx); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = (sizeof(coordinate_t));
    if (unlikely(__pyx_t_8 == 0)) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      #ifdef WITH_THREAD
      PyGILState_Release(__pyx_gilstate_save);
      #endif
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_self->my_len = (__pyx_t_1 / __pyx_t_8);

    /* "lurrn/sparsmat.pyx":4307
 *             p_vals=<float *>(<char *>s_vals)
 *             self.my_len=len(s_idx)/sizeof(coordinate_t)
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *             self.vals_ptr=<float *>PyMem_Malloc(self.my_len*sizeof(float))
 *             for i from 0<=i<self.my_len:
 */
    __pyx_v_self->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_self->my_len * (sizeof(coordinate_t)))));

    /* "lurrn/sparsmat.pyx":4308
 *             self.my_len=len(s_idx)/sizeof(coordinate_t)
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *             self.vals_ptr=<float *>PyMem_Malloc(self.my_len*sizeof(float))             # <<<<<<<<<<<<<<
 *             for i from 0<=i<self.my_len:
 *                 self.idx_ptr[i]=p_idx[i]
 */
    __pyx_v_self->vals_ptr = ((float *)PyMem_Malloc((__pyx_v_self->my_len * (sizeof(float)))));

    /* "lurrn/sparsmat.pyx":4309
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *             self.vals_ptr=<float *>PyMem_Malloc(self.my_len*sizeof(float))
 *             for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *                 self.idx_ptr[i]=p_idx[i]
 *                 self.vals_ptr[i]=p_vals[i]
 */
    __pyx_t_9 = __pyx_v_self->my_len;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":4310
 *             self.vals_ptr=<float *>PyMem_Malloc(self.my_len*sizeof(float))
 *             for i from 0<=i<self.my_len:
 *                 self.idx_ptr[i]=p_idx[i]             # <<<<<<<<<<<<<<
 *                 self.vals_ptr[i]=p_vals[i]
 *     def __dealloc__(self):
 */
      (__pyx_v_self->idx_ptr[__pyx_v_i]) = (__pyx_v_p_idx[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":4311
 *             for i from 0<=i<self.my_len:
 *                 self.idx_ptr[i]=p_idx[i]
 *                 self.vals_ptr[i]=p_vals[i]             # <<<<<<<<<<<<<<
 *     def __dealloc__(self):
 *         if self.buf is None:
 */
      (__pyx_v_self->vals_ptr[__pyx_v_i]) = (__pyx_v_p_vals[__pyx_v_i]);
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":4296
 *             s_vals=PyString_FromStringAndSize(<char *>self.vals_ptr,self.my_len*sizeof(float))
 *             return (SparseVectorF,(None,),(s_idx,s_vals))
 *     def __setstate__(self,state):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *p_idx
 *         cdef float *p_vals
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.__setstate__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s_idx);
  __Pyx_XDECREF(__pyx_v_s_vals);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4312
 *                 self.idx_ptr[i]=p_idx[i]
 *                 self.vals_ptr[i]=p_vals[i]
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.buf is None:
 *             PyMem_Free(self.idx_ptr)
 */

/* Python wrapper */
static void __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_69__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_69__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_68__dealloc__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_68__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lurrn/sparsmat.pyx":4313
 *                 self.vals_ptr[i]=p_vals[i]
 *     def __dealloc__(self):
 *         if self.buf is None:             # <<<<<<<<<<<<<<
 *             PyMem_Free(self.idx_ptr)
 *             PyMem_Free(self.vals_ptr)
 */
  __pyx_t_1 = (__pyx_v_self->buf == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lurrn/sparsmat.pyx":4314
 *     def __dealloc__(self):
 *         if self.buf is None:
 *             PyMem_Free(self.idx_ptr)             # <<<<<<<<<<<<<<
 *             PyMem_Free(self.vals_ptr)
 *         else:
 */
    PyMem_Free(__pyx_v_self->idx_ptr);

    /* "lurrn/sparsmat.pyx":4315
 *         if self.buf is None:
 *             PyMem_Free(self.idx_ptr)
 *             PyMem_Free(self.vals_ptr)             # <<<<<<<<<<<<<<
 *         else:
 *             self.buf=None
 */
    PyMem_Free(__pyx_v_self->vals_ptr);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":4317
 *             PyMem_Free(self.vals_ptr)
 *         else:
 *             self.buf=None             # <<<<<<<<<<<<<<
 *         self.idx_ptr=<coordinate_t *>0
 *         self.vals_ptr=<float *>0
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->buf);
    __Pyx_DECREF(__pyx_v_self->buf);
    __pyx_v_self->buf = Py_None;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":4318
 *         else:
 *             self.buf=None
 *         self.idx_ptr=<coordinate_t *>0             # <<<<<<<<<<<<<<
 *         self.vals_ptr=<float *>0
 *         self.my_len=0
 */
  __pyx_v_self->idx_ptr = ((coordinate_t *)0);

  /* "lurrn/sparsmat.pyx":4319
 *             self.buf=None
 *         self.idx_ptr=<coordinate_t *>0
 *         self.vals_ptr=<float *>0             # <<<<<<<<<<<<<<
 *         self.my_len=0
 *     def to_scipy(self):
 */
  __pyx_v_self->vals_ptr = ((float *)0);

  /* "lurrn/sparsmat.pyx":4320
 *         self.idx_ptr=<coordinate_t *>0
 *         self.vals_ptr=<float *>0
 *         self.my_len=0             # <<<<<<<<<<<<<<
 *     def to_scipy(self):
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] data
 */
  __pyx_v_self->my_len = 0;

  /* "lurrn/sparsmat.pyx":4312
 *                 self.idx_ptr[i]=p_idx[i]
 *                 self.vals_ptr[i]=p_vals[i]
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.buf is None:
 *             PyMem_Free(self.idx_ptr)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":4321
 *         self.vals_ptr=<float *>0
 *         self.my_len=0
 *     def to_scipy(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] data
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indices
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_71to_scipy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_71to_scipy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_scipy (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorF_70to_scipy(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorF_70to_scipy(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_self) {
  PyArrayObject *__pyx_v_data = 0;
  PyArrayObject *__pyx_v_indices = 0;
  PyArrayObject *__pyx_v_indptr = 0;
  int __pyx_v_i;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_data;
  __Pyx_Buffer __pyx_pybuffer_data;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indices;
  __Pyx_Buffer __pyx_pybuffer_indices;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indptr;
  __Pyx_Buffer __pyx_pybuffer_indptr;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyArrayObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyArrayObject *__pyx_t_13 = NULL;
  PyArrayObject *__pyx_t_14 = NULL;
  unsigned int __pyx_t_15;
  long __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_scipy", 0);
  __pyx_pybuffer_data.pybuffer.buf = NULL;
  __pyx_pybuffer_data.refcount = 0;
  __pyx_pybuffernd_data.data = NULL;
  __pyx_pybuffernd_data.rcbuffer = &__pyx_pybuffer_data;
  __pyx_pybuffer_indices.pybuffer.buf = NULL;
  __pyx_pybuffer_indices.refcount = 0;
  __pyx_pybuffernd_indices.data = NULL;
  __pyx_pybuffernd_indices.rcbuffer = &__pyx_pybuffer_indices;
  __pyx_pybuffer_indptr.pybuffer.buf = NULL;
  __pyx_pybuffer_indptr.refcount = 0;
  __pyx_pybuffernd_indptr.data = NULL;
  __pyx_pybuffernd_indptr.rcbuffer = &__pyx_pybuffer_indptr;

  /* "lurrn/sparsmat.pyx":4326
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indptr
 *         cdef int i,j
 *         indptr=numpy.zeros(2, numpy.int32)             # <<<<<<<<<<<<<<
 *         indices=numpy.zeros(self.my_len, numpy.int32)
 *         data=numpy.zeros(self.my_len, numpy.float32)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_int_2);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
    __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_8 < 0)) {
      PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer, (PyObject*)__pyx_v_indptr, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
    }
    __pyx_pybuffernd_indptr.diminfo[0].strides = __pyx_pybuffernd_indptr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indptr.diminfo[0].shape = __pyx_pybuffernd_indptr.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_7 = 0;
  __pyx_v_indptr = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4327
 *         cdef int i,j
 *         indptr=numpy.zeros(2, numpy.int32)
 *         indices=numpy.zeros(self.my_len, numpy.int32)             # <<<<<<<<<<<<<<
 *         data=numpy.zeros(self.my_len, numpy.float32)
 *         indptr[1]=self.my_len
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->my_len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_12 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_5, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_5, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_13 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
    __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indices.rcbuffer->pybuffer, (PyObject*)__pyx_t_13, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_8 < 0)) {
      PyErr_Fetch(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indices.rcbuffer->pybuffer, (PyObject*)__pyx_v_indices, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_11, __pyx_t_10, __pyx_t_9);
      }
    }
    __pyx_pybuffernd_indices.diminfo[0].strides = __pyx_pybuffernd_indices.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indices.diminfo[0].shape = __pyx_pybuffernd_indices.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_13 = 0;
  __pyx_v_indices = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4328
 *         indptr=numpy.zeros(2, numpy.int32)
 *         indices=numpy.zeros(self.my_len, numpy.int32)
 *         data=numpy.zeros(self.my_len, numpy.float32)             # <<<<<<<<<<<<<<
 *         indptr[1]=self.my_len
 *         for i from 0<=i<self.my_len:
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_zeros); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->my_len); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float32); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_6 = 0;
  __pyx_t_3 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
    __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_8 < 0)) {
      PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data.rcbuffer->pybuffer, (PyObject*)__pyx_v_data, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
    }
    __pyx_pybuffernd_data.diminfo[0].strides = __pyx_pybuffernd_data.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_data.diminfo[0].shape = __pyx_pybuffernd_data.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_14 = 0;
  __pyx_v_data = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4329
 *         indices=numpy.zeros(self.my_len, numpy.int32)
 *         data=numpy.zeros(self.my_len, numpy.float32)
 *         indptr[1]=self.my_len             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             indices[i]=0
 */
  __pyx_t_15 = __pyx_v_self->my_len;
  __pyx_t_16 = 1;
  __pyx_t_8 = -1;
  if (__pyx_t_16 < 0) {
    __pyx_t_16 += __pyx_pybuffernd_indptr.diminfo[0].shape;
    if (unlikely(__pyx_t_16 < 0)) __pyx_t_8 = 0;
  } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_indptr.diminfo[0].shape)) __pyx_t_8 = 0;
  if (unlikely(__pyx_t_8 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_8);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_indptr.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_indptr.diminfo[0].strides) = __pyx_t_15;

  /* "lurrn/sparsmat.pyx":4330
 *         data=numpy.zeros(self.my_len, numpy.float32)
 *         indptr[1]=self.my_len
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             indices[i]=0
 *         for i from 0<=i<self.my_len:
 */
  __pyx_t_15 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_15; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4331
 *         indptr[1]=self.my_len
 *         for i from 0<=i<self.my_len:
 *             indices[i]=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             data[i]=self.vals_ptr[i]
 */
    __pyx_t_8 = __pyx_v_i;
    __pyx_t_17 = -1;
    if (__pyx_t_8 < 0) {
      __pyx_t_8 += __pyx_pybuffernd_indices.diminfo[0].shape;
      if (unlikely(__pyx_t_8 < 0)) __pyx_t_17 = 0;
    } else if (unlikely(__pyx_t_8 >= __pyx_pybuffernd_indices.diminfo[0].shape)) __pyx_t_17 = 0;
    if (unlikely(__pyx_t_17 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_17);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_indices.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_indices.diminfo[0].strides) = 0;
  }

  /* "lurrn/sparsmat.pyx":4332
 *         for i from 0<=i<self.my_len:
 *             indices[i]=0
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             data[i]=self.vals_ptr[i]
 *         return (data,indices,indptr)
 */
  __pyx_t_15 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_15; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4333
 *             indices[i]=0
 *         for i from 0<=i<self.my_len:
 *             data[i]=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *         return (data,indices,indptr)
 * 
 */
    __pyx_t_17 = __pyx_v_i;
    __pyx_t_18 = -1;
    if (__pyx_t_17 < 0) {
      __pyx_t_17 += __pyx_pybuffernd_data.diminfo[0].shape;
      if (unlikely(__pyx_t_17 < 0)) __pyx_t_18 = 0;
    } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_data.diminfo[0].shape)) __pyx_t_18 = 0;
    if (unlikely(__pyx_t_18 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_18);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_data.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_data.diminfo[0].strides) = (__pyx_v_self->vals_ptr[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":4334
 *         for i from 0<=i<self.my_len:
 *             data[i]=self.vals_ptr[i]
 *         return (data,indices,indptr)             # <<<<<<<<<<<<<<
 * 
 * emptyvec_F=SparseVectorF([])
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_data));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_data));
  __Pyx_INCREF(((PyObject *)__pyx_v_indices));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_indices));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_indices));
  __Pyx_INCREF(((PyObject *)__pyx_v_indptr));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_indptr));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_indptr));
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4321
 *         self.vals_ptr=<float *>0
 *         self.my_len=0
 *     def to_scipy(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float32_t, ndim=1] data
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indices
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_12);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorF.to_scipy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_data);
  __Pyx_XDECREF((PyObject *)__pyx_v_indices);
  __Pyx_XDECREF((PyObject *)__pyx_v_indptr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4339
 * 
 * cdef class SparseVectorsF:
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *        self.vecs = []
 *     cpdef SparseVectorF to_vec(self):
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsF___init__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_14SparseVectorsF___init__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":4340
 * cdef class SparseVectorsF:
 *     def __init__(self):
 *        self.vecs = []             # <<<<<<<<<<<<<<
 *     cpdef SparseVectorF to_vec(self):
 *         cdef SparseVectorF vec
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->vecs);
  __Pyx_DECREF(__pyx_v_self->vecs);
  __pyx_v_self->vecs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4339
 * 
 * cdef class SparseVectorsF:
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *        self.vecs = []
 *     cpdef SparseVectorF to_vec(self):
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsF.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4341
 *     def __init__(self):
 *        self.vecs = []
 *     cpdef SparseVectorF to_vec(self):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorF vec
 *         cdef float weight
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_3to_vec(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_f_5lurrn_8sparsmat_14SparseVectorsF_to_vec(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_self, int __pyx_skip_dispatch) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_vec = 0;
  float __pyx_v_weight;
  size_t __pyx_v_i;
  size_t __pyx_v_j;
  struct __pyx_obj_5lurrn_8sparsmat_VecF1 *__pyx_v_result = 0;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  unsigned int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_vec", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_to_vec); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_3to_vec)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_SparseVectorF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4345
 *         cdef float weight
 *         cdef size_t i, j
 *         cdef VecF1 result = VecF1()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecF1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4346
 *         cdef size_t i, j
 *         cdef VecF1 result = VecF1()
 *         for i from 0<=i<len(self.vecs):             # <<<<<<<<<<<<<<
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 */
  __pyx_t_1 = __pyx_v_self->vecs;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4347
 *         cdef VecF1 result = VecF1()
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = self.vecs[i]
 *             for j from 0<=j<vec.my_len:
 */
    __pyx_v_weight = __pyx_v_self->weights.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":4348
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]             # <<<<<<<<<<<<<<
 *             for j from 0<=j<vec.my_len:
 *                 result.add_count(vec.idx_ptr[j], weight*vec.vals_ptr[j])
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->vecs, __pyx_v_i, size_t, 0, __Pyx_PyInt_FromSize_t, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4348; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_SparseVectorF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":4349
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 *             for j from 0<=j<vec.my_len:             # <<<<<<<<<<<<<<
 *                 result.add_count(vec.idx_ptr[j], weight*vec.vals_ptr[j])
 *         return result.to_sparse()
 */
    __pyx_t_6 = __pyx_v_vec->my_len;
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_6; __pyx_v_j++) {

      /* "lurrn/sparsmat.pyx":4350
 *             vec = self.vecs[i]
 *             for j from 0<=j<vec.my_len:
 *                 result.add_count(vec.idx_ptr[j], weight*vec.vals_ptr[j])             # <<<<<<<<<<<<<<
 *         return result.to_sparse()
 *     cpdef add(self, SparseVectorF vec, float weight=1):
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_result), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyInt_From_coordinate_t((__pyx_v_vec->idx_ptr[__pyx_v_j])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyFloat_FromDouble((__pyx_v_weight * (__pyx_v_vec->vals_ptr[__pyx_v_j]))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_8 = 1;
        }
      }
      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
  }

  /* "lurrn/sparsmat.pyx":4351
 *             for j from 0<=j<vec.my_len:
 *                 result.add_count(vec.idx_ptr[j], weight*vec.vals_ptr[j])
 *         return result.to_sparse()             # <<<<<<<<<<<<<<
 *     cpdef add(self, SparseVectorF vec, float weight=1):
 *         self.vecs.append(vec)
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF1 *)__pyx_v_result->__pyx_vtab)->to_sparse(__pyx_v_result, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4341
 *     def __init__(self):
 *        self.vecs = []
 *     cpdef SparseVectorF to_vec(self):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorF vec
 *         cdef float weight
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsF.to_vec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_vec);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_3to_vec(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_3to_vec(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_vec (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_2to_vec(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_2to_vec(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_vec", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_14SparseVectorsF_to_vec(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsF.to_vec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4352
 *                 result.add_count(vec.idx_ptr[j], weight*vec.vals_ptr[j])
 *         return result.to_sparse()
 *     cpdef add(self, SparseVectorF vec, float weight=1):             # <<<<<<<<<<<<<<
 *         self.vecs.append(vec)
 *         self.weights.push_back(weight)
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_5add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5lurrn_8sparsmat_14SparseVectorsF_add(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_vec, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsF_add *__pyx_optional_args) {
  float __pyx_v_weight = ((float)1.0);
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_weight = __pyx_optional_args->weight;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_add); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_5add)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_weight); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_vec));
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_vec));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_vec));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4353
 *         return result.to_sparse()
 *     cpdef add(self, SparseVectorF vec, float weight=1):
 *         self.vecs.append(vec)             # <<<<<<<<<<<<<<
 *         self.weights.push_back(weight)
 *     def __mul__(self, factor):
 */
  __pyx_t_8 = __Pyx_PyObject_Append(__pyx_v_self->vecs, ((PyObject *)__pyx_v_vec)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lurrn/sparsmat.pyx":4354
 *     cpdef add(self, SparseVectorF vec, float weight=1):
 *         self.vecs.append(vec)
 *         self.weights.push_back(weight)             # <<<<<<<<<<<<<<
 *     def __mul__(self, factor):
 *         cdef SparseVectorF vec
 */
  __pyx_v_self->weights.push_back(__pyx_v_weight);

  /* "lurrn/sparsmat.pyx":4352
 *                 result.add_count(vec.idx_ptr[j], weight*vec.vals_ptr[j])
 *         return result.to_sparse()
 *     cpdef add(self, SparseVectorF vec, float weight=1):             # <<<<<<<<<<<<<<
 *         self.vecs.append(vec)
 *         self.weights.push_back(weight)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsF.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_5add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_5add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_vec = 0;
  float __pyx_v_weight;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_vec,&__pyx_n_s_weight,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weight);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4352; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_vec = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)values[0]);
    if (values[1]) {
      __pyx_v_weight = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_weight == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4352; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_weight = ((float)1.0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4352; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsF.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vec), __pyx_ptype_5lurrn_8sparsmat_SparseVectorF, 1, "vec", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_4add(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *)__pyx_v_self), __pyx_v_vec, __pyx_v_weight);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_4add(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_vec, float __pyx_v_weight) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsF_add __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.weight = __pyx_v_weight;
  __pyx_t_1 = __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorsF->add(__pyx_v_self, __pyx_v_vec, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsF.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4355
 *         self.vecs.append(vec)
 *         self.weights.push_back(weight)
 *     def __mul__(self, factor):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorF vec
 *         cdef float weight
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_7__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_factor); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_7__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_factor) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__mul__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_6__mul__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_factor));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_6__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_factor) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_vec = 0;
  float __pyx_v_weight;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_result = 0;
  long __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  float __pyx_t_7;
  struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsF_add __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__mul__", 0);

  /* "lurrn/sparsmat.pyx":4358
 *         cdef SparseVectorF vec
 *         cdef float weight
 *         cdef SparseVectorsF result = SparseVectorsF             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 */
  if (!(likely(((((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsF))) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsF)), __pyx_ptype_5lurrn_8sparsmat_SparseVectorsF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsF));
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4359
 *         cdef float weight
 *         cdef SparseVectorsF result = SparseVectorsF
 *         for i from 0<=i<len(self.vecs):             # <<<<<<<<<<<<<<
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_vecs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4360
 *         cdef SparseVectorsF result = SparseVectorsF
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = self.vecs[i]
 *             result.add(vec, weight*factor)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_weights); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_at); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_7 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_weight = __pyx_t_7;

    /* "lurrn/sparsmat.pyx":4361
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]             # <<<<<<<<<<<<<<
 *             result.add(vec, weight*factor)
 *     def __add__(self, others):
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_vecs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_i, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4361; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5lurrn_8sparsmat_SparseVectorF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":4362
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 *             result.add(vec, weight*factor)             # <<<<<<<<<<<<<<
 *     def __add__(self, others):
 *         cdef SparseVectorF vec
 */
    __pyx_t_4 = PyFloat_FromDouble(__pyx_v_weight); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyNumber_Multiply(__pyx_t_4, __pyx_v_factor); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_7 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_8.__pyx_n = 1;
    __pyx_t_8.weight = __pyx_t_7;
    __pyx_t_1 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsF *)__pyx_v_result->__pyx_vtab)->add(__pyx_v_result, __pyx_v_vec, 0, &__pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4355
 *         self.vecs.append(vec)
 *         self.weights.push_back(weight)
 *     def __mul__(self, factor):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorF vec
 *         cdef float weight
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsF.__mul__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_vec);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4363
 *             vec = self.vecs[i]
 *             result.add(vec, weight*factor)
 *     def __add__(self, others):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorF vec
 *         cdef float weight
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_9__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_others); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_9__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_others) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_8__add__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_others));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_8__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_others) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_vec = 0;
  float __pyx_v_weight;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_oth_vecs = 0;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_result = 0;
  long __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  float __pyx_t_7;
  struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsF_add __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":4366
 *         cdef SparseVectorF vec
 *         cdef float weight
 *         cdef SparseVectorsF oth_vecs = others             # <<<<<<<<<<<<<<
 *         cdef SparseVectorsF result = SparseVectorsF
 *         for i from 0<=i<len(self.vecs):
 */
  if (!(likely(((__pyx_v_others) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_others, __pyx_ptype_5lurrn_8sparsmat_SparseVectorsF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_others;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_oth_vecs = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4367
 *         cdef float weight
 *         cdef SparseVectorsF oth_vecs = others
 *         cdef SparseVectorsF result = SparseVectorsF             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 */
  if (!(likely(((((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsF))) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsF)), __pyx_ptype_5lurrn_8sparsmat_SparseVectorsF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsF));
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4368
 *         cdef SparseVectorsF oth_vecs = others
 *         cdef SparseVectorsF result = SparseVectorsF
 *         for i from 0<=i<len(self.vecs):             # <<<<<<<<<<<<<<
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_vecs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4369
 *         cdef SparseVectorsF result = SparseVectorsF
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = self.vecs[i]
 *             result.add(vec, weight)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_weights); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_at); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_7 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_weight = __pyx_t_7;

    /* "lurrn/sparsmat.pyx":4370
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]             # <<<<<<<<<<<<<<
 *             result.add(vec, weight)
 *         for i from 0<=i<len(oth_vecs.vecs):
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_vecs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_i, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4370; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5lurrn_8sparsmat_SparseVectorF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":4371
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 *             result.add(vec, weight)             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(oth_vecs.vecs):
 *             weight = oth_vecs.weights.at(i)
 */
    __pyx_t_8.__pyx_n = 1;
    __pyx_t_8.weight = __pyx_v_weight;
    __pyx_t_4 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsF *)__pyx_v_result->__pyx_vtab)->add(__pyx_v_result, __pyx_v_vec, 0, &__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }

  /* "lurrn/sparsmat.pyx":4372
 *             vec = self.vecs[i]
 *             result.add(vec, weight)
 *         for i from 0<=i<len(oth_vecs.vecs):             # <<<<<<<<<<<<<<
 *             weight = oth_vecs.weights.at(i)
 *             vec = oth_vecs.vecs[i]
 */
  __pyx_t_4 = __pyx_v_oth_vecs->vecs;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_2 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4373
 *             result.add(vec, weight)
 *         for i from 0<=i<len(oth_vecs.vecs):
 *             weight = oth_vecs.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = oth_vecs.vecs[i]
 *             result.add(vec, weight)
 */
    __pyx_v_weight = __pyx_v_oth_vecs->weights.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":4374
 *         for i from 0<=i<len(oth_vecs.vecs):
 *             weight = oth_vecs.weights.at(i)
 *             vec = oth_vecs.vecs[i]             # <<<<<<<<<<<<<<
 *             result.add(vec, weight)
 *         return result
 */
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_oth_vecs->vecs, __pyx_v_i, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4374; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5lurrn_8sparsmat_SparseVectorF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":4375
 *             weight = oth_vecs.weights.at(i)
 *             vec = oth_vecs.vecs[i]
 *             result.add(vec, weight)             # <<<<<<<<<<<<<<
 *         return result
 *     def __sub__(SparseVectorsF self, SparseVectorsF others):
 */
    __pyx_t_8.__pyx_n = 1;
    __pyx_t_8.weight = __pyx_v_weight;
    __pyx_t_4 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsF *)__pyx_v_result->__pyx_vtab)->add(__pyx_v_result, __pyx_v_vec, 0, &__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }

  /* "lurrn/sparsmat.pyx":4376
 *             vec = oth_vecs.vecs[i]
 *             result.add(vec, weight)
 *         return result             # <<<<<<<<<<<<<<
 *     def __sub__(SparseVectorsF self, SparseVectorsF others):
 *         cdef SparseVectorF vec
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4363
 *             vec = self.vecs[i]
 *             result.add(vec, weight*factor)
 *     def __add__(self, others):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorF vec
 *         cdef float weight
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsF.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_vec);
  __Pyx_XDECREF((PyObject *)__pyx_v_oth_vecs);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4377
 *             result.add(vec, weight)
 *         return result
 *     def __sub__(SparseVectorsF self, SparseVectorsF others):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorF vec
 *         cdef float weight
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_11__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_others); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_11__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_others) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__sub__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_SparseVectorsF, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_others), __pyx_ptype_5lurrn_8sparsmat_SparseVectorsF, 1, "others", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_10__sub__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *)__pyx_v_others));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_10__sub__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_others) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_vec = 0;
  float __pyx_v_weight;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_oth_vecs = 0;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_result = 0;
  long __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsF_add __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__sub__", 0);

  /* "lurrn/sparsmat.pyx":4380
 *         cdef SparseVectorF vec
 *         cdef float weight
 *         cdef SparseVectorsF oth_vecs = others             # <<<<<<<<<<<<<<
 *         cdef SparseVectorsF result = SparseVectorsF()
 *         for i from 0<=i<len(self.vecs):
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_others));
  __pyx_v_oth_vecs = __pyx_v_others;

  /* "lurrn/sparsmat.pyx":4381
 *         cdef float weight
 *         cdef SparseVectorsF oth_vecs = others
 *         cdef SparseVectorsF result = SparseVectorsF()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsF)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4382
 *         cdef SparseVectorsF oth_vecs = others
 *         cdef SparseVectorsF result = SparseVectorsF()
 *         for i from 0<=i<len(self.vecs):             # <<<<<<<<<<<<<<
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 */
  __pyx_t_1 = __pyx_v_self->vecs;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4383
 *         cdef SparseVectorsF result = SparseVectorsF()
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = self.vecs[i]
 *             result.add(vec, weight)
 */
    __pyx_v_weight = __pyx_v_self->weights.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":4384
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]             # <<<<<<<<<<<<<<
 *             result.add(vec, weight)
 *         for i from 0<=i<len(oth_vecs.vecs):
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->vecs, __pyx_v_i, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4384; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_SparseVectorF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":4385
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 *             result.add(vec, weight)             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(oth_vecs.vecs):
 *             weight = oth_vecs.weights.at(i)
 */
    __pyx_t_3.__pyx_n = 1;
    __pyx_t_3.weight = __pyx_v_weight;
    __pyx_t_1 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsF *)__pyx_v_result->__pyx_vtab)->add(__pyx_v_result, __pyx_v_vec, 0, &__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4386
 *             vec = self.vecs[i]
 *             result.add(vec, weight)
 *         for i from 0<=i<len(oth_vecs.vecs):             # <<<<<<<<<<<<<<
 *             weight = oth_vecs.weights.at(i)
 *             vec = oth_vecs.vecs[i]
 */
  __pyx_t_1 = __pyx_v_oth_vecs->vecs;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4387
 *             result.add(vec, weight)
 *         for i from 0<=i<len(oth_vecs.vecs):
 *             weight = oth_vecs.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = oth_vecs.vecs[i]
 *             result.add(vec, -weight)
 */
    __pyx_v_weight = __pyx_v_oth_vecs->weights.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":4388
 *         for i from 0<=i<len(oth_vecs.vecs):
 *             weight = oth_vecs.weights.at(i)
 *             vec = oth_vecs.vecs[i]             # <<<<<<<<<<<<<<
 *             result.add(vec, -weight)
 *         return result
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_oth_vecs->vecs, __pyx_v_i, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4388; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_SparseVectorF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":4389
 *             weight = oth_vecs.weights.at(i)
 *             vec = oth_vecs.vecs[i]
 *             result.add(vec, -weight)             # <<<<<<<<<<<<<<
 *         return result
 *     cdef float _dotFull(self, const_float_ptr full_ptr):
 */
    __pyx_t_3.__pyx_n = 1;
    __pyx_t_3.weight = (-__pyx_v_weight);
    __pyx_t_1 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsF *)__pyx_v_result->__pyx_vtab)->add(__pyx_v_result, __pyx_v_vec, 0, &__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4390
 *             vec = oth_vecs.vecs[i]
 *             result.add(vec, -weight)
 *         return result             # <<<<<<<<<<<<<<
 *     cdef float _dotFull(self, const_float_ptr full_ptr):
 *         cdef size_t i, j
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4377
 *             result.add(vec, weight)
 *         return result
 *     def __sub__(SparseVectorsF self, SparseVectorsF others):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorF vec
 *         cdef float weight
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsF.__sub__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_vec);
  __Pyx_XDECREF((PyObject *)__pyx_v_oth_vecs);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4391
 *             result.add(vec, -weight)
 *         return result
 *     cdef float _dotFull(self, const_float_ptr full_ptr):             # <<<<<<<<<<<<<<
 *         cdef size_t i, j
 *         cdef float weight
 */

static float __pyx_f_5lurrn_8sparsmat_14SparseVectorsF__dotFull(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_self, const float * __pyx_v_full_ptr) {
  size_t __pyx_v_i;
  size_t __pyx_v_j;
  float __pyx_v_weight;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *__pyx_v_vec = 0;
  float __pyx_v_result;
  float __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  unsigned int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_dotFull", 0);

  /* "lurrn/sparsmat.pyx":4395
 *         cdef float weight
 *         cdef SparseVectorF vec
 *         cdef float result=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 */
  __pyx_v_result = 0.0;

  /* "lurrn/sparsmat.pyx":4396
 *         cdef SparseVectorF vec
 *         cdef float result=0
 *         for i from 0<=i<len(self.vecs):             # <<<<<<<<<<<<<<
 *             weight = self.weights.at(i)
 *             vec = self.vecs.at(i)
 */
  __pyx_t_1 = __pyx_v_self->vecs;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4397
 *         cdef float result=0
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = self.vecs.at(i)
 *             for j from 0<=j<vec.my_len:
 */
    __pyx_v_weight = __pyx_v_self->weights.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":4398
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 *             vec = self.vecs.at(i)             # <<<<<<<<<<<<<<
 *             for j from 0<=j<vec.my_len:
 *                 result += full_ptr[vec.indices[j]]*weight*vec.vals_ptr[j]
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->vecs, __pyx_n_s_at); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_SparseVectorF))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":4399
 *             weight = self.weights.at(i)
 *             vec = self.vecs.at(i)
 *             for j from 0<=j<vec.my_len:             # <<<<<<<<<<<<<<
 *                 result += full_ptr[vec.indices[j]]*weight*vec.vals_ptr[j]
 *         return result
 */
    __pyx_t_7 = __pyx_v_vec->my_len;
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_7; __pyx_v_j++) {

      /* "lurrn/sparsmat.pyx":4400
 *             vec = self.vecs.at(i)
 *             for j from 0<=j<vec.my_len:
 *                 result += full_ptr[vec.indices[j]]*weight*vec.vals_ptr[j]             # <<<<<<<<<<<<<<
 *         return result
 *     def __len__(self):
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_vec), __pyx_n_s_indices); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_j, size_t, 0, __Pyx_PyInt_FromSize_t, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4400; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_result = (__pyx_v_result + (((__pyx_v_full_ptr[__pyx_t_8]) * __pyx_v_weight) * (__pyx_v_vec->vals_ptr[__pyx_v_j])));
    }
  }

  /* "lurrn/sparsmat.pyx":4401
 *             for j from 0<=j<vec.my_len:
 *                 result += full_ptr[vec.indices[j]]*weight*vec.vals_ptr[j]
 *         return result             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return len(self.vecs)
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4391
 *             result.add(vec, -weight)
 *         return result
 *     cdef float _dotFull(self, const_float_ptr full_ptr):             # <<<<<<<<<<<<<<
 *         cdef size_t i, j
 *         cdef float weight
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorsF._dotFull", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_vec);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4402
 *                 result += full_ptr[vec.indices[j]]*weight*vec.vals_ptr[j]
 *         return result
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return len(self.vecs)
 *     def __getitem__(self, k):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_13__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_13__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_12__len__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_12__len__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":4403
 *         return result
 *     def __len__(self):
 *         return len(self.vecs)             # <<<<<<<<<<<<<<
 *     def __getitem__(self, k):
 *         vec = self.vecs[k]
 */
  __pyx_t_1 = __pyx_v_self->vecs;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4402
 *                 result += full_ptr[vec.indices[j]]*weight*vec.vals_ptr[j]
 *         return result
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return len(self.vecs)
 *     def __getitem__(self, k):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsF.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4404
 *     def __len__(self):
 *         return len(self.vecs)
 *     def __getitem__(self, k):             # <<<<<<<<<<<<<<
 *         vec = self.vecs[k]
 *         return (self.weights.at(k), vec)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_15__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_k); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_15__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_14__getitem__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *)__pyx_v_self), ((PyObject *)__pyx_v_k));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsF_14__getitem__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_v_vec = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "lurrn/sparsmat.pyx":4405
 *         return len(self.vecs)
 *     def __getitem__(self, k):
 *         vec = self.vecs[k]             # <<<<<<<<<<<<<<
 *         return (self.weights.at(k), vec)
 * ## D -> double
 */
  __pyx_t_1 = PyObject_GetItem(__pyx_v_self->vecs, __pyx_v_k); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4405; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_vec = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4406
 *     def __getitem__(self, k):
 *         vec = self.vecs[k]
 *         return (self.weights.at(k), vec)             # <<<<<<<<<<<<<<
 * ## D -> double
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_v_k); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->weights.at(__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_vec);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_vec);
  __Pyx_GIVEREF(__pyx_v_vec);
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4404
 *     def __len__(self):
 *         return len(self.vecs)
 *     def __getitem__(self, k):             # <<<<<<<<<<<<<<
 *         vec = self.vecs[k]
 *         return (self.weights.at(k), vec)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsF.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_vec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4414
 * cdef class VecD1:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_5VecD1_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_5VecD1_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1___init__(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_5VecD1___init__(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":4415
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     def item_iter(self):
 *         self.ensure_compact()
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":4414
 * cdef class VecD1:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4416
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecD1_iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("item_iter (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1_2item_iter(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("item_iter", 0);

  /* "lurrn/sparsmat.pyx":4417
 *         self.is_compact=True
 *     def item_iter(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return IVecD1_iter(self)
 *     def get_size(self,compactify=True):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":4418
 *     def item_iter(self):
 *         self.ensure_compact()
 *         return IVecD1_iter(self)             # <<<<<<<<<<<<<<
 *     def get_size(self,compactify=True):
 *         if compactify:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_IVecD1_iter)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4416
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecD1_iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.item_iter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4419
 *         self.ensure_compact()
 *         return IVecD1_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4419; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4419; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1_4get_size(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":4420
 *         return IVecD1_iter(self)
 *     def get_size(self,compactify=True):
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *         return self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":4421
 *     def get_size(self,compactify=True):
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return self.vec.size()
 *     def __len__(self):
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":4422
 *         if compactify:
 *             self.ensure_compact()
 *         return self.vec.size()             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return self.get_size(True)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_self->vec.size()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4419
 *         self.ensure_compact()
 *         return IVecD1_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4423
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecD1_7__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecD1_7__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1_6__len__(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecD1_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":4424
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4423
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4425
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1_8clear(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear", 0);

  /* "lurrn/sparsmat.pyx":4426
 *         return self.get_size(True)
 *     def clear(self):
 *         self.vec.resize(0)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void compactify(self):
 */
  __pyx_v_self->vec.resize(0);

  /* "lurrn/sparsmat.pyx":4427
 *     def clear(self):
 *         self.vec.resize(0)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrD1 comp
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":4425
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4428
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrD1 comp
 *         c_IVecD1_sort(self.vec.begin(),self.vec.end(),comp)
 */

static void __pyx_f_5lurrn_8sparsmat_5VecD1_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self) {
  struct smallerAddr<1,double> __pyx_v_comp;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compactify", 0);

  /* "lurrn/sparsmat.pyx":4430
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrD1 comp
 *         c_IVecD1_sort(self.vec.begin(),self.vec.end(),comp)             # <<<<<<<<<<<<<<
 *         c_compactifyD1(&self.vec)
 *         self.is_compact=True
 */
  sort(__pyx_v_self->vec.begin(), __pyx_v_self->vec.end(), __pyx_v_comp);

  /* "lurrn/sparsmat.pyx":4431
 *         cdef c_SmallerAddrD1 comp
 *         c_IVecD1_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyD1(&self.vec)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 */
  compactify((&__pyx_v_self->vec));

  /* "lurrn/sparsmat.pyx":4432
 *         c_IVecD1_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyD1(&self.vec)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":4428
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrD1 comp
 *         c_IVecD1_sort(self.vec.begin(),self.vec.end(),comp)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":4433
 *         c_compactifyD1(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

static void __pyx_f_5lurrn_8sparsmat_5VecD1_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":4434
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:             # <<<<<<<<<<<<<<
 *             self.compactify()
 *     cpdef double get_count(self,coordinate_t k0):
 */
  __pyx_t_1 = ((!(__pyx_v_self->is_compact != 0)) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":4435
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 *             self.compactify()             # <<<<<<<<<<<<<<
 *     cpdef double get_count(self,coordinate_t k0):
 *         cdef c_CItemD1 ci
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD1 *)__pyx_v_self->__pyx_vtab)->compactify(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":4433
 *         c_compactifyD1(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":4436
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef double get_count(self,coordinate_t k0):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD1 ci
 *         ci.addr[0]=k0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_arg_k0); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_5VecD1_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, coordinate_t __pyx_v_k0, int __pyx_skip_dispatch) {
  struct CountItem<1,double> __pyx_v_ci;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  double __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_11get_count)) {
      __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4438
 *     cpdef double get_count(self,coordinate_t k0):
 *         cdef c_CItemD1 ci
 *         ci.addr[0]=k0             # <<<<<<<<<<<<<<
 *         return c_get_countD1(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0, double item):
 */
  (__pyx_v_ci.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":4439
 *         cdef c_CItemD1 ci
 *         ci.addr[0]=k0
 *         return c_get_countD1(&self.vec,ci)             # <<<<<<<<<<<<<<
 *     cdef void c_add(self, coordinate_t k0, double item):
 *         cdef c_CItemD1 c
 */
  __pyx_r = get_count_v((&__pyx_v_self->vec), __pyx_v_ci);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4436
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef double get_count(self,coordinate_t k0):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD1 ci
 *         ci.addr[0]=k0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecD1.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_arg_k0); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_arg_k0) {
  coordinate_t __pyx_v_k0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_count (wrapper)", 0);
  assert(__pyx_arg_k0); {
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(__pyx_arg_k0); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4436; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1_10get_count(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self), ((coordinate_t)__pyx_v_k0));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, coordinate_t __pyx_v_k0) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_5VecD1_get_count(__pyx_v_self, __pyx_v_k0, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4440
 *         ci.addr[0]=k0
 *         return c_get_countD1(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0, double item):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD1 c
 *         c.addr[0]=k0
 */

static void __pyx_f_5lurrn_8sparsmat_5VecD1_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, coordinate_t __pyx_v_k0, double __pyx_v_item) {
  struct CountItem<1,double> __pyx_v_c;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_add", 0);

  /* "lurrn/sparsmat.pyx":4442
 *     cdef void c_add(self, coordinate_t k0, double item):
 *         cdef c_CItemD1 c
 *         c.addr[0]=k0             # <<<<<<<<<<<<<<
 *         c.item=item
 *         self.vec.push_back(c)
 */
  (__pyx_v_c.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":4443
 *         cdef c_CItemD1 c
 *         c.addr[0]=k0
 *         c.item=item             # <<<<<<<<<<<<<<
 *         self.vec.push_back(c)
 *         self.is_compact=False
 */
  __pyx_v_c.item = __pyx_v_item;

  /* "lurrn/sparsmat.pyx":4444
 *         c.addr[0]=k0
 *         c.item=item
 *         self.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0, item=1):
 */
  __pyx_v_self->vec.push_back(__pyx_v_c);

  /* "lurrn/sparsmat.pyx":4445
 *         c.item=item
 *         self.vec.push_back(c)
 *         self.is_compact=False             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.c_add(k0, item)
 */
  __pyx_v_self->is_compact = 0;

  /* "lurrn/sparsmat.pyx":4440
 *         ci.addr[0]=k0
 *         return c_get_countD1(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0, double item):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD1 c
 *         c.addr[0]=k0
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":4446
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0, item=1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0, item)
 *     def __add__(VecD1 self, VecD1 other):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  PyObject *__pyx_v_item = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_item,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_item);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4446; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4446; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_item = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4446; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1_12add_count(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self), __pyx_v_k0, __pyx_v_item);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, coordinate_t __pyx_v_k0, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":4447
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.c_add(k0, item)             # <<<<<<<<<<<<<<
 *     def __add__(VecD1 self, VecD1 other):
 *         cdef c_CItemD1 c1, c2
 */
  __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_item); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD1 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_v_k0, __pyx_t_1);

  /* "lurrn/sparsmat.pyx":4446
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0, item=1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0, item)
 *     def __add__(VecD1 self, VecD1 other):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4448
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.c_add(k0, item)
 *     def __add__(VecD1 self, VecD1 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD1 c1, c2
 *         cdef unsigned int i1, i2
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_VecD1, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_VecD1, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1_14__add__(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_other) {
  struct CountItem<1,double> __pyx_v_c1;
  struct CountItem<1,double> __pyx_v_c2;
  unsigned int __pyx_v_i1;
  unsigned int __pyx_v_i2;
  int __pyx_v_k;
  int __pyx_v_delta;
  struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":4453
 *         cdef int k, delta
 *         cdef VecD1 result
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         other.ensure_compact()
 *         result=VecD1()
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":4454
 *         cdef VecD1 result
 *         self.ensure_compact()
 *         other.ensure_compact()             # <<<<<<<<<<<<<<
 *         result=VecD1()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD1 *)__pyx_v_other->__pyx_vtab)->ensure_compact(__pyx_v_other);

  /* "lurrn/sparsmat.pyx":4455
 *         self.ensure_compact()
 *         other.ensure_compact()
 *         result=VecD1()             # <<<<<<<<<<<<<<
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4456
 *         other.ensure_compact()
 *         result=VecD1()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))             # <<<<<<<<<<<<<<
 *         i1=0
 *         i2=0
 */
  __pyx_t_2 = __pyx_v_other->vec.size();
  __pyx_t_3 = __pyx_v_self->vec.size();
  if (((__pyx_t_2 > __pyx_t_3) != 0)) {
    __pyx_t_4 = __pyx_t_2;
  } else {
    __pyx_t_4 = __pyx_t_3;
  }
  __pyx_v_result->vec.reserve(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":4457
 *         result=VecD1()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0             # <<<<<<<<<<<<<<
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 */
  __pyx_v_i1 = 0;

  /* "lurrn/sparsmat.pyx":4458
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 *         i2=0             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 */
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":4459
 *         i1=0
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 */
  while (1) {
    __pyx_t_6 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_6 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":4460
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             delta=0
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":4461
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             delta=0
 *             for k from 0<=k<1:
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":4462
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 *             delta=0             # <<<<<<<<<<<<<<
 *             for k from 0<=k<1:
 *                 if c1.addr[k]<c2.addr[k]:
 */
    __pyx_v_delta = 0;

    /* "lurrn/sparsmat.pyx":4463
 *             c2=other.vec.at(i2)
 *             delta=0
 *             for k from 0<=k<1:             # <<<<<<<<<<<<<<
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 */
    for (__pyx_v_k = 0; __pyx_v_k < 1; __pyx_v_k++) {

      /* "lurrn/sparsmat.pyx":4464
 *             delta=0
 *             for k from 0<=k<1:
 *                 if c1.addr[k]<c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=-1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) < (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":4465
 *             for k from 0<=k<1:
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1             # <<<<<<<<<<<<<<
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 */
        __pyx_v_delta = -1;

        /* "lurrn/sparsmat.pyx":4466
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 *                     break             # <<<<<<<<<<<<<<
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 */
        goto __pyx_L8_break;
      }

      /* "lurrn/sparsmat.pyx":4467
 *                     delta=-1
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) > (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":4468
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1             # <<<<<<<<<<<<<<
 *                     break
 *             if delta==0:
 */
        __pyx_v_delta = 1;

        /* "lurrn/sparsmat.pyx":4469
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 *                     break             # <<<<<<<<<<<<<<
 *             if delta==0:
 *                 c1.item+=c2.item
 */
        goto __pyx_L8_break;
      }
    }
    __pyx_L8_break:;

    /* "lurrn/sparsmat.pyx":4475
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
    switch (__pyx_v_delta) {

      /* "lurrn/sparsmat.pyx":4470
 *                     delta=1
 *                     break
 *             if delta==0:             # <<<<<<<<<<<<<<
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)
 */
      case 0:

      /* "lurrn/sparsmat.pyx":4471
 *                     break
 *             if delta==0:
 *                 c1.item+=c2.item             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      __pyx_v_c1.item = (__pyx_v_c1.item + __pyx_v_c2.item);

      /* "lurrn/sparsmat.pyx":4472
 *             if delta==0:
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *                 i2+=1
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":4473
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *                 i2+=1
 *             elif delta==-1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);

      /* "lurrn/sparsmat.pyx":4474
 *                 result.vec.push_back(c1)
 *                 i1+=1
 *                 i2+=1             # <<<<<<<<<<<<<<
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;

      /* "lurrn/sparsmat.pyx":4475
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      case -1:

      /* "lurrn/sparsmat.pyx":4476
 *                 i2+=1
 *             elif delta==-1:
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             else:
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":4477
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             else:
 *                 result.vec.push_back(c2)
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      break;
      default:

      /* "lurrn/sparsmat.pyx":4479
 *                 i1+=1
 *             else:
 *                 result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *                 i2+=1
 *         while i1<self.vec.size():
 */
      __pyx_v_result->vec.push_back(__pyx_v_c2);

      /* "lurrn/sparsmat.pyx":4480
 *             else:
 *                 result.vec.push_back(c2)
 *                 i2+=1             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;
    }
  }

  /* "lurrn/sparsmat.pyx":4481
 *                 result.vec.push_back(c2)
 *                 i2+=1
 *         while i1<self.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":4482
 *                 i2+=1
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c1)
 *             i1+=1
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":4483
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *             i1+=1
 *         while i2<other.vec.size():
 */
    __pyx_v_result->vec.push_back(__pyx_v_c1);

    /* "lurrn/sparsmat.pyx":4484
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 *             i1+=1             # <<<<<<<<<<<<<<
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);
  }

  /* "lurrn/sparsmat.pyx":4485
 *             result.vec.push_back(c1)
 *             i1+=1
 *         while i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":4486
 *             i1+=1
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c2)
 *             i2+=1
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":4487
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *             i2+=1
 *         return result
 */
    __pyx_v_result->vec.push_back(__pyx_v_c2);

    /* "lurrn/sparsmat.pyx":4488
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 *             i2+=1             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_v_i2 = (__pyx_v_i2 + 1);
  }

  /* "lurrn/sparsmat.pyx":4489
 *             result.vec.push_back(c2)
 *             i2+=1
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     cpdef SparseVectorD to_sparse(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4448
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.c_add(k0, item)
 *     def __add__(VecD1 self, VecD1 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD1 c1, c2
 *         cdef unsigned int i1, i2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4491
 *         return result
 * 
 *     cpdef SparseVectorD to_sparse(self):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD1 c
 *         cdef SparseVectorD result
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_17to_sparse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_f_5lurrn_8sparsmat_5VecD1_to_sparse(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, int __pyx_skip_dispatch) {
  struct CountItem<1,double> __pyx_v_c;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_result = 0;
  coordinate_t __pyx_v_n;
  coordinate_t __pyx_v_i;
  coordinate_t *__pyx_v_idx_ptr;
  double *__pyx_v_vals_ptr;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  coordinate_t __pyx_t_5;
  double __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_sparse", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_to_sparse); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_17to_sparse)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_SparseVectorD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4497
 *         cdef coordinate_t *idx_ptr
 *         cdef double *vals_ptr
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         idx_ptr=<coordinate_t *>PyMem_Malloc(n*sizeof(coordinate_t))
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":4498
 *         cdef double *vals_ptr
 *         self.ensure_compact()
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         idx_ptr=<coordinate_t *>PyMem_Malloc(n*sizeof(coordinate_t))
 *         vals_ptr=<double *>PyMem_Malloc(n*sizeof(double))
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":4499
 *         self.ensure_compact()
 *         n=self.vec.size()
 *         idx_ptr=<coordinate_t *>PyMem_Malloc(n*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         vals_ptr=<double *>PyMem_Malloc(n*sizeof(double))
 *         for i from 0<=i<n:
 */
  __pyx_v_idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_n * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":4500
 *         n=self.vec.size()
 *         idx_ptr=<coordinate_t *>PyMem_Malloc(n*sizeof(coordinate_t))
 *         vals_ptr=<double *>PyMem_Malloc(n*sizeof(double))             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *           c=self.vec.at(i)
 */
  __pyx_v_vals_ptr = ((double *)PyMem_Malloc((__pyx_v_n * (sizeof(double)))));

  /* "lurrn/sparsmat.pyx":4501
 *         idx_ptr=<coordinate_t *>PyMem_Malloc(n*sizeof(coordinate_t))
 *         vals_ptr=<double *>PyMem_Malloc(n*sizeof(double))
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *           c=self.vec.at(i)
 *           idx_ptr[i]=c.addr[0]
 */
  __pyx_t_5 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4502
 *         vals_ptr=<double *>PyMem_Malloc(n*sizeof(double))
 *         for i from 0<=i<n:
 *           c=self.vec.at(i)             # <<<<<<<<<<<<<<
 *           idx_ptr[i]=c.addr[0]
 *           vals_ptr[i]=c.item
 */
    __pyx_v_c = __pyx_v_self->vec.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":4503
 *         for i from 0<=i<n:
 *           c=self.vec.at(i)
 *           idx_ptr[i]=c.addr[0]             # <<<<<<<<<<<<<<
 *           vals_ptr[i]=c.item
 *         result=SparseVectorD(None)
 */
    (__pyx_v_idx_ptr[__pyx_v_i]) = (__pyx_v_c.addr[0]);

    /* "lurrn/sparsmat.pyx":4504
 *           c=self.vec.at(i)
 *           idx_ptr[i]=c.addr[0]
 *           vals_ptr[i]=c.item             # <<<<<<<<<<<<<<
 *         result=SparseVectorD(None)
 *         result.idx_ptr=idx_ptr
 */
    __pyx_t_6 = __pyx_v_c.item;
    (__pyx_v_vals_ptr[__pyx_v_i]) = __pyx_t_6;
  }

  /* "lurrn/sparsmat.pyx":4505
 *           idx_ptr[i]=c.addr[0]
 *           vals_ptr[i]=c.item
 *         result=SparseVectorD(None)             # <<<<<<<<<<<<<<
 *         result.idx_ptr=idx_ptr
 *         result.vals_ptr=vals_ptr
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorD)), __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4506
 *           vals_ptr[i]=c.item
 *         result=SparseVectorD(None)
 *         result.idx_ptr=idx_ptr             # <<<<<<<<<<<<<<
 *         result.vals_ptr=vals_ptr
 *         result.my_len=n
 */
  __pyx_v_result->idx_ptr = __pyx_v_idx_ptr;

  /* "lurrn/sparsmat.pyx":4507
 *         result=SparseVectorD(None)
 *         result.idx_ptr=idx_ptr
 *         result.vals_ptr=vals_ptr             # <<<<<<<<<<<<<<
 *         result.my_len=n
 *         return result
 */
  __pyx_v_result->vals_ptr = __pyx_v_vals_ptr;

  /* "lurrn/sparsmat.pyx":4508
 *         result.idx_ptr=idx_ptr
 *         result.vals_ptr=vals_ptr
 *         result.my_len=n             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
  __pyx_v_result->my_len = __pyx_v_n;

  /* "lurrn/sparsmat.pyx":4509
 *         result.vals_ptr=vals_ptr
 *         result.my_len=n
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def tofile(self, f):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4491
 *         return result
 * 
 *     cpdef SparseVectorD to_sparse(self):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD1 c
 *         cdef SparseVectorD result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.to_sparse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_17to_sparse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_17to_sparse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_sparse (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1_16to_sparse(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_16to_sparse(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_sparse", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_5VecD1_to_sparse(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.to_sparse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4511
 *         return result
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_19tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_19tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tofile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1_18tofile(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_18tofile(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  long __pyx_v_k;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  long __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("tofile", 0);

  /* "lurrn/sparsmat.pyx":4513
 *     def tofile(self, f):
 *         cdef long i, n, k, k_max
 *         n=self.get_size()             # <<<<<<<<<<<<<<
 *         f.write('D1 %d\n'%(n,))
 *         k=0
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":4514
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 *         f.write('D1 %d\n'%(n,))             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_D1_d, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4515
 *         n=self.get_size()
 *         f.write('D1 %d\n'%(n,))
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecD1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemD1))
 */
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":4516
 *         f.write('D1 %d\n'%(n,))
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecD1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemD1))
 *             f.write(s)
 */
  __pyx_t_4 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4517
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecD1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemD1))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *             k+=CHUNK_SIZE
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), (256 * (sizeof(struct CountItem<1,double>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":4518
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecD1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemD1))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":4519
 *             s=PyString_FromStringAndSize(<char *>c_VecD1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemD1))
 *             f.write(s)
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecD1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemD1))
 */
    __pyx_v_k = (__pyx_v_k + 256);
  }

  /* "lurrn/sparsmat.pyx":4520
 *             f.write(s)
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecD1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemD1))
 *             f.write(s)
 */
  __pyx_t_7 = ((__pyx_v_k < __pyx_v_n) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":4521
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecD1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemD1))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *     def fromfile(self, f):
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), ((__pyx_v_n - __pyx_v_k) * (sizeof(struct CountItem<1,double>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":4522
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecD1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemD1))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *     def fromfile(self, f):
 *         cdef long i, n
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":4511
 *         return result
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.tofile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4523
 *             s=PyString_FromStringAndSize(<char *>c_VecD1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemD1))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_21fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_21fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fromfile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1_20fromfile(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_20fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  PyObject *__pyx_v_line = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  long __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  size_t __pyx_t_9;
  char *__pyx_t_10;
  size_t __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromfile", 0);

  /* "lurrn/sparsmat.pyx":4525
 *     def fromfile(self, f):
 *         cdef long i, n
 *         line=f.readline().strip().split()             # <<<<<<<<<<<<<<
 *         assert line[0]=='D1'
 *         n=long(line[1])
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_readline); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_line = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4526
 *         cdef long i, n
 *         line=f.readline().strip().split()
 *         assert line[0]=='D1'             # <<<<<<<<<<<<<<
 *         n=long(line[1])
 *         self.clear()
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4526; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_D1, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_6)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":4527
 *         line=f.readline().strip().split()
 *         assert line[0]=='D1'
 *         n=long(line[1])             # <<<<<<<<<<<<<<
 *         self.clear()
 *         self.vec.resize(n)
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4527; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyLong_Type))), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_7;

  /* "lurrn/sparsmat.pyx":4528
 *         assert line[0]=='D1'
 *         n=long(line[1])
 *         self.clear()             # <<<<<<<<<<<<<<
 *         self.vec.resize(n)
 *         k=0
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clear); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4529
 *         n=long(line[1])
 *         self.clear()
 *         self.vec.resize(n)             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_v_self->vec.resize(__pyx_v_n);

  /* "lurrn/sparsmat.pyx":4530
 *         self.clear()
 *         self.vec.resize(n)
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemD1))
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_k = __pyx_int_0;

  /* "lurrn/sparsmat.pyx":4531
 *         self.vec.resize(n)
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemD1))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemD1)
 */
  __pyx_t_7 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4532
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemD1))             # <<<<<<<<<<<<<<
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemD1)
 *             memcpy(<void *>c_VecD1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemD1))
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyInt_FromSize_t((256 * (sizeof(struct CountItem<1,double>)))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":4533
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemD1))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemD1)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecD1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemD1))
 *             k+=CHUNK_SIZE
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!((__pyx_t_8 == (256 * (sizeof(struct CountItem<1,double>)))) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":4534
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemD1))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemD1)
 *             memcpy(<void *>c_VecD1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemD1))             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), (256 * (sizeof(struct CountItem<1,double>))));

    /* "lurrn/sparsmat.pyx":4535
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemD1)
 *             memcpy(<void *>c_VecD1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemD1))
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemD1))
 */
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_k, __pyx_int_256); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_1);
    __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4536
 *             memcpy(<void *>c_VecD1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemD1))
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=f.read((n-k)*sizeof(c_CItemD1))
 *             assert len(s)==(n-k)*sizeof(c_CItemD1)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":4537
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemD1))             # <<<<<<<<<<<<<<
 *             assert len(s)==(n-k)*sizeof(c_CItemD1)
 *             memcpy(<void *>c_VecD1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemD1))
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_5, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<1,double>))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":4538
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemD1))
 *             assert len(s)==(n-k)*sizeof(c_CItemD1)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecD1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemD1))
 *     cpdef int get_maxcol(self, int k=0):
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<1,double>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_6)) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":4539
 *             s=f.read((n-k)*sizeof(c_CItemD1))
 *             assert len(s)==(n-k)*sizeof(c_CItemD1)
 *             memcpy(<void *>c_VecD1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemD1))             # <<<<<<<<<<<<<<
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<1,double>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), __pyx_t_11);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":4523
 *             s=PyString_FromStringAndSize(<char *>c_VecD1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemD1))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.fromfile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_line);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4540
 *             assert len(s)==(n-k)*sizeof(c_CItemD1)
 *             memcpy(<void *>c_VecD1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemD1))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<1
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecD1_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD1_get_maxcol *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_i;
  int __pyx_v_n;
  int __pyx_v_new_val;
  int __pyx_v_col;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_maxcol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_23get_maxcol)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4542
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<1             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         if n==0:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_9 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_9 = ((__pyx_v_k < 1) != 0);
    __pyx_t_8 = __pyx_t_9;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_8)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":4543
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<1
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         if n==0:
 *             return -1
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":4544
 *         assert k>=0 and k<1
 *         n=self.vec.size()
 *         if n==0:             # <<<<<<<<<<<<<<
 *             return -1
 *         if k==0:
 */
  __pyx_t_8 = ((__pyx_v_n == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":4545
 *         n=self.vec.size()
 *         if n==0:
 *             return -1             # <<<<<<<<<<<<<<
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 */
    __pyx_r = -1;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":4546
 *         if n==0:
 *             return -1
 *         if k==0:             # <<<<<<<<<<<<<<
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 */
  __pyx_t_8 = ((__pyx_v_k == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":4547
 *             return -1
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]             # <<<<<<<<<<<<<<
 *         col=-1
 *         n=self.vec.size()
 */
    __pyx_r = (__pyx_v_self->vec.at((__pyx_v_n - 1)).addr[0]);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":4548
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 *         col=-1             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_v_col = -1;

  /* "lurrn/sparsmat.pyx":4549
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":4550
 *         col=-1
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 */
  __pyx_t_7 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4551
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             if new_val>col:
 *                 col=new_val
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":4552
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:             # <<<<<<<<<<<<<<
 *                 col=new_val
 *         return col
 */
    __pyx_t_8 = ((__pyx_v_new_val > __pyx_v_col) != 0);
    if (__pyx_t_8) {

      /* "lurrn/sparsmat.pyx":4553
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 *                 col=new_val             # <<<<<<<<<<<<<<
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 */
      __pyx_v_col = __pyx_v_new_val;
      goto __pyx_L9;
    }
    __pyx_L9:;
  }

  /* "lurrn/sparsmat.pyx":4554
 *             if new_val>col:
 *                 col=new_val
 *         return col             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 *         cdef int old_val, new_val, i, n, count
 */
  __pyx_r = __pyx_v_col;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4540
 *             assert len(s)==(n-k)*sizeof(c_CItemD1)
 *             memcpy(<void *>c_VecD1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemD1))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecD1.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_maxcol (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_maxcol") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4540; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4540; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_maxcol", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4540; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1_22get_maxcol(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_22get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecD1_get_maxcol __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = __pyx_vtabptr_5lurrn_8sparsmat_VecD1->get_maxcol(__pyx_v_self, 1, &__pyx_t_2); 
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4555
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecD1_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD1_get_type_counts *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_new_val;
  int __pyx_v_i;
  int __pyx_v_n;
  PyArrayObject *__pyx_v_result = 0;
  long __pyx_v_n_types;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecD1_get_maxcol __pyx_t_11;
  PyArrayObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_25get_type_counts)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4558
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<1             # <<<<<<<<<<<<<<
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_8 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_k < 1) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_7)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":4559
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<1
 *         if self.vec.size()==0:             # <<<<<<<<<<<<<<
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 */
  __pyx_t_7 = ((__pyx_v_self->vec.size() == 0) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":4560
 *         assert k>=0 and k<1
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_9 = 1;
      }
    }
    __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_2) {
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":4561
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":4562
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1             # <<<<<<<<<<<<<<
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 */
  __pyx_t_11.__pyx_n = 1;
  __pyx_t_11.k = __pyx_v_k;
  __pyx_t_10 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD1 *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0, &__pyx_t_11); 
  __pyx_v_n_types = (__pyx_t_10 + 1);

  /* "lurrn/sparsmat.pyx":4563
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_n_types); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_9 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_6) {
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_12 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
    }
    __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_12 = 0;
  __pyx_v_result = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4564
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":4565
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4566
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             result[new_val]+=1
 *         return result
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":4567
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1             # <<<<<<<<<<<<<<
 *         return result
 *     cpdef VecD1 remap(self, int k, numpy.ndarray filt):
 */
    __pyx_t_16 = __pyx_v_new_val;
    __pyx_t_17 = -1;
    if (__pyx_t_16 < 0) {
      __pyx_t_16 += __pyx_pybuffernd_result.diminfo[0].shape;
      if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 0;
    } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_17 = 0;
    if (unlikely(__pyx_t_17 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_17);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_result.diminfo[0].strides) += 1;
  }

  /* "lurrn/sparsmat.pyx":4568
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 *         return result             # <<<<<<<<<<<<<<
 *     cpdef VecD1 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyArrayObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4555
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4555; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4555; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4555; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1_24get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_24get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecD1_get_type_counts __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_5lurrn_8sparsmat_VecD1->get_type_counts(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4569
 *             result[new_val]+=1
 *         return result
 *     cpdef VecD1 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_f_5lurrn_8sparsmat_5VecD1_remap(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_wanted = 0;
  PyArrayObject *__pyx_v_target = 0;
  int __pyx_v_n;
  int __pyx_v_i;
  struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_result = 0;
  struct CountItem<1,double> __pyx_v_c;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_target;
  __Pyx_Buffer __pyx_pybuffer_target;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_wanted;
  __Pyx_Buffer __pyx_pybuffer_wanted;
  struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __pyx_pybuffer_wanted.pybuffer.buf = NULL;
  __pyx_pybuffer_wanted.refcount = 0;
  __pyx_pybuffernd_wanted.data = NULL;
  __pyx_pybuffernd_wanted.rcbuffer = &__pyx_pybuffer_wanted;
  __pyx_pybuffer_target.pybuffer.buf = NULL;
  __pyx_pybuffer_target.refcount = 0;
  __pyx_pybuffernd_target.data = NULL;
  __pyx_pybuffernd_target.rcbuffer = &__pyx_pybuffer_target;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_remap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_27remap)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_filt));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_filt));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_filt));
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_VecD1))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4570
 *         return result
 *     cpdef VecD1 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__52, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_wanted = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_wanted.diminfo[0].strides = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_wanted.diminfo[0].shape = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_8 = 0;
  __pyx_v_wanted = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":4571
 *     cpdef VecD1 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_cumsum); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Subtract(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_target = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_target.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_target.diminfo[0].strides = __pyx_pybuffernd_target.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_target.diminfo[0].shape = __pyx_pybuffernd_target.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_9 = 0;
  __pyx_v_target = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4572
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         cdef int n=self.vec.size()
 *         cdef int i
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":4573
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()             # <<<<<<<<<<<<<<
 *         cdef int i
 *         cdef VecD1 result=VecD1()
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":4575
 *         cdef int n=self.vec.size()
 *         cdef int i
 *         cdef VecD1 result=VecD1()             # <<<<<<<<<<<<<<
 *         cdef c_CItemD1 c
 *         for i from 0<=i<n:
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4577
 *         cdef VecD1 result=VecD1()
 *         cdef c_CItemD1 c
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4578
 *         cdef c_CItemD1 c
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)             # <<<<<<<<<<<<<<
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 */
    __pyx_v_c = __pyx_v_self->vec.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":4579
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:             # <<<<<<<<<<<<<<
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 */
    __pyx_t_11 = (__pyx_v_c.addr[__pyx_v_k]);
    __pyx_t_12 = -1;
    if (__pyx_t_11 < 0) {
      __pyx_t_11 += __pyx_pybuffernd_wanted.diminfo[0].shape;
      if (unlikely(__pyx_t_11 < 0)) __pyx_t_12 = 0;
    } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_wanted.diminfo[0].shape)) __pyx_t_12 = 0;
    if (unlikely(__pyx_t_12 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_12);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_wanted.diminfo[0].strides)) != 0);
    if (__pyx_t_13) {

      /* "lurrn/sparsmat.pyx":4580
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c)
 *         return result
 */
      __pyx_t_12 = (__pyx_v_c.addr[__pyx_v_k]);
      __pyx_t_14 = -1;
      if (__pyx_t_12 < 0) {
        __pyx_t_12 += __pyx_pybuffernd_target.diminfo[0].shape;
        if (unlikely(__pyx_t_12 < 0)) __pyx_t_14 = 0;
      } else if (unlikely(__pyx_t_12 >= __pyx_pybuffernd_target.diminfo[0].shape)) __pyx_t_14 = 0;
      if (unlikely(__pyx_t_14 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_14);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      (__pyx_v_c.addr[__pyx_v_k]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_target.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_target.diminfo[0].strides));

      /* "lurrn/sparsmat.pyx":4581
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         return result
 *     def append(self,tup):
 */
      __pyx_v_result->vec.push_back(__pyx_v_c);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "lurrn/sparsmat.pyx":4582
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 *         return result             # <<<<<<<<<<<<<<
 *     def append(self,tup):
 *         k0,val=tup
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4569
 *             result[new_val]+=1
 *         return result
 *     cpdef VecD1 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_wanted);
  __Pyx_XDECREF((PyObject *)__pyx_v_target);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4569; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4569; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4569; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_filt = ((PyArrayObject *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4569; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_filt), __pyx_ptype_5numpy_ndarray, 1, "filt", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1_26remap(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_26remap(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_5VecD1_remap(__pyx_v_self, __pyx_v_k, __pyx_v_filt, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4583
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,val=tup
 *         self.c_add(k0,val)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_29append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_29append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("append (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1_28append(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self), ((PyObject *)__pyx_v_tup));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_28append(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *(*__pyx_t_4)(PyObject *);
  coordinate_t __pyx_t_5;
  double __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("append", 0);

  /* "lurrn/sparsmat.pyx":4584
 *         return result
 *     def append(self,tup):
 *         k0,val=tup             # <<<<<<<<<<<<<<
 *         self.c_add(k0,val)
 *     def extend(self,tups):
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_tup))) || (PyList_CheckExact(__pyx_v_tup))) {
    PyObject* sequence = __pyx_v_tup;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    #endif
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_4(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_k0 = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_val = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":4585
 *     def append(self,tup):
 *         k0,val=tup
 *         self.c_add(k0,val)             # <<<<<<<<<<<<<<
 *     def extend(self,tups):
 *         for k0,val in tups:
 */
  __pyx_t_5 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_5 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_v_val); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD1 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_5, __pyx_t_6);

  /* "lurrn/sparsmat.pyx":4583
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,val=tup
 *         self.c_add(k0,val)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4586
 *         k0,val=tup
 *         self.c_add(k0,val)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,val in tups:
 *             self.c_add(k0,val)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_31extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_31extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extend (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1_30extend(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self), ((PyObject *)__pyx_v_tups));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_30extend(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  coordinate_t __pyx_t_9;
  double __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("extend", 0);

  /* "lurrn/sparsmat.pyx":4587
 *         self.c_add(k0,val)
 *     def extend(self,tups):
 *         for k0,val in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,val)
 *     def __iter__(self):
 */
  if (likely(PyList_CheckExact(__pyx_v_tups)) || PyTuple_CheckExact(__pyx_v_tups)) {
    __pyx_t_1 = __pyx_v_tups; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_tups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_k0, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "lurrn/sparsmat.pyx":4588
 *     def extend(self,tups):
 *         for k0,val in tups:
 *             self.c_add(k0,val)             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self.item_iter()
 */
    __pyx_t_9 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_9 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_v_val); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD1 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_9, __pyx_t_10);

    /* "lurrn/sparsmat.pyx":4587
 *         self.c_add(k0,val)
 *     def extend(self,tups):
 *         for k0,val in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,val)
 *     def __iter__(self):
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4586
 *         k0,val=tup
 *         self.c_add(k0,val)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,val in tups:
 *             self.c_add(k0,val)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.extend", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4589
 *         for k0,val in tups:
 *             self.c_add(k0,val)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_33__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_33__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1_32__iter__(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_32__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":4590
 *             self.c_add(k0,val)
 *     def __iter__(self):
 *         return self.item_iter()             # <<<<<<<<<<<<<<
 *     def __reduce__(self):
 *         return (VecD1,(),(),self.item_iter())
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4589
 *         for k0,val in tups:
 *             self.c_add(k0,val)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4591
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecD1,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_35__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_35__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1_34__reduce__(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_34__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "lurrn/sparsmat.pyx":4592
 *         return self.item_iter()
 *     def __reduce__(self):
 *         return (VecD1,(),(),self.item_iter())             # <<<<<<<<<<<<<<
 *     def __setstate__(self,state):
 *         pass
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD1)));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD1)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD1)));
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4591
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecD1,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4593
 *     def __reduce__(self):
 *         return (VecD1,(),(),self.item_iter())
 *     def __setstate__(self,state):             # <<<<<<<<<<<<<<
 *         pass
 *     def __repr__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_37__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_37__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1_36__setstate__(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self), ((PyObject *)__pyx_v_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_36__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4595
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecD1(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_39__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD1_39__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD1_38__repr__(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD1_38__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "lurrn/sparsmat.pyx":4596
 *         pass
 *     def __repr__(self):
 *         return 'VecD1(%s)'%(str(list(self)),)             # <<<<<<<<<<<<<<
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_VecD1_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4595
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecD1(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD1.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4597
 *     def __repr__(self):
 *         return 'VecD1(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

/* Python wrapper */
static void __pyx_pw_5lurrn_8sparsmat_5VecD1_41__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5lurrn_8sparsmat_5VecD1_41__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5lurrn_8sparsmat_5VecD1_40__dealloc__(((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5lurrn_8sparsmat_5VecD1_40__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lurrn/sparsmat.pyx":4599
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()             # <<<<<<<<<<<<<<
 * 
 * cdef class IVecD1_iter:
 */
  __pyx_v_self->vec.~vector();

  /* "lurrn/sparsmat.pyx":4597
 *     def __repr__(self):
 *         return 'VecD1(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":4605
 *     cdef c_VecD1 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_11IVecD1_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_11IVecD1_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_vec = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_vec,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4605; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_vec = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4605; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.IVecD1_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecD1_iter___init__(((struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter *)__pyx_v_self), __pyx_v_vec);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_11IVecD1_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter *__pyx_v_self, PyObject *__pyx_v_vec) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":4606
 *     cdef unsigned int k
 *     def __init__(self,vec):
 *         self.vec=vec             # <<<<<<<<<<<<<<
 *         self.vecC=&self.vec.vec
 *         self.k=0
 */
  if (!(likely(((__pyx_v_vec) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_vec, __pyx_ptype_5lurrn_8sparsmat_VecD1))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_vec;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->vec);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->vec));
  __pyx_v_self->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4607
 *     def __init__(self,vec):
 *         self.vec=vec
 *         self.vecC=&self.vec.vec             # <<<<<<<<<<<<<<
 *         self.k=0
 *     def __iter__(self):
 */
  __pyx_v_self->vecC = (&__pyx_v_self->vec->vec);

  /* "lurrn/sparsmat.pyx":4608
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 *         self.k=0             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self
 */
  __pyx_v_self->k = 0;

  /* "lurrn/sparsmat.pyx":4605
 *     cdef c_VecD1 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecD1_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4609
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecD1_iter_3__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecD1_iter_3__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecD1_iter_2__iter__(((struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecD1_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":4610
 *         self.k=0
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4609
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4611
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecD1_iter_5__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecD1_iter_5__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecD1_iter_4__next__(((struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecD1_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter *__pyx_v_self) {
  struct CountItem<1,double> __pyx_v_res;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "lurrn/sparsmat.pyx":4612
 *         return self
 *     def __next__(self):
 *         if self.k>=self.vecC.size():             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         cdef c_CItemD1 res=self.vecC.at(self.k)
 */
  __pyx_t_1 = ((__pyx_v_self->k >= __pyx_v_self->vecC->size()) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":4613
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         cdef c_CItemD1 res=self.vecC.at(self.k)
 *         self.k+=1
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lurrn/sparsmat.pyx":4614
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 *         cdef c_CItemD1 res=self.vecC.at(self.k)             # <<<<<<<<<<<<<<
 *         self.k+=1
 *         return (res.addr[0],
 */
  __pyx_v_res = __pyx_v_self->vecC->at(__pyx_v_self->k);

  /* "lurrn/sparsmat.pyx":4615
 *             raise StopIteration
 *         cdef c_CItemD1 res=self.vecC.at(self.k)
 *         self.k+=1             # <<<<<<<<<<<<<<
 *         return (res.addr[0],
 *                 res.item)
 */
  __pyx_v_self->k = (__pyx_v_self->k + 1);

  /* "lurrn/sparsmat.pyx":4616
 *         cdef c_CItemD1 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.item)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_res.addr[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "lurrn/sparsmat.pyx":4617
 *         self.k+=1
 *         return (res.addr[0],
 *                 res.item)             # <<<<<<<<<<<<<<
 * 
 * cdef class LargeVecD1:
 */
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_res.item); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "lurrn/sparsmat.pyx":4616
 *         cdef c_CItemD1 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.item)
 * 
 */
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4611
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecD1_iter.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4622
 *     cdef public object compact
 *     cdef public VecD1 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecD1()
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD1_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD1_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD1___init__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD1___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":4623
 *     cdef public VecD1 loose
 *     def __init__(self):
 *         self.compact=[]             # <<<<<<<<<<<<<<
 *         self.loose=VecD1()
 *         self.loose.vec.reserve(100000)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4624
 *     def __init__(self):
 *         self.compact=[]
 *         self.loose=VecD1()             # <<<<<<<<<<<<<<
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4625
 *         self.compact=[]
 *         self.loose=VecD1()
 *         self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 */
  __pyx_v_self->loose->vec.reserve(100000);

  /* "lurrn/sparsmat.pyx":4622
 *     cdef public object compact
 *     cdef public VecD1 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecD1()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD1.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4626
 *         self.loose=VecD1()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ensure_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_2ensure_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD1_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":4627
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *         self.loose=VecD1()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":4628
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *         self.loose=VecD1()
 *         while len(self.compact)>=2:
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":4629
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 *         self.loose=VecD1()             # <<<<<<<<<<<<<<
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":4630
 *             self.compact.append(self.loose)
 *         self.loose=VecD1()
 *         while len(self.compact)>=2:             # <<<<<<<<<<<<<<
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0, item=1):
 */
  while (1) {
    __pyx_t_2 = __pyx_v_self->compact;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4630; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = ((__pyx_t_6 >= 2) != 0);
    if (!__pyx_t_4) break;

    /* "lurrn/sparsmat.pyx":4631
 *         self.loose=VecD1()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.loose.c_add(k0, item)
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4631; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4631; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_1, -2, 0, NULL, NULL, &__pyx_slice__53, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4626
 *         self.loose=VecD1()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD1.ensure_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4632
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0, item=1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0, item)
 *         if self.loose.get_size(False)>=100000:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  PyObject *__pyx_v_item = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_item,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_item);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4632; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4632; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_item = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4632; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD1.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_4add_count(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *)__pyx_v_self), __pyx_v_k0, __pyx_v_item);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD1_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self, coordinate_t __pyx_v_k0, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":4633
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.loose.c_add(k0, item)             # <<<<<<<<<<<<<<
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 */
  __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_item); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD1 *)__pyx_v_self->loose->__pyx_vtab)->c_add(__pyx_v_self->loose, __pyx_v_k0, __pyx_t_1);

  /* "lurrn/sparsmat.pyx":4634
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.loose.c_add(k0, item)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__54, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_int_100000, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":4635
 *         self.loose.c_add(k0, item)
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *             self.loose=VecD1()
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD1 *)__pyx_v_self->loose->__pyx_vtab)->ensure_compact(__pyx_v_self->loose);

    /* "lurrn/sparsmat.pyx":4636
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *             self.loose=VecD1()
 *             self.loose.vec.reserve(100000)
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lurrn/sparsmat.pyx":4637
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 *             self.loose=VecD1()             # <<<<<<<<<<<<<<
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 */
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->loose);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
    __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":4638
 *             self.compact.append(self.loose)
 *             self.loose=VecD1()
 *             self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 */
    __pyx_v_self->loose->vec.reserve(100000);

    /* "lurrn/sparsmat.pyx":4639
 *             self.loose=VecD1()
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and             # <<<<<<<<<<<<<<
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
    while (1) {
      __pyx_t_2 = __pyx_v_self->compact;
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_7 = ((__pyx_t_6 >= 2) != 0);
      if (__pyx_t_7) {
      } else {
        __pyx_t_4 = __pyx_t_7;
        goto __pyx_L6_bool_binop_done;
      }

      /* "lurrn/sparsmat.pyx":4640
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):             # <<<<<<<<<<<<<<
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 */
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4640; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4640; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyNumber_Multiply(__pyx_float_0_6, __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_2, __pyx_t_9, Py_GE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_4 = __pyx_t_7;
      __pyx_L6_bool_binop_done:;
      if (!__pyx_t_4) break;

      /* "lurrn/sparsmat.pyx":4641
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4641; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4641; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = PyNumber_Add(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyList_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_9, -2, 0, NULL, NULL, &__pyx_slice__55, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":4632
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0, item=1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0, item)
 *         if self.loose.get_size(False)>=100000:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD1.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4642
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_6get_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD1_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_compact", 0);

  /* "lurrn/sparsmat.pyx":4643
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         if len(self.compact)>0:
 *             return self.compact[0]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4644
 *     def get_compact(self):
 *         self.ensure_compact()
 *         if len(self.compact)>0:             # <<<<<<<<<<<<<<
 *             return self.compact[0]
 *         else:
 */
  __pyx_t_1 = __pyx_v_self->compact;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((__pyx_t_4 > 0) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":4645
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 *             return self.compact[0]             # <<<<<<<<<<<<<<
 *         else:
 *             return VecD1()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4645; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":4647
 *             return self.compact[0]
 *         else:
 *             return VecD1()             # <<<<<<<<<<<<<<
 *     def get_size(self, compactify=True):
 *         cdef int n
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":4642
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD1.get_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4648
 *         else:
 *             return VecD1()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4648; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4648; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD1.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_8get_size(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD1_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  int __pyx_v_n;
  PyObject *__pyx_v_c = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":4650
 *     def get_size(self, compactify=True):
 *         cdef int n
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *             if self.compact:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":4651
 *         cdef int n
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *             if self.compact:
 *                 return self.compact[0].get_size()
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":4652
 *         if compactify:
 *             self.ensure_compact()
 *             if self.compact:             # <<<<<<<<<<<<<<
 *                 return self.compact[0].get_size()
 *             else:
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->compact); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":4653
 *             self.ensure_compact()
 *             if self.compact:
 *                 return self.compact[0].get_size()             # <<<<<<<<<<<<<<
 *             else:
 *                 return 0
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4653; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":4655
 *                 return self.compact[0].get_size()
 *             else:
 *                 return 0             # <<<<<<<<<<<<<<
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_int_0);
      __pyx_r = __pyx_int_0;
      goto __pyx_L0;
    }
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":4657
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_v_self->compact)) || PyTuple_CheckExact(__pyx_v_self->compact)) {
      __pyx_t_4 = __pyx_v_self->compact; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_self->compact); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_get_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__56, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":4658
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__57, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":4659
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)
 *             return n             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         self.ensure_compact()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":4648
 *         else:
 *             return VecD1()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD1.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_c);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4660
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_11__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_11__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_10__iter__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD1_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":4661
 *             return n
 *     def __iter__(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         try:
 *             return iter(self.compact[0])
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4662
 *     def __iter__(self):
 *         self.ensure_compact()
 *         try:             # <<<<<<<<<<<<<<
 *             return iter(self.compact[0])
 *         except IndexError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "lurrn/sparsmat.pyx":4663
 *         self.ensure_compact()
 *         try:
 *             return iter(self.compact[0])             # <<<<<<<<<<<<<<
 *         except IndexError:
 *             return iter([])
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4663; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4663; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L7_try_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":4664
 *         try:
 *             return iter(self.compact[0])
 *         except IndexError:             # <<<<<<<<<<<<<<
 *             return iter([])
 * 
 */
    __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_IndexError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD1.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4664; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_3);

      /* "lurrn/sparsmat.pyx":4665
 *             return iter(self.compact[0])
 *         except IndexError:
 *             return iter([])             # <<<<<<<<<<<<<<
 * 
 *     def get_type_counts(self, k=0):
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4665; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4665; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_r = __pyx_t_9;
      __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":4660
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD1.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4667
 *             return iter([])
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_13get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_13get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4667; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4667; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_12get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD1_12get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);

  /* "lurrn/sparsmat.pyx":4668
 * 
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)             # <<<<<<<<<<<<<<
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_k);
    __Pyx_GIVEREF(__pyx_v_k);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4667
 *             return iter([])
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4669
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_15remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_15remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  PyObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4669; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4669; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = values[0];
    __pyx_v_filt = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4669; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_14remap(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD1_14remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);

  /* "lurrn/sparsmat.pyx":4670
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_remap); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_v_k);
  PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_k);
  __Pyx_GIVEREF(__pyx_v_k);
  __Pyx_INCREF(__pyx_v_filt);
  PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_filt);
  __Pyx_GIVEREF(__pyx_v_filt);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4669
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4620
 * 
 * cdef class LargeVecD1:
 *     cdef public object compact             # <<<<<<<<<<<<<<
 *     cdef public VecD1 loose
 *     def __init__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_7compact_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_7compact_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_7compact___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD1_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->compact);
  __pyx_r = __pyx_v_self->compact;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD1_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD1_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_7compact_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD1_7compact_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD1_7compact_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_7compact_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4621
 * cdef class LargeVecD1:
 *     cdef public object compact
 *     cdef public VecD1 loose             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *         self.compact=[]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_5loose_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_5loose_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_5loose___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD1_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->loose));
  __pyx_r = ((PyObject *)__pyx_v_self->loose);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD1_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD1_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_5loose_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5lurrn_8sparsmat_VecD1))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD1.loose.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD1_5loose_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD1_5loose_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_5loose_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD1_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4677
 * cdef class VecD2:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_5VecD2_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_5VecD2_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2___init__(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_5VecD2___init__(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":4678
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     def item_iter(self):
 *         self.ensure_compact()
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":4677
 * cdef class VecD2:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4679
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecD2_iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("item_iter (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2_2item_iter(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("item_iter", 0);

  /* "lurrn/sparsmat.pyx":4680
 *         self.is_compact=True
 *     def item_iter(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return IVecD2_iter(self)
 *     def get_size(self,compactify=True):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":4681
 *     def item_iter(self):
 *         self.ensure_compact()
 *         return IVecD2_iter(self)             # <<<<<<<<<<<<<<
 *     def get_size(self,compactify=True):
 *         if compactify:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_IVecD2_iter)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4679
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecD2_iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.item_iter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4682
 *         self.ensure_compact()
 *         return IVecD2_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4682; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4682; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2_4get_size(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":4683
 *         return IVecD2_iter(self)
 *     def get_size(self,compactify=True):
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *         return self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":4684
 *     def get_size(self,compactify=True):
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return self.vec.size()
 *     def __len__(self):
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":4685
 *         if compactify:
 *             self.ensure_compact()
 *         return self.vec.size()             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return self.get_size(True)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_self->vec.size()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4682
 *         self.ensure_compact()
 *         return IVecD2_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4686
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecD2_7__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecD2_7__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2_6__len__(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecD2_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":4687
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__58, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4686
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4688
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2_8clear(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear", 0);

  /* "lurrn/sparsmat.pyx":4689
 *         return self.get_size(True)
 *     def clear(self):
 *         self.vec.resize(0)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void compactify(self):
 */
  __pyx_v_self->vec.resize(0);

  /* "lurrn/sparsmat.pyx":4690
 *     def clear(self):
 *         self.vec.resize(0)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrD2 comp
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":4688
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4691
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrD2 comp
 *         c_IVecD2_sort(self.vec.begin(),self.vec.end(),comp)
 */

static void __pyx_f_5lurrn_8sparsmat_5VecD2_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self) {
  struct smallerAddr<2,double> __pyx_v_comp;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compactify", 0);

  /* "lurrn/sparsmat.pyx":4693
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrD2 comp
 *         c_IVecD2_sort(self.vec.begin(),self.vec.end(),comp)             # <<<<<<<<<<<<<<
 *         c_compactifyD2(&self.vec)
 *         self.is_compact=True
 */
  sort(__pyx_v_self->vec.begin(), __pyx_v_self->vec.end(), __pyx_v_comp);

  /* "lurrn/sparsmat.pyx":4694
 *         cdef c_SmallerAddrD2 comp
 *         c_IVecD2_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyD2(&self.vec)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 */
  compactify((&__pyx_v_self->vec));

  /* "lurrn/sparsmat.pyx":4695
 *         c_IVecD2_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyD2(&self.vec)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":4691
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrD2 comp
 *         c_IVecD2_sort(self.vec.begin(),self.vec.end(),comp)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":4696
 *         c_compactifyD2(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

static void __pyx_f_5lurrn_8sparsmat_5VecD2_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":4697
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:             # <<<<<<<<<<<<<<
 *             self.compactify()
 *     cpdef double get_count(self,coordinate_t k0,coordinate_t k1):
 */
  __pyx_t_1 = ((!(__pyx_v_self->is_compact != 0)) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":4698
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 *             self.compactify()             # <<<<<<<<<<<<<<
 *     cpdef double get_count(self,coordinate_t k0,coordinate_t k1):
 *         cdef c_CItemD2 ci
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_self->__pyx_vtab)->compactify(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":4696
 *         c_compactifyD2(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":4699
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef double get_count(self,coordinate_t k0,coordinate_t k1):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD2 ci
 *         ci.addr[0]=k0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_5VecD2_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, int __pyx_skip_dispatch) {
  struct CountItem<2,double> __pyx_v_ci;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  double __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_11get_count)) {
      __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_5 = __pyx_t_1; __pyx_t_6 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_7 = 1;
        }
      }
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_6) {
        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_9;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4701
 *     cpdef double get_count(self,coordinate_t k0,coordinate_t k1):
 *         cdef c_CItemD2 ci
 *         ci.addr[0]=k0             # <<<<<<<<<<<<<<
 *         ci.addr[1]=k1
 *         return c_get_countD2(&self.vec,ci)
 */
  (__pyx_v_ci.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":4702
 *         cdef c_CItemD2 ci
 *         ci.addr[0]=k0
 *         ci.addr[1]=k1             # <<<<<<<<<<<<<<
 *         return c_get_countD2(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1, double item):
 */
  (__pyx_v_ci.addr[1]) = __pyx_v_k1;

  /* "lurrn/sparsmat.pyx":4703
 *         ci.addr[0]=k0
 *         ci.addr[1]=k1
 *         return c_get_countD2(&self.vec,ci)             # <<<<<<<<<<<<<<
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1, double item):
 *         cdef c_CItemD2 c
 */
  __pyx_r = get_count_v((&__pyx_v_self->vec), __pyx_v_ci);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4699
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef double get_count(self,coordinate_t k0,coordinate_t k1):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD2 ci
 *         ci.addr[0]=k0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecD2.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_count", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4699; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4699; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4699; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4699; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_count", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4699; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2_10get_count(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_5VecD2_get_count(__pyx_v_self, __pyx_v_k0, __pyx_v_k1, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4704
 *         ci.addr[1]=k1
 *         return c_get_countD2(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1, double item):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD2 c
 *         c.addr[0]=k0
 */

static void __pyx_f_5lurrn_8sparsmat_5VecD2_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, double __pyx_v_item) {
  struct CountItem<2,double> __pyx_v_c;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_add", 0);

  /* "lurrn/sparsmat.pyx":4706
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1, double item):
 *         cdef c_CItemD2 c
 *         c.addr[0]=k0             # <<<<<<<<<<<<<<
 *         c.addr[1]=k1
 *         c.item=item
 */
  (__pyx_v_c.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":4707
 *         cdef c_CItemD2 c
 *         c.addr[0]=k0
 *         c.addr[1]=k1             # <<<<<<<<<<<<<<
 *         c.item=item
 *         self.vec.push_back(c)
 */
  (__pyx_v_c.addr[1]) = __pyx_v_k1;

  /* "lurrn/sparsmat.pyx":4708
 *         c.addr[0]=k0
 *         c.addr[1]=k1
 *         c.item=item             # <<<<<<<<<<<<<<
 *         self.vec.push_back(c)
 *         self.is_compact=False
 */
  __pyx_v_c.item = __pyx_v_item;

  /* "lurrn/sparsmat.pyx":4709
 *         c.addr[1]=k1
 *         c.item=item
 *         self.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 */
  __pyx_v_self->vec.push_back(__pyx_v_c);

  /* "lurrn/sparsmat.pyx":4710
 *         c.item=item
 *         self.vec.push_back(c)
 *         self.is_compact=False             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.c_add(k0,k1, item)
 */
  __pyx_v_self->is_compact = 0;

  /* "lurrn/sparsmat.pyx":4704
 *         ci.addr[1]=k1
 *         return c_get_countD2(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1, double item):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD2 c
 *         c.addr[0]=k0
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":4711
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1, item)
 *     def __add__(VecD2 self, VecD2 other):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  PyObject *__pyx_v_item = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,&__pyx_n_s_item,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4711; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_item);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4711; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4711; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4711; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_item = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4711; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2_12add_count(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1, __pyx_v_item);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":4712
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.c_add(k0,k1, item)             # <<<<<<<<<<<<<<
 *     def __add__(VecD2 self, VecD2 other):
 *         cdef c_CItemD2 c1, c2
 */
  __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_item); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_v_k0, __pyx_v_k1, __pyx_t_1);

  /* "lurrn/sparsmat.pyx":4711
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1, item)
 *     def __add__(VecD2 self, VecD2 other):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4713
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.c_add(k0,k1, item)
 *     def __add__(VecD2 self, VecD2 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD2 c1, c2
 *         cdef unsigned int i1, i2
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_VecD2, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_VecD2, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2_14__add__(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_other) {
  struct CountItem<2,double> __pyx_v_c1;
  struct CountItem<2,double> __pyx_v_c2;
  unsigned int __pyx_v_i1;
  unsigned int __pyx_v_i2;
  int __pyx_v_k;
  int __pyx_v_delta;
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":4718
 *         cdef int k, delta
 *         cdef VecD2 result
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         other.ensure_compact()
 *         result=VecD2()
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":4719
 *         cdef VecD2 result
 *         self.ensure_compact()
 *         other.ensure_compact()             # <<<<<<<<<<<<<<
 *         result=VecD2()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_other->__pyx_vtab)->ensure_compact(__pyx_v_other);

  /* "lurrn/sparsmat.pyx":4720
 *         self.ensure_compact()
 *         other.ensure_compact()
 *         result=VecD2()             # <<<<<<<<<<<<<<
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4721
 *         other.ensure_compact()
 *         result=VecD2()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))             # <<<<<<<<<<<<<<
 *         i1=0
 *         i2=0
 */
  __pyx_t_2 = __pyx_v_other->vec.size();
  __pyx_t_3 = __pyx_v_self->vec.size();
  if (((__pyx_t_2 > __pyx_t_3) != 0)) {
    __pyx_t_4 = __pyx_t_2;
  } else {
    __pyx_t_4 = __pyx_t_3;
  }
  __pyx_v_result->vec.reserve(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":4722
 *         result=VecD2()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0             # <<<<<<<<<<<<<<
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 */
  __pyx_v_i1 = 0;

  /* "lurrn/sparsmat.pyx":4723
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 *         i2=0             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 */
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":4724
 *         i1=0
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 */
  while (1) {
    __pyx_t_6 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_6 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":4725
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             delta=0
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":4726
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             delta=0
 *             for k from 0<=k<2:
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":4727
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 *             delta=0             # <<<<<<<<<<<<<<
 *             for k from 0<=k<2:
 *                 if c1.addr[k]<c2.addr[k]:
 */
    __pyx_v_delta = 0;

    /* "lurrn/sparsmat.pyx":4728
 *             c2=other.vec.at(i2)
 *             delta=0
 *             for k from 0<=k<2:             # <<<<<<<<<<<<<<
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 */
    for (__pyx_v_k = 0; __pyx_v_k < 2; __pyx_v_k++) {

      /* "lurrn/sparsmat.pyx":4729
 *             delta=0
 *             for k from 0<=k<2:
 *                 if c1.addr[k]<c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=-1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) < (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":4730
 *             for k from 0<=k<2:
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1             # <<<<<<<<<<<<<<
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 */
        __pyx_v_delta = -1;

        /* "lurrn/sparsmat.pyx":4731
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 *                     break             # <<<<<<<<<<<<<<
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 */
        goto __pyx_L8_break;
      }

      /* "lurrn/sparsmat.pyx":4732
 *                     delta=-1
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) > (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":4733
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1             # <<<<<<<<<<<<<<
 *                     break
 *             if delta==0:
 */
        __pyx_v_delta = 1;

        /* "lurrn/sparsmat.pyx":4734
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 *                     break             # <<<<<<<<<<<<<<
 *             if delta==0:
 *                 c1.item+=c2.item
 */
        goto __pyx_L8_break;
      }
    }
    __pyx_L8_break:;

    /* "lurrn/sparsmat.pyx":4740
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
    switch (__pyx_v_delta) {

      /* "lurrn/sparsmat.pyx":4735
 *                     delta=1
 *                     break
 *             if delta==0:             # <<<<<<<<<<<<<<
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)
 */
      case 0:

      /* "lurrn/sparsmat.pyx":4736
 *                     break
 *             if delta==0:
 *                 c1.item+=c2.item             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      __pyx_v_c1.item = (__pyx_v_c1.item + __pyx_v_c2.item);

      /* "lurrn/sparsmat.pyx":4737
 *             if delta==0:
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *                 i2+=1
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":4738
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *                 i2+=1
 *             elif delta==-1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);

      /* "lurrn/sparsmat.pyx":4739
 *                 result.vec.push_back(c1)
 *                 i1+=1
 *                 i2+=1             # <<<<<<<<<<<<<<
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;

      /* "lurrn/sparsmat.pyx":4740
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      case -1:

      /* "lurrn/sparsmat.pyx":4741
 *                 i2+=1
 *             elif delta==-1:
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             else:
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":4742
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             else:
 *                 result.vec.push_back(c2)
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      break;
      default:

      /* "lurrn/sparsmat.pyx":4744
 *                 i1+=1
 *             else:
 *                 result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *                 i2+=1
 *         while i1<self.vec.size():
 */
      __pyx_v_result->vec.push_back(__pyx_v_c2);

      /* "lurrn/sparsmat.pyx":4745
 *             else:
 *                 result.vec.push_back(c2)
 *                 i2+=1             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;
    }
  }

  /* "lurrn/sparsmat.pyx":4746
 *                 result.vec.push_back(c2)
 *                 i2+=1
 *         while i1<self.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":4747
 *                 i2+=1
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c1)
 *             i1+=1
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":4748
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *             i1+=1
 *         while i2<other.vec.size():
 */
    __pyx_v_result->vec.push_back(__pyx_v_c1);

    /* "lurrn/sparsmat.pyx":4749
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 *             i1+=1             # <<<<<<<<<<<<<<
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);
  }

  /* "lurrn/sparsmat.pyx":4750
 *             result.vec.push_back(c1)
 *             i1+=1
 *         while i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":4751
 *             i1+=1
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c2)
 *             i2+=1
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":4752
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *             i2+=1
 *         return result
 */
    __pyx_v_result->vec.push_back(__pyx_v_c2);

    /* "lurrn/sparsmat.pyx":4753
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 *             i2+=1             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_v_i2 = (__pyx_v_i2 + 1);
  }

  /* "lurrn/sparsmat.pyx":4754
 *             result.vec.push_back(c2)
 *             i2+=1
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     cpdef CSRMatrixD to_csr(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4713
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.c_add(k0,k1, item)
 *     def __add__(VecD2 self, VecD2 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD2 c1, c2
 *         cdef unsigned int i1, i2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4756
 *         return result
 * 
 *     cpdef CSRMatrixD to_csr(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         cdef c_CSRMatrixD *matC=vec2csrD(&self.vec)
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_17to_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_5VecD2_to_csr(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, int __pyx_skip_dispatch) {
  struct CSRMatrix<double> *__pyx_v_matC;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_v_mat = 0;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_csr", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_to_csr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_17to_csr)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4757
 * 
 *     cpdef CSRMatrixD to_csr(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         cdef c_CSRMatrixD *matC=vec2csrD(&self.vec)
 *         cdef CSRMatrixD mat=CSRMatrixD()
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":4758
 *     cpdef CSRMatrixD to_csr(self):
 *         self.ensure_compact()
 *         cdef c_CSRMatrixD *matC=vec2csrD(&self.vec)             # <<<<<<<<<<<<<<
 *         cdef CSRMatrixD mat=CSRMatrixD()
 *         mat.set_matrix(matC)
 */
  __pyx_v_matC = vec2csr((&__pyx_v_self->vec));

  /* "lurrn/sparsmat.pyx":4759
 *         self.ensure_compact()
 *         cdef c_CSRMatrixD *matC=vec2csrD(&self.vec)
 *         cdef CSRMatrixD mat=CSRMatrixD()             # <<<<<<<<<<<<<<
 *         mat.set_matrix(matC)
 *         return mat
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_CSRMatrixD)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_mat = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4760
 *         cdef c_CSRMatrixD *matC=vec2csrD(&self.vec)
 *         cdef CSRMatrixD mat=CSRMatrixD()
 *         mat.set_matrix(matC)             # <<<<<<<<<<<<<<
 *         return mat
 * 
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixD *)__pyx_v_mat->__pyx_vtab)->set_matrix(__pyx_v_mat, __pyx_v_matC);

  /* "lurrn/sparsmat.pyx":4761
 *         cdef CSRMatrixD mat=CSRMatrixD()
 *         mat.set_matrix(matC)
 *         return mat             # <<<<<<<<<<<<<<
 * 
 *     def tofile(self, f):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_mat));
  __pyx_r = __pyx_v_mat;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4756
 *         return result
 * 
 *     cpdef CSRMatrixD to_csr(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         cdef c_CSRMatrixD *matC=vec2csrD(&self.vec)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.to_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mat);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_17to_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_17to_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_csr (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2_16to_csr(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_16to_csr(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_csr", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_5VecD2_to_csr(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.to_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4763
 *         return mat
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_19tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_19tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tofile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2_18tofile(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_18tofile(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  long __pyx_v_k;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  long __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("tofile", 0);

  /* "lurrn/sparsmat.pyx":4765
 *     def tofile(self, f):
 *         cdef long i, n, k, k_max
 *         n=self.get_size()             # <<<<<<<<<<<<<<
 *         f.write('D2 %d\n'%(n,))
 *         k=0
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":4766
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 *         f.write('D2 %d\n'%(n,))             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_D2_d, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4767
 *         n=self.get_size()
 *         f.write('D2 %d\n'%(n,))
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecD2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemD2))
 */
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":4768
 *         f.write('D2 %d\n'%(n,))
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecD2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemD2))
 *             f.write(s)
 */
  __pyx_t_4 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4769
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecD2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemD2))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *             k+=CHUNK_SIZE
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), (256 * (sizeof(struct CountItem<2,double>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":4770
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecD2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemD2))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":4771
 *             s=PyString_FromStringAndSize(<char *>c_VecD2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemD2))
 *             f.write(s)
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecD2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemD2))
 */
    __pyx_v_k = (__pyx_v_k + 256);
  }

  /* "lurrn/sparsmat.pyx":4772
 *             f.write(s)
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecD2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemD2))
 *             f.write(s)
 */
  __pyx_t_7 = ((__pyx_v_k < __pyx_v_n) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":4773
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecD2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemD2))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *     def fromfile(self, f):
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), ((__pyx_v_n - __pyx_v_k) * (sizeof(struct CountItem<2,double>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":4774
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecD2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemD2))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *     def fromfile(self, f):
 *         cdef long i, n
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":4763
 *         return mat
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.tofile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4775
 *             s=PyString_FromStringAndSize(<char *>c_VecD2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemD2))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_21fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_21fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fromfile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2_20fromfile(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_20fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  PyObject *__pyx_v_line = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  long __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  size_t __pyx_t_9;
  char *__pyx_t_10;
  size_t __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromfile", 0);

  /* "lurrn/sparsmat.pyx":4777
 *     def fromfile(self, f):
 *         cdef long i, n
 *         line=f.readline().strip().split()             # <<<<<<<<<<<<<<
 *         assert line[0]=='D2'
 *         n=long(line[1])
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_readline); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_line = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4778
 *         cdef long i, n
 *         line=f.readline().strip().split()
 *         assert line[0]=='D2'             # <<<<<<<<<<<<<<
 *         n=long(line[1])
 *         self.clear()
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4778; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_D2, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_6)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":4779
 *         line=f.readline().strip().split()
 *         assert line[0]=='D2'
 *         n=long(line[1])             # <<<<<<<<<<<<<<
 *         self.clear()
 *         self.vec.resize(n)
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4779; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyLong_Type))), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_7;

  /* "lurrn/sparsmat.pyx":4780
 *         assert line[0]=='D2'
 *         n=long(line[1])
 *         self.clear()             # <<<<<<<<<<<<<<
 *         self.vec.resize(n)
 *         k=0
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clear); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4781
 *         n=long(line[1])
 *         self.clear()
 *         self.vec.resize(n)             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_v_self->vec.resize(__pyx_v_n);

  /* "lurrn/sparsmat.pyx":4782
 *         self.clear()
 *         self.vec.resize(n)
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemD2))
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_k = __pyx_int_0;

  /* "lurrn/sparsmat.pyx":4783
 *         self.vec.resize(n)
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemD2))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemD2)
 */
  __pyx_t_7 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4784
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemD2))             # <<<<<<<<<<<<<<
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemD2)
 *             memcpy(<void *>c_VecD2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemD2))
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyInt_FromSize_t((256 * (sizeof(struct CountItem<2,double>)))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":4785
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemD2))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemD2)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecD2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemD2))
 *             k+=CHUNK_SIZE
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!((__pyx_t_8 == (256 * (sizeof(struct CountItem<2,double>)))) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":4786
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemD2))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemD2)
 *             memcpy(<void *>c_VecD2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemD2))             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), (256 * (sizeof(struct CountItem<2,double>))));

    /* "lurrn/sparsmat.pyx":4787
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemD2)
 *             memcpy(<void *>c_VecD2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemD2))
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemD2))
 */
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_k, __pyx_int_256); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_1);
    __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4788
 *             memcpy(<void *>c_VecD2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemD2))
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=f.read((n-k)*sizeof(c_CItemD2))
 *             assert len(s)==(n-k)*sizeof(c_CItemD2)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":4789
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemD2))             # <<<<<<<<<<<<<<
 *             assert len(s)==(n-k)*sizeof(c_CItemD2)
 *             memcpy(<void *>c_VecD2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemD2))
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_5, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<2,double>))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":4790
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemD2))
 *             assert len(s)==(n-k)*sizeof(c_CItemD2)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecD2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemD2))
 *     cpdef int get_maxcol(self, int k=0):
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<2,double>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_6)) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":4791
 *             s=f.read((n-k)*sizeof(c_CItemD2))
 *             assert len(s)==(n-k)*sizeof(c_CItemD2)
 *             memcpy(<void *>c_VecD2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemD2))             # <<<<<<<<<<<<<<
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<2,double>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), __pyx_t_11);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":4775
 *             s=PyString_FromStringAndSize(<char *>c_VecD2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemD2))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.fromfile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_line);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4792
 *             assert len(s)==(n-k)*sizeof(c_CItemD2)
 *             memcpy(<void *>c_VecD2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemD2))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<2
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecD2_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD2_get_maxcol *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_i;
  int __pyx_v_n;
  int __pyx_v_new_val;
  int __pyx_v_col;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_maxcol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_23get_maxcol)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4794
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<2             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         if n==0:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_9 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_9 = ((__pyx_v_k < 2) != 0);
    __pyx_t_8 = __pyx_t_9;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_8)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":4795
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<2
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         if n==0:
 *             return -1
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":4796
 *         assert k>=0 and k<2
 *         n=self.vec.size()
 *         if n==0:             # <<<<<<<<<<<<<<
 *             return -1
 *         if k==0:
 */
  __pyx_t_8 = ((__pyx_v_n == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":4797
 *         n=self.vec.size()
 *         if n==0:
 *             return -1             # <<<<<<<<<<<<<<
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 */
    __pyx_r = -1;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":4798
 *         if n==0:
 *             return -1
 *         if k==0:             # <<<<<<<<<<<<<<
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 */
  __pyx_t_8 = ((__pyx_v_k == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":4799
 *             return -1
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]             # <<<<<<<<<<<<<<
 *         col=-1
 *         n=self.vec.size()
 */
    __pyx_r = (__pyx_v_self->vec.at((__pyx_v_n - 1)).addr[0]);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":4800
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 *         col=-1             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_v_col = -1;

  /* "lurrn/sparsmat.pyx":4801
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":4802
 *         col=-1
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 */
  __pyx_t_7 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4803
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             if new_val>col:
 *                 col=new_val
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":4804
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:             # <<<<<<<<<<<<<<
 *                 col=new_val
 *         return col
 */
    __pyx_t_8 = ((__pyx_v_new_val > __pyx_v_col) != 0);
    if (__pyx_t_8) {

      /* "lurrn/sparsmat.pyx":4805
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 *                 col=new_val             # <<<<<<<<<<<<<<
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 */
      __pyx_v_col = __pyx_v_new_val;
      goto __pyx_L9;
    }
    __pyx_L9:;
  }

  /* "lurrn/sparsmat.pyx":4806
 *             if new_val>col:
 *                 col=new_val
 *         return col             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 *         cdef int old_val, new_val, i, n, count
 */
  __pyx_r = __pyx_v_col;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4792
 *             assert len(s)==(n-k)*sizeof(c_CItemD2)
 *             memcpy(<void *>c_VecD2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemD2))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecD2.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_maxcol (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_maxcol") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4792; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4792; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_maxcol", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4792; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2_22get_maxcol(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_22get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecD2_get_maxcol __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = __pyx_vtabptr_5lurrn_8sparsmat_VecD2->get_maxcol(__pyx_v_self, 1, &__pyx_t_2); 
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4807
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecD2_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD2_get_type_counts *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_new_val;
  int __pyx_v_i;
  int __pyx_v_n;
  PyArrayObject *__pyx_v_result = 0;
  long __pyx_v_n_types;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecD2_get_maxcol __pyx_t_11;
  PyArrayObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_25get_type_counts)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4810
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<2             # <<<<<<<<<<<<<<
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_8 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_k < 2) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_7)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":4811
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<2
 *         if self.vec.size()==0:             # <<<<<<<<<<<<<<
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 */
  __pyx_t_7 = ((__pyx_v_self->vec.size() == 0) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":4812
 *         assert k>=0 and k<2
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_9 = 1;
      }
    }
    __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_2) {
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":4813
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":4814
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1             # <<<<<<<<<<<<<<
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 */
  __pyx_t_11.__pyx_n = 1;
  __pyx_t_11.k = __pyx_v_k;
  __pyx_t_10 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0, &__pyx_t_11); 
  __pyx_v_n_types = (__pyx_t_10 + 1);

  /* "lurrn/sparsmat.pyx":4815
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_n_types); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_9 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_6) {
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_12 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
    }
    __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_12 = 0;
  __pyx_v_result = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4816
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":4817
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4818
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             result[new_val]+=1
 *         return result
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":4819
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1             # <<<<<<<<<<<<<<
 *         return result
 *     cpdef VecD2 remap(self, int k, numpy.ndarray filt):
 */
    __pyx_t_16 = __pyx_v_new_val;
    __pyx_t_17 = -1;
    if (__pyx_t_16 < 0) {
      __pyx_t_16 += __pyx_pybuffernd_result.diminfo[0].shape;
      if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 0;
    } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_17 = 0;
    if (unlikely(__pyx_t_17 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_17);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_result.diminfo[0].strides) += 1;
  }

  /* "lurrn/sparsmat.pyx":4820
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 *         return result             # <<<<<<<<<<<<<<
 *     cpdef VecD2 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyArrayObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4807
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4807; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4807; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4807; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2_24get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_24get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecD2_get_type_counts __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_5lurrn_8sparsmat_VecD2->get_type_counts(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4821
 *             result[new_val]+=1
 *         return result
 *     cpdef VecD2 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_f_5lurrn_8sparsmat_5VecD2_remap(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_wanted = 0;
  PyArrayObject *__pyx_v_target = 0;
  int __pyx_v_n;
  int __pyx_v_i;
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_result = 0;
  struct CountItem<2,double> __pyx_v_c;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_target;
  __Pyx_Buffer __pyx_pybuffer_target;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_wanted;
  __Pyx_Buffer __pyx_pybuffer_wanted;
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __pyx_pybuffer_wanted.pybuffer.buf = NULL;
  __pyx_pybuffer_wanted.refcount = 0;
  __pyx_pybuffernd_wanted.data = NULL;
  __pyx_pybuffernd_wanted.rcbuffer = &__pyx_pybuffer_wanted;
  __pyx_pybuffer_target.pybuffer.buf = NULL;
  __pyx_pybuffer_target.refcount = 0;
  __pyx_pybuffernd_target.data = NULL;
  __pyx_pybuffernd_target.rcbuffer = &__pyx_pybuffer_target;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_remap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_27remap)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_filt));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_filt));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_filt));
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_VecD2))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4822
 *         return result
 *     cpdef VecD2 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__59, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_wanted = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_wanted.diminfo[0].strides = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_wanted.diminfo[0].shape = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_8 = 0;
  __pyx_v_wanted = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":4823
 *     cpdef VecD2 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_cumsum); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Subtract(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_target = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_target.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_target.diminfo[0].strides = __pyx_pybuffernd_target.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_target.diminfo[0].shape = __pyx_pybuffernd_target.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_9 = 0;
  __pyx_v_target = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4824
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         cdef int n=self.vec.size()
 *         cdef int i
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":4825
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()             # <<<<<<<<<<<<<<
 *         cdef int i
 *         cdef VecD2 result=VecD2()
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":4827
 *         cdef int n=self.vec.size()
 *         cdef int i
 *         cdef VecD2 result=VecD2()             # <<<<<<<<<<<<<<
 *         cdef c_CItemD2 c
 *         for i from 0<=i<n:
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4829
 *         cdef VecD2 result=VecD2()
 *         cdef c_CItemD2 c
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":4830
 *         cdef c_CItemD2 c
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)             # <<<<<<<<<<<<<<
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 */
    __pyx_v_c = __pyx_v_self->vec.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":4831
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:             # <<<<<<<<<<<<<<
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 */
    __pyx_t_11 = (__pyx_v_c.addr[__pyx_v_k]);
    __pyx_t_12 = -1;
    if (__pyx_t_11 < 0) {
      __pyx_t_11 += __pyx_pybuffernd_wanted.diminfo[0].shape;
      if (unlikely(__pyx_t_11 < 0)) __pyx_t_12 = 0;
    } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_wanted.diminfo[0].shape)) __pyx_t_12 = 0;
    if (unlikely(__pyx_t_12 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_12);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_wanted.diminfo[0].strides)) != 0);
    if (__pyx_t_13) {

      /* "lurrn/sparsmat.pyx":4832
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c)
 *         return result
 */
      __pyx_t_12 = (__pyx_v_c.addr[__pyx_v_k]);
      __pyx_t_14 = -1;
      if (__pyx_t_12 < 0) {
        __pyx_t_12 += __pyx_pybuffernd_target.diminfo[0].shape;
        if (unlikely(__pyx_t_12 < 0)) __pyx_t_14 = 0;
      } else if (unlikely(__pyx_t_12 >= __pyx_pybuffernd_target.diminfo[0].shape)) __pyx_t_14 = 0;
      if (unlikely(__pyx_t_14 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_14);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      (__pyx_v_c.addr[__pyx_v_k]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_target.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_target.diminfo[0].strides));

      /* "lurrn/sparsmat.pyx":4833
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         return result
 *     def append(self,tup):
 */
      __pyx_v_result->vec.push_back(__pyx_v_c);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "lurrn/sparsmat.pyx":4834
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 *         return result             # <<<<<<<<<<<<<<
 *     def append(self,tup):
 *         k0,k1,val=tup
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4821
 *             result[new_val]+=1
 *         return result
 *     cpdef VecD2 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_wanted);
  __Pyx_XDECREF((PyObject *)__pyx_v_target);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4821; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4821; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4821; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_filt = ((PyArrayObject *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4821; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_filt), __pyx_ptype_5numpy_ndarray, 1, "filt", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2_26remap(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_26remap(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_5VecD2_remap(__pyx_v_self, __pyx_v_k, __pyx_v_filt, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4835
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,k1,val=tup
 *         self.c_add(k0,k1,val)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_29append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_29append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("append (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2_28append(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self), ((PyObject *)__pyx_v_tup));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_28append(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_k1 = NULL;
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *(*__pyx_t_5)(PyObject *);
  coordinate_t __pyx_t_6;
  coordinate_t __pyx_t_7;
  double __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("append", 0);

  /* "lurrn/sparsmat.pyx":4836
 *         return result
 *     def append(self,tup):
 *         k0,k1,val=tup             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1,val)
 *     def extend(self,tups):
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_tup))) || (PyList_CheckExact(__pyx_v_tup))) {
    PyObject* sequence = __pyx_v_tup;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    #endif
  } else {
    Py_ssize_t index = -1;
    __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 2; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_k0 = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_k1 = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_val = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "lurrn/sparsmat.pyx":4837
 *     def append(self,tup):
 *         k0,k1,val=tup
 *         self.c_add(k0,k1,val)             # <<<<<<<<<<<<<<
 *     def extend(self,tups):
 *         for k0,k1,val in tups:
 */
  __pyx_t_6 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_6 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k1); if (unlikely((__pyx_t_7 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_v_val); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_6, __pyx_t_7, __pyx_t_8);

  /* "lurrn/sparsmat.pyx":4835
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,k1,val=tup
 *         self.c_add(k0,k1,val)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_k1);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4838
 *         k0,k1,val=tup
 *         self.c_add(k0,k1,val)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,k1,val in tups:
 *             self.c_add(k0,k1,val)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_31extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_31extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extend (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2_30extend(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self), ((PyObject *)__pyx_v_tups));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_30extend(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_k1 = NULL;
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  coordinate_t __pyx_t_10;
  coordinate_t __pyx_t_11;
  double __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("extend", 0);

  /* "lurrn/sparsmat.pyx":4839
 *         self.c_add(k0,k1,val)
 *     def extend(self,tups):
 *         for k0,k1,val in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,k1,val)
 *     def __iter__(self):
 */
  if (likely(PyList_CheckExact(__pyx_v_tups)) || PyTuple_CheckExact(__pyx_v_tups)) {
    __pyx_t_1 = __pyx_v_tups; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_tups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_8 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      index = 2; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_9 = NULL;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_k0, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_k1, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "lurrn/sparsmat.pyx":4840
 *     def extend(self,tups):
 *         for k0,k1,val in tups:
 *             self.c_add(k0,k1,val)             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self.item_iter()
 */
    __pyx_t_10 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_10 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k1); if (unlikely((__pyx_t_11 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_v_val); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_10, __pyx_t_11, __pyx_t_12);

    /* "lurrn/sparsmat.pyx":4839
 *         self.c_add(k0,k1,val)
 *     def extend(self,tups):
 *         for k0,k1,val in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,k1,val)
 *     def __iter__(self):
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4838
 *         k0,k1,val=tup
 *         self.c_add(k0,k1,val)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,k1,val in tups:
 *             self.c_add(k0,k1,val)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.extend", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_k1);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4841
 *         for k0,k1,val in tups:
 *             self.c_add(k0,k1,val)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_33__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_33__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2_32__iter__(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_32__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":4842
 *             self.c_add(k0,k1,val)
 *     def __iter__(self):
 *         return self.item_iter()             # <<<<<<<<<<<<<<
 *     def __reduce__(self):
 *         return (VecD2,(),(),self.item_iter())
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4841
 *         for k0,k1,val in tups:
 *             self.c_add(k0,k1,val)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4843
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecD2,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_35__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_35__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2_34__reduce__(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_34__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "lurrn/sparsmat.pyx":4844
 *         return self.item_iter()
 *     def __reduce__(self):
 *         return (VecD2,(),(),self.item_iter())             # <<<<<<<<<<<<<<
 *     def __setstate__(self,state):
 *         pass
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)));
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4843
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecD2,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4845
 *     def __reduce__(self):
 *         return (VecD2,(),(),self.item_iter())
 *     def __setstate__(self,state):             # <<<<<<<<<<<<<<
 *         pass
 *     def __repr__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_37__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_37__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2_36__setstate__(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self), ((PyObject *)__pyx_v_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_36__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4847
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecD2(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_39__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD2_39__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD2_38__repr__(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD2_38__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "lurrn/sparsmat.pyx":4848
 *         pass
 *     def __repr__(self):
 *         return 'VecD2(%s)'%(str(list(self)),)             # <<<<<<<<<<<<<<
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_VecD2_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4847
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecD2(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD2.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4849
 *     def __repr__(self):
 *         return 'VecD2(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

/* Python wrapper */
static void __pyx_pw_5lurrn_8sparsmat_5VecD2_41__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5lurrn_8sparsmat_5VecD2_41__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5lurrn_8sparsmat_5VecD2_40__dealloc__(((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5lurrn_8sparsmat_5VecD2_40__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lurrn/sparsmat.pyx":4851
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()             # <<<<<<<<<<<<<<
 * 
 * cdef class IVecD2_iter:
 */
  __pyx_v_self->vec.~vector();

  /* "lurrn/sparsmat.pyx":4849
 *     def __repr__(self):
 *         return 'VecD2(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":4857
 *     cdef c_VecD2 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_11IVecD2_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_11IVecD2_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_vec = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_vec,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4857; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_vec = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4857; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.IVecD2_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecD2_iter___init__(((struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter *)__pyx_v_self), __pyx_v_vec);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_11IVecD2_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter *__pyx_v_self, PyObject *__pyx_v_vec) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":4858
 *     cdef unsigned int k
 *     def __init__(self,vec):
 *         self.vec=vec             # <<<<<<<<<<<<<<
 *         self.vecC=&self.vec.vec
 *         self.k=0
 */
  if (!(likely(((__pyx_v_vec) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_vec, __pyx_ptype_5lurrn_8sparsmat_VecD2))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_vec;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->vec);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->vec));
  __pyx_v_self->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4859
 *     def __init__(self,vec):
 *         self.vec=vec
 *         self.vecC=&self.vec.vec             # <<<<<<<<<<<<<<
 *         self.k=0
 *     def __iter__(self):
 */
  __pyx_v_self->vecC = (&__pyx_v_self->vec->vec);

  /* "lurrn/sparsmat.pyx":4860
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 *         self.k=0             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self
 */
  __pyx_v_self->k = 0;

  /* "lurrn/sparsmat.pyx":4857
 *     cdef c_VecD2 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecD2_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4861
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecD2_iter_3__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecD2_iter_3__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecD2_iter_2__iter__(((struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecD2_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":4862
 *         self.k=0
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4861
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4863
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecD2_iter_5__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecD2_iter_5__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecD2_iter_4__next__(((struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecD2_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter *__pyx_v_self) {
  struct CountItem<2,double> __pyx_v_res;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "lurrn/sparsmat.pyx":4864
 *         return self
 *     def __next__(self):
 *         if self.k>=self.vecC.size():             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         cdef c_CItemD2 res=self.vecC.at(self.k)
 */
  __pyx_t_1 = ((__pyx_v_self->k >= __pyx_v_self->vecC->size()) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":4865
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         cdef c_CItemD2 res=self.vecC.at(self.k)
 *         self.k+=1
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lurrn/sparsmat.pyx":4866
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 *         cdef c_CItemD2 res=self.vecC.at(self.k)             # <<<<<<<<<<<<<<
 *         self.k+=1
 *         return (res.addr[0],
 */
  __pyx_v_res = __pyx_v_self->vecC->at(__pyx_v_self->k);

  /* "lurrn/sparsmat.pyx":4867
 *             raise StopIteration
 *         cdef c_CItemD2 res=self.vecC.at(self.k)
 *         self.k+=1             # <<<<<<<<<<<<<<
 *         return (res.addr[0],
 *                 res.addr[1],
 */
  __pyx_v_self->k = (__pyx_v_self->k + 1);

  /* "lurrn/sparsmat.pyx":4868
 *         cdef c_CItemD2 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.addr[1],
 *                 res.item)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_res.addr[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "lurrn/sparsmat.pyx":4869
 *         self.k+=1
 *         return (res.addr[0],
 *                 res.addr[1],             # <<<<<<<<<<<<<<
 *                 res.item)
 * 
 */
  __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_res.addr[1])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "lurrn/sparsmat.pyx":4870
 *         return (res.addr[0],
 *                 res.addr[1],
 *                 res.item)             # <<<<<<<<<<<<<<
 * 
 * cdef class LargeVecD2:
 */
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_res.item); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":4868
 *         cdef c_CItemD2 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.addr[1],
 *                 res.item)
 */
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4863
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecD2_iter.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4875
 *     cdef public object compact
 *     cdef public VecD2 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecD2()
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD2_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD2_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD2___init__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD2___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":4876
 *     cdef public VecD2 loose
 *     def __init__(self):
 *         self.compact=[]             # <<<<<<<<<<<<<<
 *         self.loose=VecD2()
 *         self.loose.vec.reserve(100000)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4877
 *     def __init__(self):
 *         self.compact=[]
 *         self.loose=VecD2()             # <<<<<<<<<<<<<<
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4878
 *         self.compact=[]
 *         self.loose=VecD2()
 *         self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 */
  __pyx_v_self->loose->vec.reserve(100000);

  /* "lurrn/sparsmat.pyx":4875
 *     cdef public object compact
 *     cdef public VecD2 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecD2()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD2.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4879
 *         self.loose=VecD2()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ensure_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_2ensure_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":4880
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *         self.loose=VecD2()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":4881
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *         self.loose=VecD2()
 *         while len(self.compact)>=2:
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":4882
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 *         self.loose=VecD2()             # <<<<<<<<<<<<<<
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":4883
 *             self.compact.append(self.loose)
 *         self.loose=VecD2()
 *         while len(self.compact)>=2:             # <<<<<<<<<<<<<<
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 */
  while (1) {
    __pyx_t_2 = __pyx_v_self->compact;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = ((__pyx_t_6 >= 2) != 0);
    if (!__pyx_t_4) break;

    /* "lurrn/sparsmat.pyx":4884
 *         self.loose=VecD2()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.loose.c_add(k0,k1, item)
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4884; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4884; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_1, -2, 0, NULL, NULL, &__pyx_slice__60, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4879
 *         self.loose=VecD2()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD2.ensure_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4885
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0,k1, item)
 *         if self.loose.get_size(False)>=100000:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  PyObject *__pyx_v_item = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,&__pyx_n_s_item,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4885; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_item);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4885; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4885; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4885; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_item = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4885; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD2.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_4add_count(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1, __pyx_v_item);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":4886
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.loose.c_add(k0,k1, item)             # <<<<<<<<<<<<<<
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 */
  __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_item); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_self->loose->__pyx_vtab)->c_add(__pyx_v_self->loose, __pyx_v_k0, __pyx_v_k1, __pyx_t_1);

  /* "lurrn/sparsmat.pyx":4887
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.loose.c_add(k0,k1, item)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__61, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_int_100000, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":4888
 *         self.loose.c_add(k0,k1, item)
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *             self.loose=VecD2()
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 *)__pyx_v_self->loose->__pyx_vtab)->ensure_compact(__pyx_v_self->loose);

    /* "lurrn/sparsmat.pyx":4889
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *             self.loose=VecD2()
 *             self.loose.vec.reserve(100000)
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lurrn/sparsmat.pyx":4890
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 *             self.loose=VecD2()             # <<<<<<<<<<<<<<
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 */
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->loose);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
    __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":4891
 *             self.compact.append(self.loose)
 *             self.loose=VecD2()
 *             self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 */
    __pyx_v_self->loose->vec.reserve(100000);

    /* "lurrn/sparsmat.pyx":4892
 *             self.loose=VecD2()
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and             # <<<<<<<<<<<<<<
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
    while (1) {
      __pyx_t_2 = __pyx_v_self->compact;
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_7 = ((__pyx_t_6 >= 2) != 0);
      if (__pyx_t_7) {
      } else {
        __pyx_t_4 = __pyx_t_7;
        goto __pyx_L6_bool_binop_done;
      }

      /* "lurrn/sparsmat.pyx":4893
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):             # <<<<<<<<<<<<<<
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 */
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4893; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4893; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyNumber_Multiply(__pyx_float_0_6, __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_2, __pyx_t_9, Py_GE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_4 = __pyx_t_7;
      __pyx_L6_bool_binop_done:;
      if (!__pyx_t_4) break;

      /* "lurrn/sparsmat.pyx":4894
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4894; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4894; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = PyNumber_Add(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyList_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_9, -2, 0, NULL, NULL, &__pyx_slice__62, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":4885
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0,k1, item)
 *         if self.loose.get_size(False)>=100000:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD2.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4895
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_6get_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_compact", 0);

  /* "lurrn/sparsmat.pyx":4896
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         if len(self.compact)>0:
 *             return self.compact[0]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4897
 *     def get_compact(self):
 *         self.ensure_compact()
 *         if len(self.compact)>0:             # <<<<<<<<<<<<<<
 *             return self.compact[0]
 *         else:
 */
  __pyx_t_1 = __pyx_v_self->compact;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((__pyx_t_4 > 0) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":4898
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 *             return self.compact[0]             # <<<<<<<<<<<<<<
 *         else:
 *             return VecD2()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4898; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":4900
 *             return self.compact[0]
 *         else:
 *             return VecD2()             # <<<<<<<<<<<<<<
 *     def get_size(self, compactify=True):
 *         cdef int n
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":4895
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD2.get_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4901
 *         else:
 *             return VecD2()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4901; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4901; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD2.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_8get_size(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  int __pyx_v_n;
  PyObject *__pyx_v_c = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":4903
 *     def get_size(self, compactify=True):
 *         cdef int n
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *             if self.compact:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":4904
 *         cdef int n
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *             if self.compact:
 *                 return self.compact[0].get_size()
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":4905
 *         if compactify:
 *             self.ensure_compact()
 *             if self.compact:             # <<<<<<<<<<<<<<
 *                 return self.compact[0].get_size()
 *             else:
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->compact); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":4906
 *             self.ensure_compact()
 *             if self.compact:
 *                 return self.compact[0].get_size()             # <<<<<<<<<<<<<<
 *             else:
 *                 return 0
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4906; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":4908
 *                 return self.compact[0].get_size()
 *             else:
 *                 return 0             # <<<<<<<<<<<<<<
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_int_0);
      __pyx_r = __pyx_int_0;
      goto __pyx_L0;
    }
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":4910
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_v_self->compact)) || PyTuple_CheckExact(__pyx_v_self->compact)) {
      __pyx_t_4 = __pyx_v_self->compact; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_self->compact); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_get_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__63, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":4911
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__64, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":4912
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)
 *             return n             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         self.ensure_compact()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":4901
 *         else:
 *             return VecD2()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD2.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_c);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4913
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_11__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_11__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_10__iter__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":4914
 *             return n
 *     def __iter__(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         try:
 *             return iter(self.compact[0])
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4915
 *     def __iter__(self):
 *         self.ensure_compact()
 *         try:             # <<<<<<<<<<<<<<
 *             return iter(self.compact[0])
 *         except IndexError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "lurrn/sparsmat.pyx":4916
 *         self.ensure_compact()
 *         try:
 *             return iter(self.compact[0])             # <<<<<<<<<<<<<<
 *         except IndexError:
 *             return iter([])
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4916; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4916; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L7_try_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":4917
 *         try:
 *             return iter(self.compact[0])
 *         except IndexError:             # <<<<<<<<<<<<<<
 *             return iter([])
 * 
 */
    __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_IndexError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD2.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4917; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_3);

      /* "lurrn/sparsmat.pyx":4918
 *             return iter(self.compact[0])
 *         except IndexError:
 *             return iter([])             # <<<<<<<<<<<<<<
 * 
 *     cpdef CSRMatrixD to_csr(self):
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4918; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4918; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_r = __pyx_t_9;
      __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":4913
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD2.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4920
 *             return iter([])
 * 
 *     cpdef CSRMatrixD to_csr(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return self.compact[0].to_csr()
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_13to_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_f_5lurrn_8sparsmat_10LargeVecD2_to_csr(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self, int __pyx_skip_dispatch) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_csr", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_to_csr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_13to_csr)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4921
 * 
 *     cpdef CSRMatrixD to_csr(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return self.compact[0].to_csr()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4922
 *     cpdef CSRMatrixD to_csr(self):
 *         self.ensure_compact()
 *         return self.compact[0].to_csr()             # <<<<<<<<<<<<<<
 * 
 *     def get_type_counts(self, k=0):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4922; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_to_csr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4920
 *             return iter([])
 * 
 *     cpdef CSRMatrixD to_csr(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return self.compact[0].to_csr()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD2.to_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_13to_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_13to_csr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_csr (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_12to_csr(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_12to_csr(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_csr", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_10LargeVecD2_to_csr(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD2.to_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4924
 *         return self.compact[0].to_csr()
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_15get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_15get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4924; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4924; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_14get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_14get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);

  /* "lurrn/sparsmat.pyx":4925
 * 
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)             # <<<<<<<<<<<<<<
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_k);
    __Pyx_GIVEREF(__pyx_v_k);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4924
 *         return self.compact[0].to_csr()
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4926
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_17remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_17remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  PyObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4926; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4926; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = values[0];
    __pyx_v_filt = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4926; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_16remap(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_16remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);

  /* "lurrn/sparsmat.pyx":4927
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_remap); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_v_k);
  PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_k);
  __Pyx_GIVEREF(__pyx_v_k);
  __Pyx_INCREF(__pyx_v_filt);
  PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_filt);
  __Pyx_GIVEREF(__pyx_v_filt);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4926
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4873
 * 
 * cdef class LargeVecD2:
 *     cdef public object compact             # <<<<<<<<<<<<<<
 *     cdef public VecD2 loose
 *     def __init__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_7compact_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_7compact_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_7compact___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->compact);
  __pyx_r = __pyx_v_self->compact;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD2_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD2_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_7compact_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD2_7compact_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD2_7compact_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_7compact_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4874
 * cdef class LargeVecD2:
 *     cdef public object compact
 *     cdef public VecD2 loose             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *         self.compact=[]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_5loose_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_5loose_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_5loose___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD2_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->loose));
  __pyx_r = ((PyObject *)__pyx_v_self->loose);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD2_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD2_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_5loose_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5lurrn_8sparsmat_VecD2))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD2.loose.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD2_5loose_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD2_5loose_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_5loose_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD2_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4934
 * cdef class VecD3:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_5VecD3_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_5VecD3_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD3___init__(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_5VecD3___init__(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":4935
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     def item_iter(self):
 *         self.ensure_compact()
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":4934
 * cdef class VecD3:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4936
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecD3_iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("item_iter (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD3_2item_iter(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("item_iter", 0);

  /* "lurrn/sparsmat.pyx":4937
 *         self.is_compact=True
 *     def item_iter(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return IVecD3_iter(self)
 *     def get_size(self,compactify=True):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":4938
 *     def item_iter(self):
 *         self.ensure_compact()
 *         return IVecD3_iter(self)             # <<<<<<<<<<<<<<
 *     def get_size(self,compactify=True):
 *         if compactify:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_IVecD3_iter)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4936
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecD3_iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.item_iter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4939
 *         self.ensure_compact()
 *         return IVecD3_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4939; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4939; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD3_4get_size(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":4940
 *         return IVecD3_iter(self)
 *     def get_size(self,compactify=True):
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *         return self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":4941
 *     def get_size(self,compactify=True):
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return self.vec.size()
 *     def __len__(self):
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":4942
 *         if compactify:
 *             self.ensure_compact()
 *         return self.vec.size()             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return self.get_size(True)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_self->vec.size()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4939
 *         self.ensure_compact()
 *         return IVecD3_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4943
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecD3_7__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecD3_7__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD3_6__len__(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecD3_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":4944
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__65, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4943
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4945
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD3_8clear(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear", 0);

  /* "lurrn/sparsmat.pyx":4946
 *         return self.get_size(True)
 *     def clear(self):
 *         self.vec.resize(0)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void compactify(self):
 */
  __pyx_v_self->vec.resize(0);

  /* "lurrn/sparsmat.pyx":4947
 *     def clear(self):
 *         self.vec.resize(0)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrD3 comp
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":4945
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4948
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrD3 comp
 *         c_IVecD3_sort(self.vec.begin(),self.vec.end(),comp)
 */

static void __pyx_f_5lurrn_8sparsmat_5VecD3_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self) {
  struct smallerAddr<3,double> __pyx_v_comp;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compactify", 0);

  /* "lurrn/sparsmat.pyx":4950
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrD3 comp
 *         c_IVecD3_sort(self.vec.begin(),self.vec.end(),comp)             # <<<<<<<<<<<<<<
 *         c_compactifyD3(&self.vec)
 *         self.is_compact=True
 */
  sort(__pyx_v_self->vec.begin(), __pyx_v_self->vec.end(), __pyx_v_comp);

  /* "lurrn/sparsmat.pyx":4951
 *         cdef c_SmallerAddrD3 comp
 *         c_IVecD3_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyD3(&self.vec)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 */
  compactify((&__pyx_v_self->vec));

  /* "lurrn/sparsmat.pyx":4952
 *         c_IVecD3_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyD3(&self.vec)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":4948
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrD3 comp
 *         c_IVecD3_sort(self.vec.begin(),self.vec.end(),comp)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":4953
 *         c_compactifyD3(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

static void __pyx_f_5lurrn_8sparsmat_5VecD3_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":4954
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:             # <<<<<<<<<<<<<<
 *             self.compactify()
 *     cpdef double get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):
 */
  __pyx_t_1 = ((!(__pyx_v_self->is_compact != 0)) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":4955
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 *             self.compactify()             # <<<<<<<<<<<<<<
 *     cpdef double get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):
 *         cdef c_CItemD3 ci
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD3 *)__pyx_v_self->__pyx_vtab)->compactify(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":4953
 *         c_compactifyD3(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":4956
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef double get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD3 ci
 *         ci.addr[0]=k0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_5VecD3_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, int __pyx_skip_dispatch) {
  struct CountItem<3,double> __pyx_v_ci;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  double __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD3_11get_count)) {
      __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_6 = __pyx_t_1; __pyx_t_7 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
          __pyx_t_8 = 1;
        }
      }
      __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_5 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_10;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":4958
 *     cpdef double get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):
 *         cdef c_CItemD3 ci
 *         ci.addr[0]=k0             # <<<<<<<<<<<<<<
 *         ci.addr[1]=k1
 *         ci.addr[2]=k2
 */
  (__pyx_v_ci.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":4959
 *         cdef c_CItemD3 ci
 *         ci.addr[0]=k0
 *         ci.addr[1]=k1             # <<<<<<<<<<<<<<
 *         ci.addr[2]=k2
 *         return c_get_countD3(&self.vec,ci)
 */
  (__pyx_v_ci.addr[1]) = __pyx_v_k1;

  /* "lurrn/sparsmat.pyx":4960
 *         ci.addr[0]=k0
 *         ci.addr[1]=k1
 *         ci.addr[2]=k2             # <<<<<<<<<<<<<<
 *         return c_get_countD3(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, double item):
 */
  (__pyx_v_ci.addr[2]) = __pyx_v_k2;

  /* "lurrn/sparsmat.pyx":4961
 *         ci.addr[1]=k1
 *         ci.addr[2]=k2
 *         return c_get_countD3(&self.vec,ci)             # <<<<<<<<<<<<<<
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, double item):
 *         cdef c_CItemD3 c
 */
  __pyx_r = get_count_v((&__pyx_v_self->vec), __pyx_v_ci);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4956
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef double get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD3 ci
 *         ci.addr[0]=k0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecD3.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,&__pyx_n_s_k2,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_count", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4956; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_count", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4956; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4956; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4956; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4956; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k2 = __Pyx_PyInt_As_coordinate_t(values[2]); if (unlikely((__pyx_v_k2 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4956; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_count", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4956; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD3_10get_count(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1, __pyx_v_k2);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_5VecD3_get_count(__pyx_v_self, __pyx_v_k0, __pyx_v_k1, __pyx_v_k2, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4962
 *         ci.addr[2]=k2
 *         return c_get_countD3(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, double item):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD3 c
 *         c.addr[0]=k0
 */

static void __pyx_f_5lurrn_8sparsmat_5VecD3_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, double __pyx_v_item) {
  struct CountItem<3,double> __pyx_v_c;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_add", 0);

  /* "lurrn/sparsmat.pyx":4964
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, double item):
 *         cdef c_CItemD3 c
 *         c.addr[0]=k0             # <<<<<<<<<<<<<<
 *         c.addr[1]=k1
 *         c.addr[2]=k2
 */
  (__pyx_v_c.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":4965
 *         cdef c_CItemD3 c
 *         c.addr[0]=k0
 *         c.addr[1]=k1             # <<<<<<<<<<<<<<
 *         c.addr[2]=k2
 *         c.item=item
 */
  (__pyx_v_c.addr[1]) = __pyx_v_k1;

  /* "lurrn/sparsmat.pyx":4966
 *         c.addr[0]=k0
 *         c.addr[1]=k1
 *         c.addr[2]=k2             # <<<<<<<<<<<<<<
 *         c.item=item
 *         self.vec.push_back(c)
 */
  (__pyx_v_c.addr[2]) = __pyx_v_k2;

  /* "lurrn/sparsmat.pyx":4967
 *         c.addr[1]=k1
 *         c.addr[2]=k2
 *         c.item=item             # <<<<<<<<<<<<<<
 *         self.vec.push_back(c)
 *         self.is_compact=False
 */
  __pyx_v_c.item = __pyx_v_item;

  /* "lurrn/sparsmat.pyx":4968
 *         c.addr[2]=k2
 *         c.item=item
 *         self.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 */
  __pyx_v_self->vec.push_back(__pyx_v_c);

  /* "lurrn/sparsmat.pyx":4969
 *         c.item=item
 *         self.vec.push_back(c)
 *         self.is_compact=False             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.c_add(k0,k1,k2, item)
 */
  __pyx_v_self->is_compact = 0;

  /* "lurrn/sparsmat.pyx":4962
 *         ci.addr[2]=k2
 *         return c_get_countD3(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, double item):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD3 c
 *         c.addr[0]=k0
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":4970
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1,k2, item)
 *     def __add__(VecD3 self, VecD3 other):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  PyObject *__pyx_v_item = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,&__pyx_n_s_k2,&__pyx_n_s_item,0};
    PyObject* values[4] = {0,0,0,0};
    values[3] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 0, 3, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4970; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 0, 3, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4970; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_item);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4970; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4970; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4970; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k2 = __Pyx_PyInt_As_coordinate_t(values[2]); if (unlikely((__pyx_v_k2 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4970; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_item = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4970; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD3_12add_count(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1, __pyx_v_k2, __pyx_v_item);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":4971
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.c_add(k0,k1,k2, item)             # <<<<<<<<<<<<<<
 *     def __add__(VecD3 self, VecD3 other):
 *         cdef c_CItemD3 c1, c2
 */
  __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_item); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD3 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_v_k0, __pyx_v_k1, __pyx_v_k2, __pyx_t_1);

  /* "lurrn/sparsmat.pyx":4970
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1,k2, item)
 *     def __add__(VecD3 self, VecD3 other):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":4972
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.c_add(k0,k1,k2, item)
 *     def __add__(VecD3 self, VecD3 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD3 c1, c2
 *         cdef unsigned int i1, i2
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_VecD3, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_VecD3, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD3_14__add__(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_other) {
  struct CountItem<3,double> __pyx_v_c1;
  struct CountItem<3,double> __pyx_v_c2;
  unsigned int __pyx_v_i1;
  unsigned int __pyx_v_i2;
  int __pyx_v_k;
  int __pyx_v_delta;
  struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":4977
 *         cdef int k, delta
 *         cdef VecD3 result
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         other.ensure_compact()
 *         result=VecD3()
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":4978
 *         cdef VecD3 result
 *         self.ensure_compact()
 *         other.ensure_compact()             # <<<<<<<<<<<<<<
 *         result=VecD3()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD3 *)__pyx_v_other->__pyx_vtab)->ensure_compact(__pyx_v_other);

  /* "lurrn/sparsmat.pyx":4979
 *         self.ensure_compact()
 *         other.ensure_compact()
 *         result=VecD3()             # <<<<<<<<<<<<<<
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4980
 *         other.ensure_compact()
 *         result=VecD3()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))             # <<<<<<<<<<<<<<
 *         i1=0
 *         i2=0
 */
  __pyx_t_2 = __pyx_v_other->vec.size();
  __pyx_t_3 = __pyx_v_self->vec.size();
  if (((__pyx_t_2 > __pyx_t_3) != 0)) {
    __pyx_t_4 = __pyx_t_2;
  } else {
    __pyx_t_4 = __pyx_t_3;
  }
  __pyx_v_result->vec.reserve(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":4981
 *         result=VecD3()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0             # <<<<<<<<<<<<<<
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 */
  __pyx_v_i1 = 0;

  /* "lurrn/sparsmat.pyx":4982
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 *         i2=0             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 */
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":4983
 *         i1=0
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 */
  while (1) {
    __pyx_t_6 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_6 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":4984
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             delta=0
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":4985
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             delta=0
 *             for k from 0<=k<3:
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":4986
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 *             delta=0             # <<<<<<<<<<<<<<
 *             for k from 0<=k<3:
 *                 if c1.addr[k]<c2.addr[k]:
 */
    __pyx_v_delta = 0;

    /* "lurrn/sparsmat.pyx":4987
 *             c2=other.vec.at(i2)
 *             delta=0
 *             for k from 0<=k<3:             # <<<<<<<<<<<<<<
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 */
    for (__pyx_v_k = 0; __pyx_v_k < 3; __pyx_v_k++) {

      /* "lurrn/sparsmat.pyx":4988
 *             delta=0
 *             for k from 0<=k<3:
 *                 if c1.addr[k]<c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=-1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) < (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":4989
 *             for k from 0<=k<3:
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1             # <<<<<<<<<<<<<<
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 */
        __pyx_v_delta = -1;

        /* "lurrn/sparsmat.pyx":4990
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 *                     break             # <<<<<<<<<<<<<<
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 */
        goto __pyx_L8_break;
      }

      /* "lurrn/sparsmat.pyx":4991
 *                     delta=-1
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) > (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":4992
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1             # <<<<<<<<<<<<<<
 *                     break
 *             if delta==0:
 */
        __pyx_v_delta = 1;

        /* "lurrn/sparsmat.pyx":4993
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 *                     break             # <<<<<<<<<<<<<<
 *             if delta==0:
 *                 c1.item+=c2.item
 */
        goto __pyx_L8_break;
      }
    }
    __pyx_L8_break:;

    /* "lurrn/sparsmat.pyx":4999
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
    switch (__pyx_v_delta) {

      /* "lurrn/sparsmat.pyx":4994
 *                     delta=1
 *                     break
 *             if delta==0:             # <<<<<<<<<<<<<<
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)
 */
      case 0:

      /* "lurrn/sparsmat.pyx":4995
 *                     break
 *             if delta==0:
 *                 c1.item+=c2.item             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      __pyx_v_c1.item = (__pyx_v_c1.item + __pyx_v_c2.item);

      /* "lurrn/sparsmat.pyx":4996
 *             if delta==0:
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *                 i2+=1
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":4997
 *                 c1.item+=c2.item
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *                 i2+=1
 *             elif delta==-1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);

      /* "lurrn/sparsmat.pyx":4998
 *                 result.vec.push_back(c1)
 *                 i1+=1
 *                 i2+=1             # <<<<<<<<<<<<<<
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;

      /* "lurrn/sparsmat.pyx":4999
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      case -1:

      /* "lurrn/sparsmat.pyx":5000
 *                 i2+=1
 *             elif delta==-1:
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             else:
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":5001
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             else:
 *                 result.vec.push_back(c2)
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      break;
      default:

      /* "lurrn/sparsmat.pyx":5003
 *                 i1+=1
 *             else:
 *                 result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *                 i2+=1
 *         while i1<self.vec.size():
 */
      __pyx_v_result->vec.push_back(__pyx_v_c2);

      /* "lurrn/sparsmat.pyx":5004
 *             else:
 *                 result.vec.push_back(c2)
 *                 i2+=1             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;
    }
  }

  /* "lurrn/sparsmat.pyx":5005
 *                 result.vec.push_back(c2)
 *                 i2+=1
 *         while i1<self.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":5006
 *                 i2+=1
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c1)
 *             i1+=1
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":5007
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *             i1+=1
 *         while i2<other.vec.size():
 */
    __pyx_v_result->vec.push_back(__pyx_v_c1);

    /* "lurrn/sparsmat.pyx":5008
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 *             i1+=1             # <<<<<<<<<<<<<<
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);
  }

  /* "lurrn/sparsmat.pyx":5009
 *             result.vec.push_back(c1)
 *             i1+=1
 *         while i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":5010
 *             i1+=1
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c2)
 *             i2+=1
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":5011
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *             i2+=1
 *         return result
 */
    __pyx_v_result->vec.push_back(__pyx_v_c2);

    /* "lurrn/sparsmat.pyx":5012
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 *             i2+=1             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_v_i2 = (__pyx_v_i2 + 1);
  }

  /* "lurrn/sparsmat.pyx":5013
 *             result.vec.push_back(c2)
 *             i2+=1
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def tofile(self, f):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":4972
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.c_add(k0,k1,k2, item)
 *     def __add__(VecD3 self, VecD3 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemD3 c1, c2
 *         cdef unsigned int i1, i2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5015
 *         return result
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_17tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_17tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tofile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD3_16tofile(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_16tofile(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  long __pyx_v_k;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  long __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("tofile", 0);

  /* "lurrn/sparsmat.pyx":5017
 *     def tofile(self, f):
 *         cdef long i, n, k, k_max
 *         n=self.get_size()             # <<<<<<<<<<<<<<
 *         f.write('D3 %d\n'%(n,))
 *         k=0
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":5018
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 *         f.write('D3 %d\n'%(n,))             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_D3_d, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5019
 *         n=self.get_size()
 *         f.write('D3 %d\n'%(n,))
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecD3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemD3))
 */
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":5020
 *         f.write('D3 %d\n'%(n,))
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecD3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemD3))
 *             f.write(s)
 */
  __pyx_t_4 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5021
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecD3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemD3))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *             k+=CHUNK_SIZE
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), (256 * (sizeof(struct CountItem<3,double>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":5022
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecD3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemD3))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":5023
 *             s=PyString_FromStringAndSize(<char *>c_VecD3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemD3))
 *             f.write(s)
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecD3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemD3))
 */
    __pyx_v_k = (__pyx_v_k + 256);
  }

  /* "lurrn/sparsmat.pyx":5024
 *             f.write(s)
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecD3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemD3))
 *             f.write(s)
 */
  __pyx_t_7 = ((__pyx_v_k < __pyx_v_n) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":5025
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecD3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemD3))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *     def fromfile(self, f):
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), ((__pyx_v_n - __pyx_v_k) * (sizeof(struct CountItem<3,double>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":5026
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecD3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemD3))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *     def fromfile(self, f):
 *         cdef long i, n
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":5015
 *         return result
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.tofile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5027
 *             s=PyString_FromStringAndSize(<char *>c_VecD3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemD3))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_19fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_19fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fromfile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD3_18fromfile(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_18fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  PyObject *__pyx_v_line = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  long __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  size_t __pyx_t_9;
  char *__pyx_t_10;
  size_t __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromfile", 0);

  /* "lurrn/sparsmat.pyx":5029
 *     def fromfile(self, f):
 *         cdef long i, n
 *         line=f.readline().strip().split()             # <<<<<<<<<<<<<<
 *         assert line[0]=='D3'
 *         n=long(line[1])
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_readline); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_line = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5030
 *         cdef long i, n
 *         line=f.readline().strip().split()
 *         assert line[0]=='D3'             # <<<<<<<<<<<<<<
 *         n=long(line[1])
 *         self.clear()
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5030; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_D3, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_6)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":5031
 *         line=f.readline().strip().split()
 *         assert line[0]=='D3'
 *         n=long(line[1])             # <<<<<<<<<<<<<<
 *         self.clear()
 *         self.vec.resize(n)
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5031; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyLong_Type))), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_7;

  /* "lurrn/sparsmat.pyx":5032
 *         assert line[0]=='D3'
 *         n=long(line[1])
 *         self.clear()             # <<<<<<<<<<<<<<
 *         self.vec.resize(n)
 *         k=0
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clear); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5033
 *         n=long(line[1])
 *         self.clear()
 *         self.vec.resize(n)             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_v_self->vec.resize(__pyx_v_n);

  /* "lurrn/sparsmat.pyx":5034
 *         self.clear()
 *         self.vec.resize(n)
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemD3))
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_k = __pyx_int_0;

  /* "lurrn/sparsmat.pyx":5035
 *         self.vec.resize(n)
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemD3))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemD3)
 */
  __pyx_t_7 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5036
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemD3))             # <<<<<<<<<<<<<<
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemD3)
 *             memcpy(<void *>c_VecD3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemD3))
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyInt_FromSize_t((256 * (sizeof(struct CountItem<3,double>)))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":5037
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemD3))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemD3)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecD3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemD3))
 *             k+=CHUNK_SIZE
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5037; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!((__pyx_t_8 == (256 * (sizeof(struct CountItem<3,double>)))) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5037; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":5038
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemD3))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemD3)
 *             memcpy(<void *>c_VecD3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemD3))             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), (256 * (sizeof(struct CountItem<3,double>))));

    /* "lurrn/sparsmat.pyx":5039
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemD3)
 *             memcpy(<void *>c_VecD3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemD3))
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemD3))
 */
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_k, __pyx_int_256); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_1);
    __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5040
 *             memcpy(<void *>c_VecD3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemD3))
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=f.read((n-k)*sizeof(c_CItemD3))
 *             assert len(s)==(n-k)*sizeof(c_CItemD3)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":5041
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemD3))             # <<<<<<<<<<<<<<
 *             assert len(s)==(n-k)*sizeof(c_CItemD3)
 *             memcpy(<void *>c_VecD3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemD3))
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_5, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<3,double>))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":5042
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemD3))
 *             assert len(s)==(n-k)*sizeof(c_CItemD3)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecD3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemD3))
 *     cpdef int get_maxcol(self, int k=0):
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<3,double>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_6)) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":5043
 *             s=f.read((n-k)*sizeof(c_CItemD3))
 *             assert len(s)==(n-k)*sizeof(c_CItemD3)
 *             memcpy(<void *>c_VecD3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemD3))             # <<<<<<<<<<<<<<
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<3,double>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), __pyx_t_11);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":5027
 *             s=PyString_FromStringAndSize(<char *>c_VecD3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemD3))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.fromfile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_line);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5044
 *             assert len(s)==(n-k)*sizeof(c_CItemD3)
 *             memcpy(<void *>c_VecD3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemD3))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<3
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_21get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecD3_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD3_get_maxcol *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_i;
  int __pyx_v_n;
  int __pyx_v_new_val;
  int __pyx_v_col;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_maxcol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD3_21get_maxcol)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5046
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<3             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         if n==0:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_9 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_9 = ((__pyx_v_k < 3) != 0);
    __pyx_t_8 = __pyx_t_9;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_8)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":5047
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<3
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         if n==0:
 *             return -1
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":5048
 *         assert k>=0 and k<3
 *         n=self.vec.size()
 *         if n==0:             # <<<<<<<<<<<<<<
 *             return -1
 *         if k==0:
 */
  __pyx_t_8 = ((__pyx_v_n == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":5049
 *         n=self.vec.size()
 *         if n==0:
 *             return -1             # <<<<<<<<<<<<<<
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 */
    __pyx_r = -1;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":5050
 *         if n==0:
 *             return -1
 *         if k==0:             # <<<<<<<<<<<<<<
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 */
  __pyx_t_8 = ((__pyx_v_k == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":5051
 *             return -1
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]             # <<<<<<<<<<<<<<
 *         col=-1
 *         n=self.vec.size()
 */
    __pyx_r = (__pyx_v_self->vec.at((__pyx_v_n - 1)).addr[0]);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":5052
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 *         col=-1             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_v_col = -1;

  /* "lurrn/sparsmat.pyx":5053
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":5054
 *         col=-1
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 */
  __pyx_t_7 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5055
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             if new_val>col:
 *                 col=new_val
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":5056
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:             # <<<<<<<<<<<<<<
 *                 col=new_val
 *         return col
 */
    __pyx_t_8 = ((__pyx_v_new_val > __pyx_v_col) != 0);
    if (__pyx_t_8) {

      /* "lurrn/sparsmat.pyx":5057
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 *                 col=new_val             # <<<<<<<<<<<<<<
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 */
      __pyx_v_col = __pyx_v_new_val;
      goto __pyx_L9;
    }
    __pyx_L9:;
  }

  /* "lurrn/sparsmat.pyx":5058
 *             if new_val>col:
 *                 col=new_val
 *         return col             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 *         cdef int old_val, new_val, i, n, count
 */
  __pyx_r = __pyx_v_col;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5044
 *             assert len(s)==(n-k)*sizeof(c_CItemD3)
 *             memcpy(<void *>c_VecD3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemD3))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<3
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecD3.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_21get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_21get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_maxcol (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_maxcol") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5044; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5044; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_maxcol", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5044; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD3_20get_maxcol(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_20get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecD3_get_maxcol __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = __pyx_vtabptr_5lurrn_8sparsmat_VecD3->get_maxcol(__pyx_v_self, 1, &__pyx_t_2); 
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5059
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_23get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecD3_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD3_get_type_counts *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_new_val;
  int __pyx_v_i;
  int __pyx_v_n;
  PyArrayObject *__pyx_v_result = 0;
  long __pyx_v_n_types;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecD3_get_maxcol __pyx_t_11;
  PyArrayObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD3_23get_type_counts)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5062
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<3             # <<<<<<<<<<<<<<
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_8 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_k < 3) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_7)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":5063
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<3
 *         if self.vec.size()==0:             # <<<<<<<<<<<<<<
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 */
  __pyx_t_7 = ((__pyx_v_self->vec.size() == 0) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":5064
 *         assert k>=0 and k<3
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_9 = 1;
      }
    }
    __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_2) {
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":5065
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":5066
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1             # <<<<<<<<<<<<<<
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 */
  __pyx_t_11.__pyx_n = 1;
  __pyx_t_11.k = __pyx_v_k;
  __pyx_t_10 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD3 *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0, &__pyx_t_11); 
  __pyx_v_n_types = (__pyx_t_10 + 1);

  /* "lurrn/sparsmat.pyx":5067
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_n_types); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_9 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_6) {
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_12 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
    }
    __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_12 = 0;
  __pyx_v_result = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5068
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":5069
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5070
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             result[new_val]+=1
 *         return result
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":5071
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1             # <<<<<<<<<<<<<<
 *         return result
 *     cpdef VecD3 remap(self, int k, numpy.ndarray filt):
 */
    __pyx_t_16 = __pyx_v_new_val;
    __pyx_t_17 = -1;
    if (__pyx_t_16 < 0) {
      __pyx_t_16 += __pyx_pybuffernd_result.diminfo[0].shape;
      if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 0;
    } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_17 = 0;
    if (unlikely(__pyx_t_17 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_17);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_result.diminfo[0].strides) += 1;
  }

  /* "lurrn/sparsmat.pyx":5072
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 *         return result             # <<<<<<<<<<<<<<
 *     cpdef VecD3 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyArrayObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5059
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_23get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_23get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5059; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5059; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5059; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD3_22get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_22get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecD3_get_type_counts __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_5lurrn_8sparsmat_VecD3->get_type_counts(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5073
 *             result[new_val]+=1
 *         return result
 *     cpdef VecD3 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_25remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_f_5lurrn_8sparsmat_5VecD3_remap(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_wanted = 0;
  PyArrayObject *__pyx_v_target = 0;
  int __pyx_v_n;
  int __pyx_v_i;
  struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_result = 0;
  struct CountItem<3,double> __pyx_v_c;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_target;
  __Pyx_Buffer __pyx_pybuffer_target;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_wanted;
  __Pyx_Buffer __pyx_pybuffer_wanted;
  struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __pyx_pybuffer_wanted.pybuffer.buf = NULL;
  __pyx_pybuffer_wanted.refcount = 0;
  __pyx_pybuffernd_wanted.data = NULL;
  __pyx_pybuffernd_wanted.rcbuffer = &__pyx_pybuffer_wanted;
  __pyx_pybuffer_target.pybuffer.buf = NULL;
  __pyx_pybuffer_target.refcount = 0;
  __pyx_pybuffernd_target.data = NULL;
  __pyx_pybuffernd_target.rcbuffer = &__pyx_pybuffer_target;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_remap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD3_25remap)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_filt));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_filt));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_filt));
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_VecD3))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5074
 *         return result
 *     cpdef VecD3 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__66, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_wanted = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_wanted.diminfo[0].strides = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_wanted.diminfo[0].shape = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_8 = 0;
  __pyx_v_wanted = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":5075
 *     cpdef VecD3 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_cumsum); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Subtract(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_target = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_target.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_target.diminfo[0].strides = __pyx_pybuffernd_target.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_target.diminfo[0].shape = __pyx_pybuffernd_target.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_9 = 0;
  __pyx_v_target = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5076
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         cdef int n=self.vec.size()
 *         cdef int i
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":5077
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()             # <<<<<<<<<<<<<<
 *         cdef int i
 *         cdef VecD3 result=VecD3()
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":5079
 *         cdef int n=self.vec.size()
 *         cdef int i
 *         cdef VecD3 result=VecD3()             # <<<<<<<<<<<<<<
 *         cdef c_CItemD3 c
 *         for i from 0<=i<n:
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5081
 *         cdef VecD3 result=VecD3()
 *         cdef c_CItemD3 c
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5082
 *         cdef c_CItemD3 c
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)             # <<<<<<<<<<<<<<
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 */
    __pyx_v_c = __pyx_v_self->vec.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":5083
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:             # <<<<<<<<<<<<<<
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 */
    __pyx_t_11 = (__pyx_v_c.addr[__pyx_v_k]);
    __pyx_t_12 = -1;
    if (__pyx_t_11 < 0) {
      __pyx_t_11 += __pyx_pybuffernd_wanted.diminfo[0].shape;
      if (unlikely(__pyx_t_11 < 0)) __pyx_t_12 = 0;
    } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_wanted.diminfo[0].shape)) __pyx_t_12 = 0;
    if (unlikely(__pyx_t_12 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_12);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_wanted.diminfo[0].strides)) != 0);
    if (__pyx_t_13) {

      /* "lurrn/sparsmat.pyx":5084
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c)
 *         return result
 */
      __pyx_t_12 = (__pyx_v_c.addr[__pyx_v_k]);
      __pyx_t_14 = -1;
      if (__pyx_t_12 < 0) {
        __pyx_t_12 += __pyx_pybuffernd_target.diminfo[0].shape;
        if (unlikely(__pyx_t_12 < 0)) __pyx_t_14 = 0;
      } else if (unlikely(__pyx_t_12 >= __pyx_pybuffernd_target.diminfo[0].shape)) __pyx_t_14 = 0;
      if (unlikely(__pyx_t_14 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_14);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      (__pyx_v_c.addr[__pyx_v_k]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_target.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_target.diminfo[0].strides));

      /* "lurrn/sparsmat.pyx":5085
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         return result
 *     def append(self,tup):
 */
      __pyx_v_result->vec.push_back(__pyx_v_c);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "lurrn/sparsmat.pyx":5086
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 *         return result             # <<<<<<<<<<<<<<
 *     def append(self,tup):
 *         k0,k1,k2,val=tup
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5073
 *             result[new_val]+=1
 *         return result
 *     cpdef VecD3 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_wanted);
  __Pyx_XDECREF((PyObject *)__pyx_v_target);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_25remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_25remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5073; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5073; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5073; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_filt = ((PyArrayObject *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5073; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_filt), __pyx_ptype_5numpy_ndarray, 1, "filt", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD3_24remap(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_24remap(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_5VecD3_remap(__pyx_v_self, __pyx_v_k, __pyx_v_filt, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5087
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,k1,k2,val=tup
 *         self.c_add(k0,k1,k2,val)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_27append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_27append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("append (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD3_26append(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self), ((PyObject *)__pyx_v_tup));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_26append(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_k1 = NULL;
  PyObject *__pyx_v_k2 = NULL;
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  coordinate_t __pyx_t_7;
  coordinate_t __pyx_t_8;
  coordinate_t __pyx_t_9;
  double __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("append", 0);

  /* "lurrn/sparsmat.pyx":5088
 *         return result
 *     def append(self,tup):
 *         k0,k1,k2,val=tup             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1,k2,val)
 *     def extend(self,tups):
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_tup))) || (PyList_CheckExact(__pyx_v_tup))) {
    PyObject* sequence = __pyx_v_tup;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_2,&__pyx_t_3,&__pyx_t_4};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_2,&__pyx_t_3,&__pyx_t_4};
    __pyx_t_5 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_6(__pyx_t_5); if (unlikely(!item)) goto __pyx_L3_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_k0 = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_k1 = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_k2 = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_val = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "lurrn/sparsmat.pyx":5089
 *     def append(self,tup):
 *         k0,k1,k2,val=tup
 *         self.c_add(k0,k1,k2,val)             # <<<<<<<<<<<<<<
 *     def extend(self,tups):
 *         for k0,k1,k2,val in tups:
 */
  __pyx_t_7 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_7 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k1); if (unlikely((__pyx_t_8 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k2); if (unlikely((__pyx_t_9 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_v_val); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD3 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10);

  /* "lurrn/sparsmat.pyx":5087
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,k1,k2,val=tup
 *         self.c_add(k0,k1,k2,val)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_k1);
  __Pyx_XDECREF(__pyx_v_k2);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5090
 *         k0,k1,k2,val=tup
 *         self.c_add(k0,k1,k2,val)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,k1,k2,val in tups:
 *             self.c_add(k0,k1,k2,val)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_29extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_29extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extend (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD3_28extend(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self), ((PyObject *)__pyx_v_tups));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_28extend(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_k1 = NULL;
  PyObject *__pyx_v_k2 = NULL;
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  coordinate_t __pyx_t_11;
  coordinate_t __pyx_t_12;
  coordinate_t __pyx_t_13;
  double __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("extend", 0);

  /* "lurrn/sparsmat.pyx":5091
 *         self.c_add(k0,k1,k2,val)
 *     def extend(self,tups):
 *         for k0,k1,k2,val in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,k1,k2,val)
 *     def __iter__(self):
 */
  if (likely(PyList_CheckExact(__pyx_v_tups)) || PyTuple_CheckExact(__pyx_v_tups)) {
    __pyx_t_1 = __pyx_v_tups; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_tups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 4)) {
        if (size > 4) __Pyx_RaiseTooManyValuesError(4);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); 
        __pyx_t_8 = PyTuple_GET_ITEM(sequence, 3); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 2); 
        __pyx_t_8 = PyList_GET_ITEM(sequence, 3); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_8);
      #else
      {
        Py_ssize_t i;
        PyObject** temps[4] = {&__pyx_t_5,&__pyx_t_6,&__pyx_t_7,&__pyx_t_8};
        for (i=0; i < 4; i++) {
          PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(item);
          *(temps[i]) = item;
        }
      }
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      PyObject** temps[4] = {&__pyx_t_5,&__pyx_t_6,&__pyx_t_7,&__pyx_t_8};
      __pyx_t_9 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
      for (index=0; index < 4; index++) {
        PyObject* item = __pyx_t_10(__pyx_t_9); if (unlikely(!item)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(item);
        *(temps[index]) = item;
      }
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_10 = NULL;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_10 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_k0, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_k1, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_k2, __pyx_t_7);
    __pyx_t_7 = 0;
    __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "lurrn/sparsmat.pyx":5092
 *     def extend(self,tups):
 *         for k0,k1,k2,val in tups:
 *             self.c_add(k0,k1,k2,val)             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self.item_iter()
 */
    __pyx_t_11 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_11 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_12 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k1); if (unlikely((__pyx_t_12 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_13 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k2); if (unlikely((__pyx_t_13 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_14 = __pyx_PyFloat_AsDouble(__pyx_v_val); if (unlikely((__pyx_t_14 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD3 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_11, __pyx_t_12, __pyx_t_13, __pyx_t_14);

    /* "lurrn/sparsmat.pyx":5091
 *         self.c_add(k0,k1,k2,val)
 *     def extend(self,tups):
 *         for k0,k1,k2,val in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,k1,k2,val)
 *     def __iter__(self):
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5090
 *         k0,k1,k2,val=tup
 *         self.c_add(k0,k1,k2,val)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,k1,k2,val in tups:
 *             self.c_add(k0,k1,k2,val)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.extend", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_k1);
  __Pyx_XDECREF(__pyx_v_k2);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5093
 *         for k0,k1,k2,val in tups:
 *             self.c_add(k0,k1,k2,val)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_31__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_31__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD3_30__iter__(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_30__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":5094
 *             self.c_add(k0,k1,k2,val)
 *     def __iter__(self):
 *         return self.item_iter()             # <<<<<<<<<<<<<<
 *     def __reduce__(self):
 *         return (VecD3,(),(),self.item_iter())
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5093
 *         for k0,k1,k2,val in tups:
 *             self.c_add(k0,k1,k2,val)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5095
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecD3,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_33__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_33__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD3_32__reduce__(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_32__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "lurrn/sparsmat.pyx":5096
 *         return self.item_iter()
 *     def __reduce__(self):
 *         return (VecD3,(),(),self.item_iter())             # <<<<<<<<<<<<<<
 *     def __setstate__(self,state):
 *         pass
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD3)));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD3)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD3)));
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5095
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecD3,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5097
 *     def __reduce__(self):
 *         return (VecD3,(),(),self.item_iter())
 *     def __setstate__(self,state):             # <<<<<<<<<<<<<<
 *         pass
 *     def __repr__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_35__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_35__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD3_34__setstate__(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self), ((PyObject *)__pyx_v_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_34__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5099
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecD3(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_37__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecD3_37__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecD3_36__repr__(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecD3_36__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "lurrn/sparsmat.pyx":5100
 *         pass
 *     def __repr__(self):
 *         return 'VecD3(%s)'%(str(list(self)),)             # <<<<<<<<<<<<<<
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_VecD3_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5099
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecD3(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecD3.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5101
 *     def __repr__(self):
 *         return 'VecD3(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

/* Python wrapper */
static void __pyx_pw_5lurrn_8sparsmat_5VecD3_39__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5lurrn_8sparsmat_5VecD3_39__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5lurrn_8sparsmat_5VecD3_38__dealloc__(((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5lurrn_8sparsmat_5VecD3_38__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lurrn/sparsmat.pyx":5103
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()             # <<<<<<<<<<<<<<
 * 
 * cdef class IVecD3_iter:
 */
  __pyx_v_self->vec.~vector();

  /* "lurrn/sparsmat.pyx":5101
 *     def __repr__(self):
 *         return 'VecD3(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":5109
 *     cdef c_VecD3 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_11IVecD3_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_11IVecD3_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_vec = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_vec,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5109; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_vec = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5109; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.IVecD3_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecD3_iter___init__(((struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter *)__pyx_v_self), __pyx_v_vec);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_11IVecD3_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter *__pyx_v_self, PyObject *__pyx_v_vec) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":5110
 *     cdef unsigned int k
 *     def __init__(self,vec):
 *         self.vec=vec             # <<<<<<<<<<<<<<
 *         self.vecC=&self.vec.vec
 *         self.k=0
 */
  if (!(likely(((__pyx_v_vec) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_vec, __pyx_ptype_5lurrn_8sparsmat_VecD3))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_vec;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->vec);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->vec));
  __pyx_v_self->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5111
 *     def __init__(self,vec):
 *         self.vec=vec
 *         self.vecC=&self.vec.vec             # <<<<<<<<<<<<<<
 *         self.k=0
 *     def __iter__(self):
 */
  __pyx_v_self->vecC = (&__pyx_v_self->vec->vec);

  /* "lurrn/sparsmat.pyx":5112
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 *         self.k=0             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self
 */
  __pyx_v_self->k = 0;

  /* "lurrn/sparsmat.pyx":5109
 *     cdef c_VecD3 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecD3_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5113
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecD3_iter_3__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecD3_iter_3__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecD3_iter_2__iter__(((struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecD3_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":5114
 *         self.k=0
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5113
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5115
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecD3_iter_5__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecD3_iter_5__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecD3_iter_4__next__(((struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecD3_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter *__pyx_v_self) {
  struct CountItem<3,double> __pyx_v_res;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "lurrn/sparsmat.pyx":5116
 *         return self
 *     def __next__(self):
 *         if self.k>=self.vecC.size():             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         cdef c_CItemD3 res=self.vecC.at(self.k)
 */
  __pyx_t_1 = ((__pyx_v_self->k >= __pyx_v_self->vecC->size()) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":5117
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         cdef c_CItemD3 res=self.vecC.at(self.k)
 *         self.k+=1
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lurrn/sparsmat.pyx":5118
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 *         cdef c_CItemD3 res=self.vecC.at(self.k)             # <<<<<<<<<<<<<<
 *         self.k+=1
 *         return (res.addr[0],
 */
  __pyx_v_res = __pyx_v_self->vecC->at(__pyx_v_self->k);

  /* "lurrn/sparsmat.pyx":5119
 *             raise StopIteration
 *         cdef c_CItemD3 res=self.vecC.at(self.k)
 *         self.k+=1             # <<<<<<<<<<<<<<
 *         return (res.addr[0],
 *                 res.addr[1],
 */
  __pyx_v_self->k = (__pyx_v_self->k + 1);

  /* "lurrn/sparsmat.pyx":5120
 *         cdef c_CItemD3 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.addr[1],
 *                 res.addr[2],
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_res.addr[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "lurrn/sparsmat.pyx":5121
 *         self.k+=1
 *         return (res.addr[0],
 *                 res.addr[1],             # <<<<<<<<<<<<<<
 *                 res.addr[2],
 *                 res.item)
 */
  __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_res.addr[1])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "lurrn/sparsmat.pyx":5122
 *         return (res.addr[0],
 *                 res.addr[1],
 *                 res.addr[2],             # <<<<<<<<<<<<<<
 *                 res.item)
 * 
 */
  __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_res.addr[2])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":5123
 *                 res.addr[1],
 *                 res.addr[2],
 *                 res.item)             # <<<<<<<<<<<<<<
 * 
 * cdef class LargeVecD3:
 */
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_res.item); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "lurrn/sparsmat.pyx":5120
 *         cdef c_CItemD3 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.addr[1],
 *                 res.addr[2],
 */
  __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5115
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecD3_iter.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5128
 *     cdef public object compact
 *     cdef public VecD3 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecD3()
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD3_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD3_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD3___init__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD3___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":5129
 *     cdef public VecD3 loose
 *     def __init__(self):
 *         self.compact=[]             # <<<<<<<<<<<<<<
 *         self.loose=VecD3()
 *         self.loose.vec.reserve(100000)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5130
 *     def __init__(self):
 *         self.compact=[]
 *         self.loose=VecD3()             # <<<<<<<<<<<<<<
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5131
 *         self.compact=[]
 *         self.loose=VecD3()
 *         self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 */
  __pyx_v_self->loose->vec.reserve(100000);

  /* "lurrn/sparsmat.pyx":5128
 *     cdef public object compact
 *     cdef public VecD3 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecD3()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD3.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5132
 *         self.loose=VecD3()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ensure_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_2ensure_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD3_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":5133
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *         self.loose=VecD3()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":5134
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *         self.loose=VecD3()
 *         while len(self.compact)>=2:
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":5135
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 *         self.loose=VecD3()             # <<<<<<<<<<<<<<
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":5136
 *             self.compact.append(self.loose)
 *         self.loose=VecD3()
 *         while len(self.compact)>=2:             # <<<<<<<<<<<<<<
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 */
  while (1) {
    __pyx_t_2 = __pyx_v_self->compact;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = ((__pyx_t_6 >= 2) != 0);
    if (!__pyx_t_4) break;

    /* "lurrn/sparsmat.pyx":5137
 *         self.loose=VecD3()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.loose.c_add(k0,k1,k2, item)
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5137; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5137; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_1, -2, 0, NULL, NULL, &__pyx_slice__67, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5132
 *         self.loose=VecD3()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD3.ensure_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5138
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0,k1,k2, item)
 *         if self.loose.get_size(False)>=100000:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  PyObject *__pyx_v_item = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,&__pyx_n_s_k2,&__pyx_n_s_item,0};
    PyObject* values[4] = {0,0,0,0};
    values[3] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 0, 3, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5138; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 0, 3, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5138; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_item);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5138; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5138; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5138; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k2 = __Pyx_PyInt_As_coordinate_t(values[2]); if (unlikely((__pyx_v_k2 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5138; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_item = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5138; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD3.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_4add_count(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1, __pyx_v_k2, __pyx_v_item);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD3_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":5139
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.loose.c_add(k0,k1,k2, item)             # <<<<<<<<<<<<<<
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 */
  __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_item); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD3 *)__pyx_v_self->loose->__pyx_vtab)->c_add(__pyx_v_self->loose, __pyx_v_k0, __pyx_v_k1, __pyx_v_k2, __pyx_t_1);

  /* "lurrn/sparsmat.pyx":5140
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.loose.c_add(k0,k1,k2, item)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__68, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_int_100000, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":5141
 *         self.loose.c_add(k0,k1,k2, item)
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *             self.loose=VecD3()
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD3 *)__pyx_v_self->loose->__pyx_vtab)->ensure_compact(__pyx_v_self->loose);

    /* "lurrn/sparsmat.pyx":5142
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *             self.loose=VecD3()
 *             self.loose.vec.reserve(100000)
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lurrn/sparsmat.pyx":5143
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 *             self.loose=VecD3()             # <<<<<<<<<<<<<<
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 */
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->loose);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
    __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":5144
 *             self.compact.append(self.loose)
 *             self.loose=VecD3()
 *             self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 */
    __pyx_v_self->loose->vec.reserve(100000);

    /* "lurrn/sparsmat.pyx":5145
 *             self.loose=VecD3()
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and             # <<<<<<<<<<<<<<
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
    while (1) {
      __pyx_t_2 = __pyx_v_self->compact;
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_7 = ((__pyx_t_6 >= 2) != 0);
      if (__pyx_t_7) {
      } else {
        __pyx_t_4 = __pyx_t_7;
        goto __pyx_L6_bool_binop_done;
      }

      /* "lurrn/sparsmat.pyx":5146
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):             # <<<<<<<<<<<<<<
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 */
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5146; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5146; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyNumber_Multiply(__pyx_float_0_6, __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_2, __pyx_t_9, Py_GE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_4 = __pyx_t_7;
      __pyx_L6_bool_binop_done:;
      if (!__pyx_t_4) break;

      /* "lurrn/sparsmat.pyx":5147
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5147; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5147; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = PyNumber_Add(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyList_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_9, -2, 0, NULL, NULL, &__pyx_slice__69, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":5138
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0,k1,k2, item)
 *         if self.loose.get_size(False)>=100000:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD3.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5148
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_6get_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD3_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_compact", 0);

  /* "lurrn/sparsmat.pyx":5149
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         if len(self.compact)>0:
 *             return self.compact[0]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5150
 *     def get_compact(self):
 *         self.ensure_compact()
 *         if len(self.compact)>0:             # <<<<<<<<<<<<<<
 *             return self.compact[0]
 *         else:
 */
  __pyx_t_1 = __pyx_v_self->compact;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((__pyx_t_4 > 0) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":5151
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 *             return self.compact[0]             # <<<<<<<<<<<<<<
 *         else:
 *             return VecD3()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5151; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":5153
 *             return self.compact[0]
 *         else:
 *             return VecD3()             # <<<<<<<<<<<<<<
 *     def get_size(self, compactify=True):
 *         cdef int n
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":5148
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD3.get_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5154
 *         else:
 *             return VecD3()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5154; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5154; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD3.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_8get_size(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD3_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  int __pyx_v_n;
  PyObject *__pyx_v_c = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":5156
 *     def get_size(self, compactify=True):
 *         cdef int n
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *             if self.compact:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":5157
 *         cdef int n
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *             if self.compact:
 *                 return self.compact[0].get_size()
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":5158
 *         if compactify:
 *             self.ensure_compact()
 *             if self.compact:             # <<<<<<<<<<<<<<
 *                 return self.compact[0].get_size()
 *             else:
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->compact); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":5159
 *             self.ensure_compact()
 *             if self.compact:
 *                 return self.compact[0].get_size()             # <<<<<<<<<<<<<<
 *             else:
 *                 return 0
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5159; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":5161
 *                 return self.compact[0].get_size()
 *             else:
 *                 return 0             # <<<<<<<<<<<<<<
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_int_0);
      __pyx_r = __pyx_int_0;
      goto __pyx_L0;
    }
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":5163
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_v_self->compact)) || PyTuple_CheckExact(__pyx_v_self->compact)) {
      __pyx_t_4 = __pyx_v_self->compact; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_self->compact); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_get_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__70, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":5164
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__71, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":5165
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)
 *             return n             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         self.ensure_compact()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":5154
 *         else:
 *             return VecD3()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD3.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_c);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5166
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_11__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_11__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_10__iter__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD3_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":5167
 *             return n
 *     def __iter__(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         try:
 *             return iter(self.compact[0])
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5168
 *     def __iter__(self):
 *         self.ensure_compact()
 *         try:             # <<<<<<<<<<<<<<
 *             return iter(self.compact[0])
 *         except IndexError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "lurrn/sparsmat.pyx":5169
 *         self.ensure_compact()
 *         try:
 *             return iter(self.compact[0])             # <<<<<<<<<<<<<<
 *         except IndexError:
 *             return iter([])
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5169; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L7_try_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":5170
 *         try:
 *             return iter(self.compact[0])
 *         except IndexError:             # <<<<<<<<<<<<<<
 *             return iter([])
 * 
 */
    __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_IndexError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD3.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5170; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_3);

      /* "lurrn/sparsmat.pyx":5171
 *             return iter(self.compact[0])
 *         except IndexError:
 *             return iter([])             # <<<<<<<<<<<<<<
 * 
 *     def get_type_counts(self, k=0):
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5171; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5171; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_r = __pyx_t_9;
      __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":5166
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD3.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5173
 *             return iter([])
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_13get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_13get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5173; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5173; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_12get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD3_12get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);

  /* "lurrn/sparsmat.pyx":5174
 * 
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)             # <<<<<<<<<<<<<<
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_k);
    __Pyx_GIVEREF(__pyx_v_k);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5173
 *             return iter([])
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5175
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_15remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_15remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  PyObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5175; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5175; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = values[0];
    __pyx_v_filt = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5175; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_14remap(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD3_14remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);

  /* "lurrn/sparsmat.pyx":5176
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)             # <<<<<<<<<<<<<<
 * 
 * cdef class SparseVectorD:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_remap); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_v_k);
  PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_k);
  __Pyx_GIVEREF(__pyx_v_k);
  __Pyx_INCREF(__pyx_v_filt);
  PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_filt);
  __Pyx_GIVEREF(__pyx_v_filt);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5175
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5126
 * 
 * cdef class LargeVecD3:
 *     cdef public object compact             # <<<<<<<<<<<<<<
 *     cdef public VecD3 loose
 *     def __init__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_7compact_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_7compact_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_7compact___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD3_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->compact);
  __pyx_r = __pyx_v_self->compact;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD3_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD3_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_7compact_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD3_7compact_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD3_7compact_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_7compact_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5127
 * cdef class LargeVecD3:
 *     cdef public object compact
 *     cdef public VecD3 loose             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *         self.compact=[]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_5loose_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_5loose_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_5loose___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecD3_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->loose));
  __pyx_r = ((PyObject *)__pyx_v_self->loose);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD3_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD3_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_5loose_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5lurrn_8sparsmat_VecD3))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecD3.loose.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD3_5loose_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecD3_5loose_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_5loose_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecD3_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5179
 * 
 * cdef class SparseVectorD:
 *     def __init__(self, pairs=None):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         if pairs is not None:
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pairs = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pairs,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pairs);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5179; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_pairs = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5179; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD___init__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), __pyx_v_pairs);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_13SparseVectorD___init__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, PyObject *__pyx_v_pairs) {
  coordinate_t __pyx_v_i;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_y = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  unsigned int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  coordinate_t __pyx_t_10;
  double __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":5181
 *     def __init__(self, pairs=None):
 *         cdef coordinate_t i
 *         if pairs is not None:             # <<<<<<<<<<<<<<
 *             self.my_len=len(pairs)
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 */
  __pyx_t_1 = (__pyx_v_pairs != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lurrn/sparsmat.pyx":5182
 *         cdef coordinate_t i
 *         if pairs is not None:
 *             self.my_len=len(pairs)             # <<<<<<<<<<<<<<
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *             self.vals_ptr=<double *>PyMem_Malloc(self.my_len*sizeof(double))
 */
    __pyx_t_3 = PyObject_Length(__pyx_v_pairs); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_self->my_len = __pyx_t_3;

    /* "lurrn/sparsmat.pyx":5183
 *         if pairs is not None:
 *             self.my_len=len(pairs)
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *             self.vals_ptr=<double *>PyMem_Malloc(self.my_len*sizeof(double))
 *             for i from 0<=i<self.my_len:
 */
    __pyx_v_self->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_self->my_len * (sizeof(coordinate_t)))));

    /* "lurrn/sparsmat.pyx":5184
 *             self.my_len=len(pairs)
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *             self.vals_ptr=<double *>PyMem_Malloc(self.my_len*sizeof(double))             # <<<<<<<<<<<<<<
 *             for i from 0<=i<self.my_len:
 *                 x,y=pairs[i]
 */
    __pyx_v_self->vals_ptr = ((double *)PyMem_Malloc((__pyx_v_self->my_len * (sizeof(double)))));

    /* "lurrn/sparsmat.pyx":5185
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *             self.vals_ptr=<double *>PyMem_Malloc(self.my_len*sizeof(double))
 *             for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *                 x,y=pairs[i]
 *                 self.idx_ptr[i]=x
 */
    __pyx_t_4 = __pyx_v_self->my_len;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":5186
 *             self.vals_ptr=<double *>PyMem_Malloc(self.my_len*sizeof(double))
 *             for i from 0<=i<self.my_len:
 *                 x,y=pairs[i]             # <<<<<<<<<<<<<<
 *                 self.idx_ptr[i]=x
 *                 self.vals_ptr[i]=y
 */
      __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_pairs, __pyx_v_i, coordinate_t, 0, __Pyx_PyInt_From_coordinate_t, 0, 0, 1); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5186; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_5);
      if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
        PyObject* sequence = __pyx_t_5;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        #else
        __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        #endif
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_8 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
        index = 0; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L7_unpacking_done;
        __pyx_L6_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L7_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_6);
      __pyx_t_6 = 0;
      __Pyx_XDECREF_SET(__pyx_v_y, __pyx_t_7);
      __pyx_t_7 = 0;

      /* "lurrn/sparsmat.pyx":5187
 *             for i from 0<=i<self.my_len:
 *                 x,y=pairs[i]
 *                 self.idx_ptr[i]=x             # <<<<<<<<<<<<<<
 *                 self.vals_ptr[i]=y
 *         else:
 */
      __pyx_t_10 = __Pyx_PyInt_As_coordinate_t(__pyx_v_x); if (unlikely((__pyx_t_10 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      (__pyx_v_self->idx_ptr[__pyx_v_i]) = __pyx_t_10;

      /* "lurrn/sparsmat.pyx":5188
 *                 x,y=pairs[i]
 *                 self.idx_ptr[i]=x
 *                 self.vals_ptr[i]=y             # <<<<<<<<<<<<<<
 *         else:
 *             self.my_len=0
 */
      __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_v_y); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      (__pyx_v_self->vals_ptr[__pyx_v_i]) = __pyx_t_11;
    }
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":5190
 *                 self.vals_ptr[i]=y
 *         else:
 *             self.my_len=0             # <<<<<<<<<<<<<<
 *             self.idx_ptr=NULL
 *             self.vals_ptr=NULL
 */
    __pyx_v_self->my_len = 0;

    /* "lurrn/sparsmat.pyx":5191
 *         else:
 *             self.my_len=0
 *             self.idx_ptr=NULL             # <<<<<<<<<<<<<<
 *             self.vals_ptr=NULL
 *     cpdef int from_dense(self, double[:] dense):
 */
    __pyx_v_self->idx_ptr = NULL;

    /* "lurrn/sparsmat.pyx":5192
 *             self.my_len=0
 *             self.idx_ptr=NULL
 *             self.vals_ptr=NULL             # <<<<<<<<<<<<<<
 *     cpdef int from_dense(self, double[:] dense):
 *         cdef int i, k
 */
    __pyx_v_self->vals_ptr = NULL;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":5179
 * 
 * cdef class SparseVectorD:
 *     def __init__(self, pairs=None):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         if pairs is not None:
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5193
 *             self.idx_ptr=NULL
 *             self.vals_ptr=NULL
 *     cpdef int from_dense(self, double[:] dense):             # <<<<<<<<<<<<<<
 *         cdef int i, k
 *         assert self.my_len == 0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_3from_dense(PyObject *__pyx_v_self, PyObject *__pyx_arg_dense); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_13SparseVectorD_from_dense(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, __Pyx_memviewslice __pyx_v_dense, int __pyx_skip_dispatch) {
  int __pyx_v_i;
  int __pyx_v_k;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_dense", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_from_dense); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_3from_dense)) {
      if (unlikely(!__pyx_v_dense.memview)) { __Pyx_RaiseUnboundLocalError("dense"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
      __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dense, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5195
 *     cpdef int from_dense(self, double[:] dense):
 *         cdef int i, k
 *         assert self.my_len == 0             # <<<<<<<<<<<<<<
 *         k = 0
 *         for i from 0<=i<dense.shape[0]:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_self->my_len == 0) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":5196
 *         cdef int i, k
 *         assert self.my_len == 0
 *         k = 0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<dense.shape[0]:
 *             if dense[i]!=0.0:
 */
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":5197
 *         assert self.my_len == 0
 *         k = 0
 *         for i from 0<=i<dense.shape[0]:             # <<<<<<<<<<<<<<
 *             if dense[i]!=0.0:
 *                 k += 1
 */
  __pyx_t_8 = (__pyx_v_dense.shape[0]);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5198
 *         k = 0
 *         for i from 0<=i<dense.shape[0]:
 *             if dense[i]!=0.0:             # <<<<<<<<<<<<<<
 *                 k += 1
 *         self.my_len = k
 */
    __pyx_t_7 = __pyx_v_i;
    __pyx_t_9 = -1;
    if (__pyx_t_7 < 0) {
      __pyx_t_7 += __pyx_v_dense.shape[0];
      if (unlikely(__pyx_t_7 < 0)) __pyx_t_9 = 0;
    } else if (unlikely(__pyx_t_7 >= __pyx_v_dense.shape[0])) __pyx_t_9 = 0;
    if (unlikely(__pyx_t_9 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_9);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_10 = (((*((double *) ( /* dim=0 */ (__pyx_v_dense.data + __pyx_t_7 * __pyx_v_dense.strides[0]) ))) != 0.0) != 0);
    if (__pyx_t_10) {

      /* "lurrn/sparsmat.pyx":5199
 *         for i from 0<=i<dense.shape[0]:
 *             if dense[i]!=0.0:
 *                 k += 1             # <<<<<<<<<<<<<<
 *         self.my_len = k
 *         self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 */
      __pyx_v_k = (__pyx_v_k + 1);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "lurrn/sparsmat.pyx":5200
 *             if dense[i]!=0.0:
 *                 k += 1
 *         self.my_len = k             # <<<<<<<<<<<<<<
 *         self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *         self.vals_ptr=<double *>PyMem_Malloc(self.my_len*sizeof(double))
 */
  __pyx_v_self->my_len = __pyx_v_k;

  /* "lurrn/sparsmat.pyx":5201
 *                 k += 1
 *         self.my_len = k
 *         self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         self.vals_ptr=<double *>PyMem_Malloc(self.my_len*sizeof(double))
 *         k = 0
 */
  __pyx_v_self->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_self->my_len * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":5202
 *         self.my_len = k
 *         self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *         self.vals_ptr=<double *>PyMem_Malloc(self.my_len*sizeof(double))             # <<<<<<<<<<<<<<
 *         k = 0
 *         for i from 0<=i<dense.shape[0]:
 */
  __pyx_v_self->vals_ptr = ((double *)PyMem_Malloc((__pyx_v_self->my_len * (sizeof(double)))));

  /* "lurrn/sparsmat.pyx":5203
 *         self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *         self.vals_ptr=<double *>PyMem_Malloc(self.my_len*sizeof(double))
 *         k = 0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<dense.shape[0]:
 *             if dense[i] != 0.0:
 */
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":5204
 *         self.vals_ptr=<double *>PyMem_Malloc(self.my_len*sizeof(double))
 *         k = 0
 *         for i from 0<=i<dense.shape[0]:             # <<<<<<<<<<<<<<
 *             if dense[i] != 0.0:
 *                 self.idx_ptr[k] = i
 */
  __pyx_t_8 = (__pyx_v_dense.shape[0]);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5205
 *         k = 0
 *         for i from 0<=i<dense.shape[0]:
 *             if dense[i] != 0.0:             # <<<<<<<<<<<<<<
 *                 self.idx_ptr[k] = i
 *                 self.vals_ptr[k] = dense[i]
 */
    __pyx_t_9 = __pyx_v_i;
    __pyx_t_11 = -1;
    if (__pyx_t_9 < 0) {
      __pyx_t_9 += __pyx_v_dense.shape[0];
      if (unlikely(__pyx_t_9 < 0)) __pyx_t_11 = 0;
    } else if (unlikely(__pyx_t_9 >= __pyx_v_dense.shape[0])) __pyx_t_11 = 0;
    if (unlikely(__pyx_t_11 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_11);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_10 = (((*((double *) ( /* dim=0 */ (__pyx_v_dense.data + __pyx_t_9 * __pyx_v_dense.strides[0]) ))) != 0.0) != 0);
    if (__pyx_t_10) {

      /* "lurrn/sparsmat.pyx":5206
 *         for i from 0<=i<dense.shape[0]:
 *             if dense[i] != 0.0:
 *                 self.idx_ptr[k] = i             # <<<<<<<<<<<<<<
 *                 self.vals_ptr[k] = dense[i]
 *                 k += 1
 */
      (__pyx_v_self->idx_ptr[__pyx_v_k]) = __pyx_v_i;

      /* "lurrn/sparsmat.pyx":5207
 *             if dense[i] != 0.0:
 *                 self.idx_ptr[k] = i
 *                 self.vals_ptr[k] = dense[i]             # <<<<<<<<<<<<<<
 *                 k += 1
 *         return k
 */
      __pyx_t_11 = __pyx_v_i;
      __pyx_t_12 = -1;
      if (__pyx_t_11 < 0) {
        __pyx_t_11 += __pyx_v_dense.shape[0];
        if (unlikely(__pyx_t_11 < 0)) __pyx_t_12 = 0;
      } else if (unlikely(__pyx_t_11 >= __pyx_v_dense.shape[0])) __pyx_t_12 = 0;
      if (unlikely(__pyx_t_12 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_12);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      (__pyx_v_self->vals_ptr[__pyx_v_k]) = (*((double *) ( /* dim=0 */ (__pyx_v_dense.data + __pyx_t_11 * __pyx_v_dense.strides[0]) )));

      /* "lurrn/sparsmat.pyx":5208
 *                 self.idx_ptr[k] = i
 *                 self.vals_ptr[k] = dense[i]
 *                 k += 1             # <<<<<<<<<<<<<<
 *         return k
 *     cpdef double dotSelf(self):
 */
      __pyx_v_k = (__pyx_v_k + 1);
      goto __pyx_L8;
    }
    __pyx_L8:;
  }

  /* "lurrn/sparsmat.pyx":5209
 *                 self.vals_ptr[k] = dense[i]
 *                 k += 1
 *         return k             # <<<<<<<<<<<<<<
 *     cpdef double dotSelf(self):
 *         cdef double s=0
 */
  __pyx_r = __pyx_v_k;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5193
 *             self.idx_ptr=NULL
 *             self.vals_ptr=NULL
 *     cpdef int from_dense(self, double[:] dense):             # <<<<<<<<<<<<<<
 *         cdef int i, k
 *         assert self.my_len == 0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorD.from_dense", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_3from_dense(PyObject *__pyx_v_self, PyObject *__pyx_arg_dense); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_3from_dense(PyObject *__pyx_v_self, PyObject *__pyx_arg_dense) {
  __Pyx_memviewslice __pyx_v_dense = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_dense (wrapper)", 0);
  assert(__pyx_arg_dense); {
    __pyx_v_dense = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_arg_dense); if (unlikely(!__pyx_v_dense.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5193; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.from_dense", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_2from_dense(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), __pyx_v_dense);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_2from_dense(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, __Pyx_memviewslice __pyx_v_dense) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_dense", 0);
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_v_dense.memview)) { __Pyx_RaiseUnboundLocalError("dense"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_5lurrn_8sparsmat_13SparseVectorD_from_dense(__pyx_v_self, __pyx_v_dense, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.from_dense", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_dense, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5210
 *                 k += 1
 *         return k
 *     cpdef double dotSelf(self):             # <<<<<<<<<<<<<<
 *         cdef double s=0
 *         cdef coordinate_t i
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_5dotSelf(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_dotSelf(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, int __pyx_skip_dispatch) {
  double __pyx_v_s;
  coordinate_t __pyx_v_i;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  double __pyx_t_5;
  unsigned int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotSelf", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dotSelf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_5dotSelf)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_5;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5211
 *         return k
 *     cpdef double dotSelf(self):
 *         cdef double s=0             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_s = 0.0;

  /* "lurrn/sparsmat.pyx":5213
 *         cdef double s=0
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             s+=self.vals_ptr[i]*self.vals_ptr[i]
 *         return s
 */
  __pyx_t_6 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5214
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 *             s+=self.vals_ptr[i]*self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *         return s
 *     cdef double _dotFull(self, const_double_ptr full_ptr):
 */
    __pyx_v_s = (__pyx_v_s + ((__pyx_v_self->vals_ptr[__pyx_v_i]) * (__pyx_v_self->vals_ptr[__pyx_v_i])));
  }

  /* "lurrn/sparsmat.pyx":5215
 *         for i from 0<=i<self.my_len:
 *             s+=self.vals_ptr[i]*self.vals_ptr[i]
 *         return s             # <<<<<<<<<<<<<<
 *     cdef double _dotFull(self, const_double_ptr full_ptr):
 *         cdef double s=0
 */
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5210
 *                 k += 1
 *         return k
 *     cpdef double dotSelf(self):             # <<<<<<<<<<<<<<
 *         cdef double s=0
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorD.dotSelf", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_5dotSelf(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_5dotSelf(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dotSelf (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_4dotSelf(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_4dotSelf(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotSelf", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorD_dotSelf(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.dotSelf", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5216
 *             s+=self.vals_ptr[i]*self.vals_ptr[i]
 *         return s
 *     cdef double _dotFull(self, const_double_ptr full_ptr):             # <<<<<<<<<<<<<<
 *         cdef double s=0
 *         cdef coordinate_t i
 */

static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD__dotFull(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, const double * __pyx_v_full_ptr) {
  double __pyx_v_s;
  coordinate_t __pyx_v_i;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  __Pyx_RefNannySetupContext("_dotFull", 0);

  /* "lurrn/sparsmat.pyx":5217
 *         return s
 *     cdef double _dotFull(self, const_double_ptr full_ptr):
 *         cdef double s=0             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_s = 0.0;

  /* "lurrn/sparsmat.pyx":5219
 *         cdef double s=0
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5220
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]             # <<<<<<<<<<<<<<
 *         return s
 *     cdef double _dotFull_partial(self, const_double_ptr full_ptr, int my_len):
 */
    __pyx_v_s = (__pyx_v_s + ((__pyx_v_self->vals_ptr[__pyx_v_i]) * (__pyx_v_full_ptr[(__pyx_v_self->idx_ptr[__pyx_v_i])])));
  }

  /* "lurrn/sparsmat.pyx":5221
 *         for i from 0<=i<self.my_len:
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s             # <<<<<<<<<<<<<<
 *     cdef double _dotFull_partial(self, const_double_ptr full_ptr, int my_len):
 *         cdef double s=0
 */
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5216
 *             s+=self.vals_ptr[i]*self.vals_ptr[i]
 *         return s
 *     cdef double _dotFull(self, const_double_ptr full_ptr):             # <<<<<<<<<<<<<<
 *         cdef double s=0
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5222
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s
 *     cdef double _dotFull_partial(self, const_double_ptr full_ptr, int my_len):             # <<<<<<<<<<<<<<
 *         cdef double s=0
 *         cdef coordinate_t i
 */

static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD__dotFull_partial(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, const double * __pyx_v_full_ptr, int __pyx_v_my_len) {
  double __pyx_v_s;
  coordinate_t __pyx_v_i;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_dotFull_partial", 0);

  /* "lurrn/sparsmat.pyx":5223
 *         return s
 *     cdef double _dotFull_partial(self, const_double_ptr full_ptr, int my_len):
 *         cdef double s=0             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<my_len:
 */
  __pyx_v_s = 0.0;

  /* "lurrn/sparsmat.pyx":5225
 *         cdef double s=0
 *         cdef coordinate_t i
 *         for i from 0<=i<my_len:             # <<<<<<<<<<<<<<
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s
 */
  __pyx_t_1 = __pyx_v_my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5226
 *         cdef coordinate_t i
 *         for i from 0<=i<my_len:
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]             # <<<<<<<<<<<<<<
 *         return s
 *     cpdef double jaccard(self, SparseVectorD other):
 */
    __pyx_v_s = (__pyx_v_s + ((__pyx_v_self->vals_ptr[__pyx_v_i]) * (__pyx_v_full_ptr[(__pyx_v_self->idx_ptr[__pyx_v_i])])));
  }

  /* "lurrn/sparsmat.pyx":5227
 *         for i from 0<=i<my_len:
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s             # <<<<<<<<<<<<<<
 *     cpdef double jaccard(self, SparseVectorD other):
 *         cdef double s_max=0
 */
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5222
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s
 *     cdef double _dotFull_partial(self, const_double_ptr full_ptr, int my_len):             # <<<<<<<<<<<<<<
 *         cdef double s=0
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5228
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s
 *     cpdef double jaccard(self, SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef double s_max=0
 *         cdef double s_min=0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_7jaccard(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_jaccard(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other, int __pyx_skip_dispatch) {
  double __pyx_v_s_max;
  double __pyx_v_s_min;
  double __pyx_v_val1;
  double __pyx_v_val2;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("jaccard", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_jaccard); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_7jaccard)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5229
 *         return s
 *     cpdef double jaccard(self, SparseVectorD other):
 *         cdef double s_max=0             # <<<<<<<<<<<<<<
 *         cdef double s_min=0
 *         cdef double val1, val2
 */
  __pyx_v_s_max = 0.0;

  /* "lurrn/sparsmat.pyx":5230
 *     cpdef double jaccard(self, SparseVectorD other):
 *         cdef double s_max=0
 *         cdef double s_min=0             # <<<<<<<<<<<<<<
 *         cdef double val1, val2
 *         cdef coordinate_t i,j, idx_i, idx_j
 */
  __pyx_v_s_min = 0.0;

  /* "lurrn/sparsmat.pyx":5233
 *         cdef double val1, val2
 *         cdef coordinate_t i,j, idx_i, idx_j
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":5234
 *         cdef coordinate_t i,j, idx_i, idx_j
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *             idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":5235
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *             idx_i=self.idx_ptr[i]
 *             idx_j=other.idx_ptr[j]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":5236
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *             idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *             idx_j=other.idx_ptr[j]
 *             if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":5237
 *         while i<self.my_len and j<other.my_len:
 *             idx_i=self.idx_ptr[i]
 *             idx_j=other.idx_ptr[j]             # <<<<<<<<<<<<<<
 *             if idx_i<idx_j:
 *                 s_max+=self.vals_ptr[i]
 */
    __pyx_v_idx_j = (__pyx_v_other->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":5238
 *             idx_i=self.idx_ptr[i]
 *             idx_j=other.idx_ptr[j]
 *             if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *                 s_max+=self.vals_ptr[i]
 *                 i+=1
 */
    __pyx_t_7 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":5239
 *             idx_j=other.idx_ptr[j]
 *             if idx_i<idx_j:
 *                 s_max+=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                 i+=1
 *             elif idx_i>idx_j:
 */
      __pyx_v_s_max = (__pyx_v_s_max + (__pyx_v_self->vals_ptr[__pyx_v_i]));

      /* "lurrn/sparsmat.pyx":5240
 *             if idx_i<idx_j:
 *                 s_max+=self.vals_ptr[i]
 *                 i+=1             # <<<<<<<<<<<<<<
 *             elif idx_i>idx_j:
 *                 s_max+=other.vals_ptr[j]
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":5241
 *                 s_max+=self.vals_ptr[i]
 *                 i+=1
 *             elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *                 s_max+=other.vals_ptr[j]
 *                 j+=1
 */
    __pyx_t_7 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":5242
 *                 i+=1
 *             elif idx_i>idx_j:
 *                 s_max+=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                 j+=1
 *             else:
 */
      __pyx_v_s_max = (__pyx_v_s_max + (__pyx_v_other->vals_ptr[__pyx_v_j]));

      /* "lurrn/sparsmat.pyx":5243
 *             elif idx_i>idx_j:
 *                 s_max+=other.vals_ptr[j]
 *                 j+=1             # <<<<<<<<<<<<<<
 *             else:
 *                 val1=self.vals_ptr[i]
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":5245
 *                 j+=1
 *             else:
 *                 val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                 val2=other.vals_ptr[j]
 *                 if val1>val2:
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":5246
 *             else:
 *                 val1=self.vals_ptr[i]
 *                 val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                 if val1>val2:
 *                     s_max+=val1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":5247
 *                 val1=self.vals_ptr[i]
 *                 val2=other.vals_ptr[j]
 *                 if val1>val2:             # <<<<<<<<<<<<<<
 *                     s_max+=val1
 *                     s_min+=val2
 */
      __pyx_t_7 = ((__pyx_v_val1 > __pyx_v_val2) != 0);
      if (__pyx_t_7) {

        /* "lurrn/sparsmat.pyx":5248
 *                 val2=other.vals_ptr[j]
 *                 if val1>val2:
 *                     s_max+=val1             # <<<<<<<<<<<<<<
 *                     s_min+=val2
 *                 else:
 */
        __pyx_v_s_max = (__pyx_v_s_max + __pyx_v_val1);

        /* "lurrn/sparsmat.pyx":5249
 *                 if val1>val2:
 *                     s_max+=val1
 *                     s_min+=val2             # <<<<<<<<<<<<<<
 *                 else:
 *                     s_max+=val2
 */
        __pyx_v_s_min = (__pyx_v_s_min + __pyx_v_val2);
        goto __pyx_L8;
      }
      /*else*/ {

        /* "lurrn/sparsmat.pyx":5251
 *                     s_min+=val2
 *                 else:
 *                     s_max+=val2             # <<<<<<<<<<<<<<
 *                     s_min+=val1
 *                 i+=1
 */
        __pyx_v_s_max = (__pyx_v_s_max + __pyx_v_val2);

        /* "lurrn/sparsmat.pyx":5252
 *                 else:
 *                     s_max+=val2
 *                     s_min+=val1             # <<<<<<<<<<<<<<
 *                 i+=1
 *                 j+=1
 */
        __pyx_v_s_min = (__pyx_v_s_min + __pyx_v_val1);
      }
      __pyx_L8:;

      /* "lurrn/sparsmat.pyx":5253
 *                     s_max+=val2
 *                     s_min+=val1
 *                 i+=1             # <<<<<<<<<<<<<<
 *                 j+=1
 *         if i<self.my_len:
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":5254
 *                     s_min+=val1
 *                 i+=1
 *                 j+=1             # <<<<<<<<<<<<<<
 *         if i<self.my_len:
 *             while i<self.my_len:
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":5255
 *                 i+=1
 *                 j+=1
 *         if i<self.my_len:             # <<<<<<<<<<<<<<
 *             while i<self.my_len:
 *                 s_max+=self.vals_ptr[i]
 */
  __pyx_t_7 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":5256
 *                 j+=1
 *         if i<self.my_len:
 *             while i<self.my_len:             # <<<<<<<<<<<<<<
 *                 s_max+=self.vals_ptr[i]
 *                 i+=1
 */
    while (1) {
      __pyx_t_7 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
      if (!__pyx_t_7) break;

      /* "lurrn/sparsmat.pyx":5257
 *         if i<self.my_len:
 *             while i<self.my_len:
 *                 s_max+=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                 i+=1
 *         else:
 */
      __pyx_v_s_max = (__pyx_v_s_max + (__pyx_v_self->vals_ptr[__pyx_v_i]));

      /* "lurrn/sparsmat.pyx":5258
 *             while i<self.my_len:
 *                 s_max+=self.vals_ptr[i]
 *                 i+=1             # <<<<<<<<<<<<<<
 *         else:
 *             while j<other.my_len:
 */
      __pyx_v_i = (__pyx_v_i + 1);
    }
    goto __pyx_L9;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":5260
 *                 i+=1
 *         else:
 *             while j<other.my_len:             # <<<<<<<<<<<<<<
 *                 s_max+=other.vals_ptr[j]
 *                 j+=1
 */
    while (1) {
      __pyx_t_7 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
      if (!__pyx_t_7) break;

      /* "lurrn/sparsmat.pyx":5261
 *         else:
 *             while j<other.my_len:
 *                 s_max+=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                 j+=1
 *         if s_max==0:
 */
      __pyx_v_s_max = (__pyx_v_s_max + (__pyx_v_other->vals_ptr[__pyx_v_j]));

      /* "lurrn/sparsmat.pyx":5262
 *             while j<other.my_len:
 *                 s_max+=other.vals_ptr[j]
 *                 j+=1             # <<<<<<<<<<<<<<
 *         if s_max==0:
 *             return 0.0
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
  }
  __pyx_L9:;

  /* "lurrn/sparsmat.pyx":5263
 *                 s_max+=other.vals_ptr[j]
 *                 j+=1
 *         if s_max==0:             # <<<<<<<<<<<<<<
 *             return 0.0
 *         else:
 */
  __pyx_t_7 = ((__pyx_v_s_max == 0.0) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":5264
 *                 j+=1
 *         if s_max==0:
 *             return 0.0             # <<<<<<<<<<<<<<
 *         else:
 *             return s_min/s_max
 */
    __pyx_r = 0.0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":5266
 *             return 0.0
 *         else:
 *             return s_min/s_max             # <<<<<<<<<<<<<<
 *     cpdef double dotSparse(self, SparseVectorD other):
 *         cdef double product=0
 */
    if (unlikely(__pyx_v_s_max == 0)) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      #ifdef WITH_THREAD
      PyGILState_Release(__pyx_gilstate_save);
      #endif
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_r = (__pyx_v_s_min / __pyx_v_s_max);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":5228
 *             s+=self.vals_ptr[i]*full_ptr[self.idx_ptr[i]]
 *         return s
 *     cpdef double jaccard(self, SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef double s_max=0
 *         cdef double s_min=0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorD.jaccard", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_7jaccard(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_7jaccard(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("jaccard (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorD, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_6jaccard(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_6jaccard(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("jaccard", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorD_jaccard(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.jaccard", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5267
 *         else:
 *             return s_min/s_max
 *     cpdef double dotSparse(self, SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef double product=0
 *         cdef double val1, val2
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_9dotSparse(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_dotSparse(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other, int __pyx_skip_dispatch) {
  double __pyx_v_product;
  double __pyx_v_val1;
  double __pyx_v_val2;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotSparse", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dotSparse); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_9dotSparse)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5268
 *             return s_min/s_max
 *     cpdef double dotSparse(self, SparseVectorD other):
 *         cdef double product=0             # <<<<<<<<<<<<<<
 *         cdef double val1, val2
 *         cdef coordinate_t i, j, idx_i, idx_j
 */
  __pyx_v_product = 0.0;

  /* "lurrn/sparsmat.pyx":5271
 *         cdef double val1, val2
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":5272
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":5273
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":5274
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":5275
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]             # <<<<<<<<<<<<<<
 *            if idx_i<idx_j:
 *               i+=1
 */
    __pyx_v_idx_j = (__pyx_v_other->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":5276
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *               i+=1
 *            elif idx_i>idx_j:
 */
    __pyx_t_7 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":5277
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 *               i+=1             # <<<<<<<<<<<<<<
 *            elif idx_i>idx_j:
 *               j+=1
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":5278
 *            if idx_i<idx_j:
 *               i+=1
 *            elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *               j+=1
 *            else:
 */
    __pyx_t_7 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":5279
 *               i+=1
 *            elif idx_i>idx_j:
 *               j+=1             # <<<<<<<<<<<<<<
 *            else:
 *               val1=self.vals_ptr[i]
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":5281
 *               j+=1
 *            else:
 *               val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *               val2=other.vals_ptr[j]
 *               product+=val1*val2
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":5282
 *            else:
 *               val1=self.vals_ptr[i]
 *               val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *               product+=val1*val2
 *               i+=1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":5283
 *               val1=self.vals_ptr[i]
 *               val2=other.vals_ptr[j]
 *               product+=val1*val2             # <<<<<<<<<<<<<<
 *               i+=1
 *               j+=1
 */
      __pyx_v_product = (__pyx_v_product + (__pyx_v_val1 * __pyx_v_val2));

      /* "lurrn/sparsmat.pyx":5284
 *               val2=other.vals_ptr[j]
 *               product+=val1*val2
 *               i+=1             # <<<<<<<<<<<<<<
 *               j+=1
 *         return product
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":5285
 *               product+=val1*val2
 *               i+=1
 *               j+=1             # <<<<<<<<<<<<<<
 *         return product
 *     def count_intersection(self, SparseVectorD other):
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":5286
 *               i+=1
 *               j+=1
 *         return product             # <<<<<<<<<<<<<<
 *     def count_intersection(self, SparseVectorD other):
 *         cdef coordinate_t i, j, idx_i, idx_j
 */
  __pyx_r = __pyx_v_product;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5267
 *         else:
 *             return s_min/s_max
 *     cpdef double dotSparse(self, SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef double product=0
 *         cdef double val1, val2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorD.dotSparse", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_9dotSparse(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_9dotSparse(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dotSparse (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorD, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_8dotSparse(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_8dotSparse(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotSparse", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorD_dotSparse(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.dotSparse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5287
 *               j+=1
 *         return product
 *     def count_intersection(self, SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         cdef int n_ab=0
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_11count_intersection(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_11count_intersection(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("count_intersection (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorD, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_10count_intersection(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_10count_intersection(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other) {
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  int __pyx_v_n_ab;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("count_intersection", 0);

  /* "lurrn/sparsmat.pyx":5289
 *     def count_intersection(self, SparseVectorD other):
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         cdef int n_ab=0             # <<<<<<<<<<<<<<
 *         i=0
 *         j=0
 */
  __pyx_v_n_ab = 0;

  /* "lurrn/sparsmat.pyx":5290
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         cdef int n_ab=0
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":5291
 *         cdef int n_ab=0
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":5292
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_1) break;

    /* "lurrn/sparsmat.pyx":5293
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":5294
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]             # <<<<<<<<<<<<<<
 *            if idx_i<idx_j:
 *               i+=1
 */
    __pyx_v_idx_j = (__pyx_v_other->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":5295
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *               i+=1
 *            elif idx_i>idx_j:
 */
    __pyx_t_1 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":5296
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 *               i+=1             # <<<<<<<<<<<<<<
 *            elif idx_i>idx_j:
 *               j+=1
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":5297
 *            if idx_i<idx_j:
 *               i+=1
 *            elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *               j+=1
 *            else:
 */
    __pyx_t_1 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":5298
 *               i+=1
 *            elif idx_i>idx_j:
 *               j+=1             # <<<<<<<<<<<<<<
 *            else:
 *               i+=1
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":5300
 *               j+=1
 *            else:
 *               i+=1             # <<<<<<<<<<<<<<
 *               j+=1
 *               n_ab+=1
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":5301
 *            else:
 *               i+=1
 *               j+=1             # <<<<<<<<<<<<<<
 *               n_ab+=1
 *         return n_ab
 */
      __pyx_v_j = (__pyx_v_j + 1);

      /* "lurrn/sparsmat.pyx":5302
 *               i+=1
 *               j+=1
 *               n_ab+=1             # <<<<<<<<<<<<<<
 *         return n_ab
 *     cpdef double min_sum(self, SparseVectorD other):
 */
      __pyx_v_n_ab = (__pyx_v_n_ab + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":5303
 *               j+=1
 *               n_ab+=1
 *         return n_ab             # <<<<<<<<<<<<<<
 *     cpdef double min_sum(self, SparseVectorD other):
 *         cdef double product=0.0
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n_ab); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5287
 *               j+=1
 *         return product
 *     def count_intersection(self, SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         cdef int n_ab=0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.count_intersection", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5304
 *               n_ab+=1
 *         return n_ab
 *     cpdef double min_sum(self, SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef double product=0.0
 *         cdef double val1, val2
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_13min_sum(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_min_sum(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other, int __pyx_skip_dispatch) {
  double __pyx_v_product;
  double __pyx_v_val1;
  double __pyx_v_val2;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("min_sum", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_min_sum); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_13min_sum)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5305
 *         return n_ab
 *     cpdef double min_sum(self, SparseVectorD other):
 *         cdef double product=0.0             # <<<<<<<<<<<<<<
 *         cdef double val1, val2
 *         cdef coordinate_t i, j, idx_i, idx_j
 */
  __pyx_v_product = 0.0;

  /* "lurrn/sparsmat.pyx":5308
 *         cdef double val1, val2
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":5309
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":5310
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":5311
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":5312
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]             # <<<<<<<<<<<<<<
 *            if idx_i<idx_j:
 *               i+=1
 */
    __pyx_v_idx_j = (__pyx_v_other->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":5313
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *               i+=1
 *            elif idx_i>idx_j:
 */
    __pyx_t_7 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":5314
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 *               i+=1             # <<<<<<<<<<<<<<
 *            elif idx_i>idx_j:
 *               j+=1
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":5315
 *            if idx_i<idx_j:
 *               i+=1
 *            elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *               j+=1
 *            else:
 */
    __pyx_t_7 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":5316
 *               i+=1
 *            elif idx_i>idx_j:
 *               j+=1             # <<<<<<<<<<<<<<
 *            else:
 *               val1=self.vals_ptr[i]
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":5318
 *               j+=1
 *            else:
 *               val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *               val2=other.vals_ptr[j]
 *               if val1<val2:
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":5319
 *            else:
 *               val1=self.vals_ptr[i]
 *               val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *               if val1<val2:
 *                   product+=val1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":5320
 *               val1=self.vals_ptr[i]
 *               val2=other.vals_ptr[j]
 *               if val1<val2:             # <<<<<<<<<<<<<<
 *                   product+=val1
 *               else:
 */
      __pyx_t_7 = ((__pyx_v_val1 < __pyx_v_val2) != 0);
      if (__pyx_t_7) {

        /* "lurrn/sparsmat.pyx":5321
 *               val2=other.vals_ptr[j]
 *               if val1<val2:
 *                   product+=val1             # <<<<<<<<<<<<<<
 *               else:
 *                   product+=val2
 */
        __pyx_v_product = (__pyx_v_product + __pyx_v_val1);
        goto __pyx_L8;
      }
      /*else*/ {

        /* "lurrn/sparsmat.pyx":5323
 *                   product+=val1
 *               else:
 *                   product+=val2             # <<<<<<<<<<<<<<
 *               i+=1
 *               j+=1
 */
        __pyx_v_product = (__pyx_v_product + __pyx_v_val2);
      }
      __pyx_L8:;

      /* "lurrn/sparsmat.pyx":5324
 *               else:
 *                   product+=val2
 *               i+=1             # <<<<<<<<<<<<<<
 *               j+=1
 *         return product
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":5325
 *                   product+=val2
 *               i+=1
 *               j+=1             # <<<<<<<<<<<<<<
 *         return product
 *     cpdef double cosine(self, SparseVectorD other):
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":5326
 *               i+=1
 *               j+=1
 *         return product             # <<<<<<<<<<<<<<
 *     cpdef double cosine(self, SparseVectorD other):
 *         cdef double sqsum_self=0.0
 */
  __pyx_r = __pyx_v_product;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5304
 *               n_ab+=1
 *         return n_ab
 *     cpdef double min_sum(self, SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef double product=0.0
 *         cdef double val1, val2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorD.min_sum", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_13min_sum(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_13min_sum(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("min_sum (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorD, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_12min_sum(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_12min_sum(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("min_sum", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorD_min_sum(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.min_sum", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5327
 *               j+=1
 *         return product
 *     cpdef double cosine(self, SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef double sqsum_self=0.0
 *         cdef double sqsum_other=0.0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_15cosine(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_cosine(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other, int __pyx_skip_dispatch) {
  double __pyx_v_sqsum_self;
  double __pyx_v_sqsum_other;
  double __pyx_v_product;
  double __pyx_v_val1;
  double __pyx_v_val2;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("cosine", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_cosine); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_15cosine)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5328
 *         return product
 *     cpdef double cosine(self, SparseVectorD other):
 *         cdef double sqsum_self=0.0             # <<<<<<<<<<<<<<
 *         cdef double sqsum_other=0.0
 *         cdef double product=0.0
 */
  __pyx_v_sqsum_self = 0.0;

  /* "lurrn/sparsmat.pyx":5329
 *     cpdef double cosine(self, SparseVectorD other):
 *         cdef double sqsum_self=0.0
 *         cdef double sqsum_other=0.0             # <<<<<<<<<<<<<<
 *         cdef double product=0.0
 *         cdef double val1, val2
 */
  __pyx_v_sqsum_other = 0.0;

  /* "lurrn/sparsmat.pyx":5330
 *         cdef double sqsum_self=0.0
 *         cdef double sqsum_other=0.0
 *         cdef double product=0.0             # <<<<<<<<<<<<<<
 *         cdef double val1, val2
 *         cdef coordinate_t i, j, idx_i, idx_j
 */
  __pyx_v_product = 0.0;

  /* "lurrn/sparsmat.pyx":5333
 *         cdef double val1, val2
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":5334
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":5335
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":5336
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":5337
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]             # <<<<<<<<<<<<<<
 *            if idx_i<idx_j:
 *               val1=self.vals_ptr[i]
 */
    __pyx_v_idx_j = (__pyx_v_other->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":5338
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *               val1=self.vals_ptr[i]
 *               sqsum_self+=val1*val1
 */
    __pyx_t_7 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":5339
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 *               val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *               sqsum_self+=val1*val1
 *               i+=1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":5340
 *            if idx_i<idx_j:
 *               val1=self.vals_ptr[i]
 *               sqsum_self+=val1*val1             # <<<<<<<<<<<<<<
 *               i+=1
 *            elif idx_i>idx_j:
 */
      __pyx_v_sqsum_self = (__pyx_v_sqsum_self + (__pyx_v_val1 * __pyx_v_val1));

      /* "lurrn/sparsmat.pyx":5341
 *               val1=self.vals_ptr[i]
 *               sqsum_self+=val1*val1
 *               i+=1             # <<<<<<<<<<<<<<
 *            elif idx_i>idx_j:
 *               val2=other.vals_ptr[j]
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":5342
 *               sqsum_self+=val1*val1
 *               i+=1
 *            elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *               val2=other.vals_ptr[j]
 *               sqsum_other+=val2*val2
 */
    __pyx_t_7 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":5343
 *               i+=1
 *            elif idx_i>idx_j:
 *               val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *               sqsum_other+=val2*val2
 *               j+=1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":5344
 *            elif idx_i>idx_j:
 *               val2=other.vals_ptr[j]
 *               sqsum_other+=val2*val2             # <<<<<<<<<<<<<<
 *               j+=1
 *            else:
 */
      __pyx_v_sqsum_other = (__pyx_v_sqsum_other + (__pyx_v_val2 * __pyx_v_val2));

      /* "lurrn/sparsmat.pyx":5345
 *               val2=other.vals_ptr[j]
 *               sqsum_other+=val2*val2
 *               j+=1             # <<<<<<<<<<<<<<
 *            else:
 *               val1=self.vals_ptr[i]
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":5347
 *               j+=1
 *            else:
 *               val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *               val2=other.vals_ptr[j]
 *               sqsum_self+=val1*val1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":5348
 *            else:
 *               val1=self.vals_ptr[i]
 *               val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *               sqsum_self+=val1*val1
 *               sqsum_other+=val2*val2
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":5349
 *               val1=self.vals_ptr[i]
 *               val2=other.vals_ptr[j]
 *               sqsum_self+=val1*val1             # <<<<<<<<<<<<<<
 *               sqsum_other+=val2*val2
 *               product+=val1*val2
 */
      __pyx_v_sqsum_self = (__pyx_v_sqsum_self + (__pyx_v_val1 * __pyx_v_val1));

      /* "lurrn/sparsmat.pyx":5350
 *               val2=other.vals_ptr[j]
 *               sqsum_self+=val1*val1
 *               sqsum_other+=val2*val2             # <<<<<<<<<<<<<<
 *               product+=val1*val2
 *               i+=1
 */
      __pyx_v_sqsum_other = (__pyx_v_sqsum_other + (__pyx_v_val2 * __pyx_v_val2));

      /* "lurrn/sparsmat.pyx":5351
 *               sqsum_self+=val1*val1
 *               sqsum_other+=val2*val2
 *               product+=val1*val2             # <<<<<<<<<<<<<<
 *               i+=1
 *               j+=1
 */
      __pyx_v_product = (__pyx_v_product + (__pyx_v_val1 * __pyx_v_val2));

      /* "lurrn/sparsmat.pyx":5352
 *               sqsum_other+=val2*val2
 *               product+=val1*val2
 *               i+=1             # <<<<<<<<<<<<<<
 *               j+=1
 *         if i<self.my_len:
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":5353
 *               product+=val1*val2
 *               i+=1
 *               j+=1             # <<<<<<<<<<<<<<
 *         if i<self.my_len:
 *             while i<self.my_len:
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":5354
 *               i+=1
 *               j+=1
 *         if i<self.my_len:             # <<<<<<<<<<<<<<
 *             while i<self.my_len:
 *                 val1=self.vals_ptr[i]
 */
  __pyx_t_7 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":5355
 *               j+=1
 *         if i<self.my_len:
 *             while i<self.my_len:             # <<<<<<<<<<<<<<
 *                 val1=self.vals_ptr[i]
 *                 sqsum_self+=val1*val1
 */
    while (1) {
      __pyx_t_7 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
      if (!__pyx_t_7) break;

      /* "lurrn/sparsmat.pyx":5356
 *         if i<self.my_len:
 *             while i<self.my_len:
 *                 val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                 sqsum_self+=val1*val1
 *                 i+=1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":5357
 *             while i<self.my_len:
 *                 val1=self.vals_ptr[i]
 *                 sqsum_self+=val1*val1             # <<<<<<<<<<<<<<
 *                 i+=1
 *         else:
 */
      __pyx_v_sqsum_self = (__pyx_v_sqsum_self + (__pyx_v_val1 * __pyx_v_val1));

      /* "lurrn/sparsmat.pyx":5358
 *                 val1=self.vals_ptr[i]
 *                 sqsum_self+=val1*val1
 *                 i+=1             # <<<<<<<<<<<<<<
 *         else:
 *             while j<other.my_len:
 */
      __pyx_v_i = (__pyx_v_i + 1);
    }
    goto __pyx_L8;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":5360
 *                 i+=1
 *         else:
 *             while j<other.my_len:             # <<<<<<<<<<<<<<
 *                 val2=other.vals_ptr[j]
 *                 sqsum_other+=val2*val2
 */
    while (1) {
      __pyx_t_7 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
      if (!__pyx_t_7) break;

      /* "lurrn/sparsmat.pyx":5361
 *         else:
 *             while j<other.my_len:
 *                 val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                 sqsum_other+=val2*val2
 *                 j+=1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":5362
 *             while j<other.my_len:
 *                 val2=other.vals_ptr[j]
 *                 sqsum_other+=val2*val2             # <<<<<<<<<<<<<<
 *                 j+=1
 *         return product/sqrt(sqsum_self*sqsum_other)
 */
      __pyx_v_sqsum_other = (__pyx_v_sqsum_other + (__pyx_v_val2 * __pyx_v_val2));

      /* "lurrn/sparsmat.pyx":5363
 *                 val2=other.vals_ptr[j]
 *                 sqsum_other+=val2*val2
 *                 j+=1             # <<<<<<<<<<<<<<
 *         return product/sqrt(sqsum_self*sqsum_other)
 *     cpdef double jsd_unnorm(self, SparseVectorD other):
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
  }
  __pyx_L8:;

  /* "lurrn/sparsmat.pyx":5364
 *                 sqsum_other+=val2*val2
 *                 j+=1
 *         return product/sqrt(sqsum_self*sqsum_other)             # <<<<<<<<<<<<<<
 *     cpdef double jsd_unnorm(self, SparseVectorD other):
 *         cdef double sum=0.0
 */
  __pyx_t_6 = sqrt((__pyx_v_sqsum_self * __pyx_v_sqsum_other));
  if (unlikely(__pyx_t_6 == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_r = (__pyx_v_product / __pyx_t_6);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5327
 *               j+=1
 *         return product
 *     cpdef double cosine(self, SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef double sqsum_self=0.0
 *         cdef double sqsum_other=0.0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorD.cosine", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_15cosine(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_15cosine(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("cosine (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorD, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_14cosine(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_14cosine(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("cosine", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorD_cosine(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.cosine", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5365
 *                 j+=1
 *         return product/sqrt(sqsum_self*sqsum_other)
 *     cpdef double jsd_unnorm(self, SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef double val1, val2, avg
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_17jsd_unnorm(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_jsd_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other, int __pyx_skip_dispatch) {
  double __pyx_v_sum;
  double __pyx_v_val1;
  double __pyx_v_val2;
  double __pyx_v_avg;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("jsd_unnorm", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_jsd_unnorm); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_17jsd_unnorm)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5366
 *         return product/sqrt(sqsum_self*sqsum_other)
 *     cpdef double jsd_unnorm(self, SparseVectorD other):
 *         cdef double sum=0.0             # <<<<<<<<<<<<<<
 *         cdef double val1, val2, avg
 *         cdef coordinate_t i, j, idx_i, idx_j
 */
  __pyx_v_sum = 0.0;

  /* "lurrn/sparsmat.pyx":5369
 *         cdef double val1, val2, avg
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":5370
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":5371
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":5372
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":5373
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]             # <<<<<<<<<<<<<<
 *            if idx_i<idx_j:
 *                val1=self.vals_ptr[i]
 */
    __pyx_v_idx_j = (__pyx_v_other->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":5374
 *            idx_i=self.idx_ptr[i]
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *                val1=self.vals_ptr[i]
 *                sum+=val1*M_LN2
 */
    __pyx_t_7 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":5375
 *            idx_j=other.idx_ptr[j]
 *            if idx_i<idx_j:
 *                val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                sum+=val1*M_LN2
 *                i+=1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":5376
 *            if idx_i<idx_j:
 *                val1=self.vals_ptr[i]
 *                sum+=val1*M_LN2             # <<<<<<<<<<<<<<
 *                i+=1
 *            elif idx_i>idx_j:
 */
      __pyx_v_sum = (__pyx_v_sum + (__pyx_v_val1 * M_LN2));

      /* "lurrn/sparsmat.pyx":5377
 *                val1=self.vals_ptr[i]
 *                sum+=val1*M_LN2
 *                i+=1             # <<<<<<<<<<<<<<
 *            elif idx_i>idx_j:
 *                val2=other.vals_ptr[j]
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":5378
 *                sum+=val1*M_LN2
 *                i+=1
 *            elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *                val2=other.vals_ptr[j]
 *                sum+=val2*M_LN2
 */
    __pyx_t_7 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":5379
 *                i+=1
 *            elif idx_i>idx_j:
 *                val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                sum+=val2*M_LN2
 *                j+=1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":5380
 *            elif idx_i>idx_j:
 *                val2=other.vals_ptr[j]
 *                sum+=val2*M_LN2             # <<<<<<<<<<<<<<
 *                j+=1
 *            else:
 */
      __pyx_v_sum = (__pyx_v_sum + (__pyx_v_val2 * M_LN2));

      /* "lurrn/sparsmat.pyx":5381
 *                val2=other.vals_ptr[j]
 *                sum+=val2*M_LN2
 *                j+=1             # <<<<<<<<<<<<<<
 *            else:
 *                val1=self.vals_ptr[i]
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":5383
 *                j+=1
 *            else:
 *                val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                val2=other.vals_ptr[j]
 *                i+=1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":5384
 *            else:
 *                val1=self.vals_ptr[i]
 *                val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                i+=1
 *                j+=1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":5385
 *                val1=self.vals_ptr[i]
 *                val2=other.vals_ptr[j]
 *                i+=1             # <<<<<<<<<<<<<<
 *                j+=1
 *                avg=(val1+val2)/2.0
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":5386
 *                val2=other.vals_ptr[j]
 *                i+=1
 *                j+=1             # <<<<<<<<<<<<<<
 *                avg=(val1+val2)/2.0
 *                sum+=val1*log(val1/avg)+val2*log(val2/avg)
 */
      __pyx_v_j = (__pyx_v_j + 1);

      /* "lurrn/sparsmat.pyx":5387
 *                i+=1
 *                j+=1
 *                avg=(val1+val2)/2.0             # <<<<<<<<<<<<<<
 *                sum+=val1*log(val1/avg)+val2*log(val2/avg)
 *         while i<self.my_len:
 */
      __pyx_v_avg = ((__pyx_v_val1 + __pyx_v_val2) / 2.0);

      /* "lurrn/sparsmat.pyx":5388
 *                j+=1
 *                avg=(val1+val2)/2.0
 *                sum+=val1*log(val1/avg)+val2*log(val2/avg)             # <<<<<<<<<<<<<<
 *         while i<self.my_len:
 *            val1=self.vals_ptr[i]
 */
      if (unlikely(__pyx_v_avg == 0)) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        #ifdef WITH_THREAD
        PyGILState_Release(__pyx_gilstate_save);
        #endif
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      if (unlikely(__pyx_v_avg == 0)) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        #ifdef WITH_THREAD
        PyGILState_Release(__pyx_gilstate_save);
        #endif
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_v_sum = (__pyx_v_sum + ((__pyx_v_val1 * log((__pyx_v_val1 / __pyx_v_avg))) + (__pyx_v_val2 * log((__pyx_v_val2 / __pyx_v_avg)))));
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":5389
 *                avg=(val1+val2)/2.0
 *                sum+=val1*log(val1/avg)+val2*log(val2/avg)
 *         while i<self.my_len:             # <<<<<<<<<<<<<<
 *            val1=self.vals_ptr[i]
 *            i+=1
 */
  while (1) {
    __pyx_t_7 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":5390
 *                sum+=val1*log(val1/avg)+val2*log(val2/avg)
 *         while i<self.my_len:
 *            val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *            i+=1
 *            sum+=val1*M_LN2
 */
    __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":5391
 *         while i<self.my_len:
 *            val1=self.vals_ptr[i]
 *            i+=1             # <<<<<<<<<<<<<<
 *            sum+=val1*M_LN2
 *         while j<other.my_len:
 */
    __pyx_v_i = (__pyx_v_i + 1);

    /* "lurrn/sparsmat.pyx":5392
 *            val1=self.vals_ptr[i]
 *            i+=1
 *            sum+=val1*M_LN2             # <<<<<<<<<<<<<<
 *         while j<other.my_len:
 *            val2=other.vals_ptr[j]
 */
    __pyx_v_sum = (__pyx_v_sum + (__pyx_v_val1 * M_LN2));
  }

  /* "lurrn/sparsmat.pyx":5393
 *            i+=1
 *            sum+=val1*M_LN2
 *         while j<other.my_len:             # <<<<<<<<<<<<<<
 *            val2=other.vals_ptr[j]
 *            j+=1
 */
  while (1) {
    __pyx_t_7 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":5394
 *            sum+=val1*M_LN2
 *         while j<other.my_len:
 *            val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *            j+=1
 *            sum+=val2*M_LN2
 */
    __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":5395
 *         while j<other.my_len:
 *            val2=other.vals_ptr[j]
 *            j+=1             # <<<<<<<<<<<<<<
 *            sum+=val2*M_LN2
 *         return sum/(2.0*M_LN2)
 */
    __pyx_v_j = (__pyx_v_j + 1);

    /* "lurrn/sparsmat.pyx":5396
 *            val2=other.vals_ptr[j]
 *            j+=1
 *            sum+=val2*M_LN2             # <<<<<<<<<<<<<<
 *         return sum/(2.0*M_LN2)
 *     cpdef double skew_unnorm(self, SparseVectorD other, double alpha):
 */
    __pyx_v_sum = (__pyx_v_sum + (__pyx_v_val2 * M_LN2));
  }

  /* "lurrn/sparsmat.pyx":5397
 *            j+=1
 *            sum+=val2*M_LN2
 *         return sum/(2.0*M_LN2)             # <<<<<<<<<<<<<<
 *     cpdef double skew_unnorm(self, SparseVectorD other, double alpha):
 *         cdef double sum=0.0
 */
  __pyx_t_6 = (2.0 * M_LN2);
  if (unlikely(__pyx_t_6 == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_r = (__pyx_v_sum / __pyx_t_6);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5365
 *                 j+=1
 *         return product/sqrt(sqsum_self*sqsum_other)
 *     cpdef double jsd_unnorm(self, SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef double val1, val2, avg
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorD.jsd_unnorm", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_17jsd_unnorm(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_17jsd_unnorm(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("jsd_unnorm (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorD, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_16jsd_unnorm(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_16jsd_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("jsd_unnorm", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorD_jsd_unnorm(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.jsd_unnorm", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5398
 *            sum+=val2*M_LN2
 *         return sum/(2.0*M_LN2)
 *     cpdef double skew_unnorm(self, SparseVectorD other, double alpha):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef double beta=1.0-alpha
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_19skew_unnorm(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_skew_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other, double __pyx_v_alpha, int __pyx_skip_dispatch) {
  double __pyx_v_sum;
  double __pyx_v_beta;
  double __pyx_v_val1;
  double __pyx_v_val2;
  double __pyx_v_avg;
  coordinate_t __pyx_v_i;
  coordinate_t __pyx_v_j;
  coordinate_t __pyx_v_idx_i;
  coordinate_t __pyx_v_idx_j;
  double __pyx_v_log_invbeta;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  double __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("skew_unnorm", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_skew_unnorm); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_19skew_unnorm)) {
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_alpha); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_other));
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_other));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_8;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5399
 *         return sum/(2.0*M_LN2)
 *     cpdef double skew_unnorm(self, SparseVectorD other, double alpha):
 *         cdef double sum=0.0             # <<<<<<<<<<<<<<
 *         cdef double beta=1.0-alpha
 *         cdef double val1, val2, avg
 */
  __pyx_v_sum = 0.0;

  /* "lurrn/sparsmat.pyx":5400
 *     cpdef double skew_unnorm(self, SparseVectorD other, double alpha):
 *         cdef double sum=0.0
 *         cdef double beta=1.0-alpha             # <<<<<<<<<<<<<<
 *         cdef double val1, val2, avg
 *         cdef coordinate_t i, j, idx_i, idx_j
 */
  __pyx_v_beta = (1.0 - __pyx_v_alpha);

  /* "lurrn/sparsmat.pyx":5403
 *         cdef double val1, val2, avg
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         cdef double log_invbeta=log(1.0/beta)             # <<<<<<<<<<<<<<
 *         i=0
 *         j=0
 */
  if (unlikely(__pyx_v_beta == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_log_invbeta = log((1.0 / __pyx_v_beta));

  /* "lurrn/sparsmat.pyx":5404
 *         cdef coordinate_t i, j, idx_i, idx_j
 *         cdef double log_invbeta=log(1.0/beta)
 *         i=0             # <<<<<<<<<<<<<<
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 */
  __pyx_v_i = 0;

  /* "lurrn/sparsmat.pyx":5405
 *         cdef double log_invbeta=log(1.0/beta)
 *         i=0
 *         j=0             # <<<<<<<<<<<<<<
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 */
  __pyx_v_j = 0;

  /* "lurrn/sparsmat.pyx":5406
 *         i=0
 *         j=0
 *         while i<self.my_len and j<other.my_len:             # <<<<<<<<<<<<<<
 *            idx_i=self.idx_ptr[i]
 *            idx_j=self.idx_ptr[j]
 */
  while (1) {
    __pyx_t_10 = ((__pyx_v_i < __pyx_v_self->my_len) != 0);
    if (__pyx_t_10) {
    } else {
      __pyx_t_9 = __pyx_t_10;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_10 = ((__pyx_v_j < __pyx_v_other->my_len) != 0);
    __pyx_t_9 = __pyx_t_10;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_9) break;

    /* "lurrn/sparsmat.pyx":5407
 *         j=0
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *            idx_j=self.idx_ptr[j]
 *            if idx_i<idx_j:
 */
    __pyx_v_idx_i = (__pyx_v_self->idx_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":5408
 *         while i<self.my_len and j<other.my_len:
 *            idx_i=self.idx_ptr[i]
 *            idx_j=self.idx_ptr[j]             # <<<<<<<<<<<<<<
 *            if idx_i<idx_j:
 *                val1=self.vals_ptr[i]
 */
    __pyx_v_idx_j = (__pyx_v_self->idx_ptr[__pyx_v_j]);

    /* "lurrn/sparsmat.pyx":5409
 *            idx_i=self.idx_ptr[i]
 *            idx_j=self.idx_ptr[j]
 *            if idx_i<idx_j:             # <<<<<<<<<<<<<<
 *                val1=self.vals_ptr[i]
 *                sum+=val1*log_invbeta
 */
    __pyx_t_9 = ((__pyx_v_idx_i < __pyx_v_idx_j) != 0);
    if (__pyx_t_9) {

      /* "lurrn/sparsmat.pyx":5410
 *            idx_j=self.idx_ptr[j]
 *            if idx_i<idx_j:
 *                val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                sum+=val1*log_invbeta
 *                i+=1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":5411
 *            if idx_i<idx_j:
 *                val1=self.vals_ptr[i]
 *                sum+=val1*log_invbeta             # <<<<<<<<<<<<<<
 *                i+=1
 *            elif idx_i>idx_j:
 */
      __pyx_v_sum = (__pyx_v_sum + (__pyx_v_val1 * __pyx_v_log_invbeta));

      /* "lurrn/sparsmat.pyx":5412
 *                val1=self.vals_ptr[i]
 *                sum+=val1*log_invbeta
 *                i+=1             # <<<<<<<<<<<<<<
 *            elif idx_i>idx_j:
 *                j+=1
 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":5413
 *                sum+=val1*log_invbeta
 *                i+=1
 *            elif idx_i>idx_j:             # <<<<<<<<<<<<<<
 *                j+=1
 *            else:
 */
    __pyx_t_9 = ((__pyx_v_idx_i > __pyx_v_idx_j) != 0);
    if (__pyx_t_9) {

      /* "lurrn/sparsmat.pyx":5414
 *                i+=1
 *            elif idx_i>idx_j:
 *                j+=1             # <<<<<<<<<<<<<<
 *            else:
 *                val1=self.vals_ptr[i]
 */
      __pyx_v_j = (__pyx_v_j + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":5416
 *                j+=1
 *            else:
 *                val1=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *                val2=other.vals_ptr[j]
 *                avg=alpha*val2+beta*val1
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":5417
 *            else:
 *                val1=self.vals_ptr[i]
 *                val2=other.vals_ptr[j]             # <<<<<<<<<<<<<<
 *                avg=alpha*val2+beta*val1
 *                sum+=log(val1/avg)
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_j]);

      /* "lurrn/sparsmat.pyx":5418
 *                val1=self.vals_ptr[i]
 *                val2=other.vals_ptr[j]
 *                avg=alpha*val2+beta*val1             # <<<<<<<<<<<<<<
 *                sum+=log(val1/avg)
 *                i+=1
 */
      __pyx_v_avg = ((__pyx_v_alpha * __pyx_v_val2) + (__pyx_v_beta * __pyx_v_val1));

      /* "lurrn/sparsmat.pyx":5419
 *                val2=other.vals_ptr[j]
 *                avg=alpha*val2+beta*val1
 *                sum+=log(val1/avg)             # <<<<<<<<<<<<<<
 *                i+=1
 *                j+=1
 */
      if (unlikely(__pyx_v_avg == 0)) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        #ifdef WITH_THREAD
        PyGILState_Release(__pyx_gilstate_save);
        #endif
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_v_sum = (__pyx_v_sum + log((__pyx_v_val1 / __pyx_v_avg)));

      /* "lurrn/sparsmat.pyx":5420
 *                avg=alpha*val2+beta*val1
 *                sum+=log(val1/avg)
 *                i+=1             # <<<<<<<<<<<<<<
 *                j+=1
 *         return sum
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "lurrn/sparsmat.pyx":5421
 *                sum+=log(val1/avg)
 *                i+=1
 *                j+=1             # <<<<<<<<<<<<<<
 *         return sum
 *     cpdef double norm_l1(self):
 */
      __pyx_v_j = (__pyx_v_j + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":5422
 *                i+=1
 *                j+=1
 *         return sum             # <<<<<<<<<<<<<<
 *     cpdef double norm_l1(self):
 *         cdef double sum=0.0
 */
  __pyx_r = __pyx_v_sum;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5398
 *            sum+=val2*M_LN2
 *         return sum/(2.0*M_LN2)
 *     cpdef double skew_unnorm(self, SparseVectorD other, double alpha):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef double beta=1.0-alpha
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorD.skew_unnorm", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_19skew_unnorm(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_19skew_unnorm(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other = 0;
  double __pyx_v_alpha;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("skew_unnorm (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_other,&__pyx_n_s_alpha,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_other)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alpha)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("skew_unnorm", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5398; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "skew_unnorm") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5398; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_other = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)values[0]);
    __pyx_v_alpha = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_alpha == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5398; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("skew_unnorm", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5398; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.skew_unnorm", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorD, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_18skew_unnorm(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), __pyx_v_other, __pyx_v_alpha);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_18skew_unnorm(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other, double __pyx_v_alpha) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("skew_unnorm", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorD_skew_unnorm(__pyx_v_self, __pyx_v_other, __pyx_v_alpha, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.skew_unnorm", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5423
 *                j+=1
 *         return sum
 *     cpdef double norm_l1(self):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef unsigned int i
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_21norm_l1(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_norm_l1(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, int __pyx_skip_dispatch) {
  double __pyx_v_sum;
  unsigned int __pyx_v_i;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  double __pyx_t_5;
  unsigned int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("norm_l1", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_norm_l1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_21norm_l1)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_5;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5424
 *         return sum
 *     cpdef double norm_l1(self):
 *         cdef double sum=0.0             # <<<<<<<<<<<<<<
 *         cdef unsigned int i
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_sum = 0.0;

  /* "lurrn/sparsmat.pyx":5426
 *         cdef double sum=0.0
 *         cdef unsigned int i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             sum+=fabs(self.vals_ptr[i])
 *         return sum
 */
  __pyx_t_6 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5427
 *         cdef unsigned int i
 *         for i from 0<=i<self.my_len:
 *             sum+=fabs(self.vals_ptr[i])             # <<<<<<<<<<<<<<
 *         return sum
 *     cpdef double norm_l2(self):
 */
    __pyx_v_sum = (__pyx_v_sum + fabs((__pyx_v_self->vals_ptr[__pyx_v_i])));
  }

  /* "lurrn/sparsmat.pyx":5428
 *         for i from 0<=i<self.my_len:
 *             sum+=fabs(self.vals_ptr[i])
 *         return sum             # <<<<<<<<<<<<<<
 *     cpdef double norm_l2(self):
 *         cdef double sum=0.0
 */
  __pyx_r = __pyx_v_sum;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5423
 *                j+=1
 *         return sum
 *     cpdef double norm_l1(self):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef unsigned int i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorD.norm_l1", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_21norm_l1(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_21norm_l1(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("norm_l1 (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_20norm_l1(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_20norm_l1(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("norm_l1", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorD_norm_l1(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.norm_l1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5429
 *             sum+=fabs(self.vals_ptr[i])
 *         return sum
 *     cpdef double norm_l2(self):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef double val
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_23norm_l2(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_norm_l2(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, int __pyx_skip_dispatch) {
  double __pyx_v_sum;
  double __pyx_v_val;
  unsigned int __pyx_v_i;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  double __pyx_t_5;
  unsigned int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("norm_l2", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_norm_l2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_23norm_l2)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_5;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5430
 *         return sum
 *     cpdef double norm_l2(self):
 *         cdef double sum=0.0             # <<<<<<<<<<<<<<
 *         cdef double val
 *         cdef unsigned int i
 */
  __pyx_v_sum = 0.0;

  /* "lurrn/sparsmat.pyx":5433
 *         cdef double val
 *         cdef unsigned int i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             val=self.vals_ptr[i];
 *             sum+=val*val
 */
  __pyx_t_6 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5434
 *         cdef unsigned int i
 *         for i from 0<=i<self.my_len:
 *             val=self.vals_ptr[i];             # <<<<<<<<<<<<<<
 *             sum+=val*val
 *         return sqrt(sum)
 */
    __pyx_v_val = (__pyx_v_self->vals_ptr[__pyx_v_i]);

    /* "lurrn/sparsmat.pyx":5435
 *         for i from 0<=i<self.my_len:
 *             val=self.vals_ptr[i];
 *             sum+=val*val             # <<<<<<<<<<<<<<
 *         return sqrt(sum)
 *     cpdef double norm_lp(self, double p):
 */
    __pyx_v_sum = (__pyx_v_sum + (__pyx_v_val * __pyx_v_val));
  }

  /* "lurrn/sparsmat.pyx":5436
 *             val=self.vals_ptr[i];
 *             sum+=val*val
 *         return sqrt(sum)             # <<<<<<<<<<<<<<
 *     cpdef double norm_lp(self, double p):
 *         cdef double sum=0.0
 */
  __pyx_r = sqrt(__pyx_v_sum);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5429
 *             sum+=fabs(self.vals_ptr[i])
 *         return sum
 *     cpdef double norm_l2(self):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef double val
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorD.norm_l2", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_23norm_l2(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_23norm_l2(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("norm_l2 (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_22norm_l2(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_22norm_l2(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("norm_l2", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorD_norm_l2(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.norm_l2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5437
 *             sum+=val*val
 *         return sqrt(sum)
 *     cpdef double norm_lp(self, double p):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef int i
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_25norm_lp(PyObject *__pyx_v_self, PyObject *__pyx_arg_p); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_norm_lp(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, double __pyx_v_p, int __pyx_skip_dispatch) {
  double __pyx_v_sum;
  int __pyx_v_i;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  double __pyx_t_7;
  unsigned int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("norm_lp", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_norm_lp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_25norm_lp)) {
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_p); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5438
 *         return sqrt(sum)
 *     cpdef double norm_lp(self, double p):
 *         cdef double sum=0.0             # <<<<<<<<<<<<<<
 *         cdef int i
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_sum = 0.0;

  /* "lurrn/sparsmat.pyx":5440
 *         cdef double sum=0.0
 *         cdef int i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             sum+=pow(fabs(self.vals_ptr[i]),p)
 *         return pow(sum,1.0/p)
 */
  __pyx_t_8 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5441
 *         cdef int i
 *         for i from 0<=i<self.my_len:
 *             sum+=pow(fabs(self.vals_ptr[i]),p)             # <<<<<<<<<<<<<<
 *         return pow(sum,1.0/p)
 *     def dotFull(self, numpy.ndarray[double,ndim=1] full):
 */
    __pyx_v_sum = (__pyx_v_sum + pow(fabs((__pyx_v_self->vals_ptr[__pyx_v_i])), __pyx_v_p));
  }

  /* "lurrn/sparsmat.pyx":5442
 *         for i from 0<=i<self.my_len:
 *             sum+=pow(fabs(self.vals_ptr[i]),p)
 *         return pow(sum,1.0/p)             # <<<<<<<<<<<<<<
 *     def dotFull(self, numpy.ndarray[double,ndim=1] full):
 *         cdef double *full_ptr
 */
  if (unlikely(__pyx_v_p == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_r = pow(__pyx_v_sum, (1.0 / __pyx_v_p));
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5437
 *             sum+=val*val
 *         return sqrt(sum)
 *     cpdef double norm_lp(self, double p):             # <<<<<<<<<<<<<<
 *         cdef double sum=0.0
 *         cdef int i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorD.norm_lp", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_25norm_lp(PyObject *__pyx_v_self, PyObject *__pyx_arg_p); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_25norm_lp(PyObject *__pyx_v_self, PyObject *__pyx_arg_p) {
  double __pyx_v_p;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("norm_lp (wrapper)", 0);
  assert(__pyx_arg_p); {
    __pyx_v_p = __pyx_PyFloat_AsDouble(__pyx_arg_p); if (unlikely((__pyx_v_p == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5437; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.norm_lp", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_24norm_lp(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((double)__pyx_v_p));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_24norm_lp(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, double __pyx_v_p) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("norm_lp", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorD_norm_lp(__pyx_v_self, __pyx_v_p, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.norm_lp", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5443
 *             sum+=pow(fabs(self.vals_ptr[i]),p)
 *         return pow(sum,1.0/p)
 *     def dotFull(self, numpy.ndarray[double,ndim=1] full):             # <<<<<<<<<<<<<<
 *         cdef double *full_ptr
 *         cdef unsigned int my_len=self.my_len
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_27dotFull(PyObject *__pyx_v_self, PyObject *__pyx_v_full); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_27dotFull(PyObject *__pyx_v_self, PyObject *__pyx_v_full) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dotFull (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_full), __pyx_ptype_5numpy_ndarray, 1, "full", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_26dotFull(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((PyArrayObject *)__pyx_v_full));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_26dotFull(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, PyArrayObject *__pyx_v_full) {
  double *__pyx_v_full_ptr;
  unsigned int __pyx_v_my_len;
  unsigned int __pyx_v_full_len;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_full;
  __Pyx_Buffer __pyx_pybuffer_full;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotFull", 0);
  __pyx_pybuffer_full.pybuffer.buf = NULL;
  __pyx_pybuffer_full.refcount = 0;
  __pyx_pybuffernd_full.data = NULL;
  __pyx_pybuffernd_full.rcbuffer = &__pyx_pybuffer_full;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_full.rcbuffer->pybuffer, (PyObject*)__pyx_v_full, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_full.diminfo[0].strides = __pyx_pybuffernd_full.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_full.diminfo[0].shape = __pyx_pybuffernd_full.rcbuffer->pybuffer.shape[0];

  /* "lurrn/sparsmat.pyx":5445
 *     def dotFull(self, numpy.ndarray[double,ndim=1] full):
 *         cdef double *full_ptr
 *         cdef unsigned int my_len=self.my_len             # <<<<<<<<<<<<<<
 *         cdef unsigned int full_len=len(full)
 *         # treat nonpresent values as 0
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  __pyx_v_my_len = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":5446
 *         cdef double *full_ptr
 *         cdef unsigned int my_len=self.my_len
 *         cdef unsigned int full_len=len(full)             # <<<<<<<<<<<<<<
 *         # treat nonpresent values as 0
 *         while my_len>0 and self.idx_ptr[my_len-1]>full_len:
 */
  __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_full)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_full_len = __pyx_t_2;

  /* "lurrn/sparsmat.pyx":5448
 *         cdef unsigned int full_len=len(full)
 *         # treat nonpresent values as 0
 *         while my_len>0 and self.idx_ptr[my_len-1]>full_len:             # <<<<<<<<<<<<<<
 *             my_len-=1
 *         full_ptr=<double*>full.data
 */
  while (1) {
    __pyx_t_4 = ((__pyx_v_my_len > 0) != 0);
    if (__pyx_t_4) {
    } else {
      __pyx_t_3 = __pyx_t_4;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_4 = (((__pyx_v_self->idx_ptr[(__pyx_v_my_len - 1)]) > __pyx_v_full_len) != 0);
    __pyx_t_3 = __pyx_t_4;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_3) break;

    /* "lurrn/sparsmat.pyx":5449
 *         # treat nonpresent values as 0
 *         while my_len>0 and self.idx_ptr[my_len-1]>full_len:
 *             my_len-=1             # <<<<<<<<<<<<<<
 *         full_ptr=<double*>full.data
 *         return self._dotFull_partial(full_ptr,my_len)
 */
    __pyx_v_my_len = (__pyx_v_my_len - 1);
  }

  /* "lurrn/sparsmat.pyx":5450
 *         while my_len>0 and self.idx_ptr[my_len-1]>full_len:
 *             my_len-=1
 *         full_ptr=<double*>full.data             # <<<<<<<<<<<<<<
 *         return self._dotFull_partial(full_ptr,my_len)
 *     def dotFull_check(self, numpy.ndarray[double,ndim=1] full):
 */
  __pyx_v_full_ptr = ((double *)__pyx_v_full->data);

  /* "lurrn/sparsmat.pyx":5451
 *             my_len-=1
 *         full_ptr=<double*>full.data
 *         return self._dotFull_partial(full_ptr,my_len)             # <<<<<<<<<<<<<<
 *     def dotFull_check(self, numpy.ndarray[double,ndim=1] full):
 *         cdef double *full_ptr
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = PyFloat_FromDouble(((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self->__pyx_vtab)->_dotFull_partial(__pyx_v_self, __pyx_v_full_ptr, __pyx_v_my_len)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5443
 *             sum+=pow(fabs(self.vals_ptr[i]),p)
 *         return pow(sum,1.0/p)
 *     def dotFull(self, numpy.ndarray[double,ndim=1] full):             # <<<<<<<<<<<<<<
 *         cdef double *full_ptr
 *         cdef unsigned int my_len=self.my_len
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_full.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.dotFull", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_full.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5452
 *         full_ptr=<double*>full.data
 *         return self._dotFull_partial(full_ptr,my_len)
 *     def dotFull_check(self, numpy.ndarray[double,ndim=1] full):             # <<<<<<<<<<<<<<
 *         cdef double *full_ptr
 *         cdef int my_len=self.my_len
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_29dotFull_check(PyObject *__pyx_v_self, PyObject *__pyx_v_full); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_29dotFull_check(PyObject *__pyx_v_self, PyObject *__pyx_v_full) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dotFull_check (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_full), __pyx_ptype_5numpy_ndarray, 1, "full", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_28dotFull_check(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((PyArrayObject *)__pyx_v_full));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_28dotFull_check(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, PyArrayObject *__pyx_v_full) {
  double *__pyx_v_full_ptr;
  CYTHON_UNUSED int __pyx_v_my_len;
  CYTHON_UNUSED int __pyx_v_full_len;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_full;
  __Pyx_Buffer __pyx_pybuffer_full;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  coordinate_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotFull_check", 0);
  __pyx_pybuffer_full.pybuffer.buf = NULL;
  __pyx_pybuffer_full.refcount = 0;
  __pyx_pybuffernd_full.data = NULL;
  __pyx_pybuffernd_full.rcbuffer = &__pyx_pybuffer_full;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_full.rcbuffer->pybuffer, (PyObject*)__pyx_v_full, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_full.diminfo[0].strides = __pyx_pybuffernd_full.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_full.diminfo[0].shape = __pyx_pybuffernd_full.rcbuffer->pybuffer.shape[0];

  /* "lurrn/sparsmat.pyx":5454
 *     def dotFull_check(self, numpy.ndarray[double,ndim=1] full):
 *         cdef double *full_ptr
 *         cdef int my_len=self.my_len             # <<<<<<<<<<<<<<
 *         cdef int full_len=len(full)
 *         # boundary check
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  __pyx_v_my_len = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":5455
 *         cdef double *full_ptr
 *         cdef int my_len=self.my_len
 *         cdef int full_len=len(full)             # <<<<<<<<<<<<<<
 *         # boundary check
 *         full[self.idx_ptr[self.my_len-1]]
 */
  __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_full)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_full_len = __pyx_t_2;

  /* "lurrn/sparsmat.pyx":5457
 *         cdef int full_len=len(full)
 *         # boundary check
 *         full[self.idx_ptr[self.my_len-1]]             # <<<<<<<<<<<<<<
 *         full_ptr=<double*>full.data
 *         return self._dotFull(full_ptr)
 */
  __pyx_t_3 = (__pyx_v_self->idx_ptr[(__pyx_v_self->my_len - 1)]);
  __pyx_t_4 = -1;
  if (unlikely(__pyx_t_3 >= (size_t)__pyx_pybuffernd_full.diminfo[0].shape)) __pyx_t_4 = 0;
  if (unlikely(__pyx_t_4 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_4);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_full.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_full.diminfo[0].strides));

  /* "lurrn/sparsmat.pyx":5458
 *         # boundary check
 *         full[self.idx_ptr[self.my_len-1]]
 *         full_ptr=<double*>full.data             # <<<<<<<<<<<<<<
 *         return self._dotFull(full_ptr)
 *     def dotMatrix(self, numpy.ndarray[double,ndim=2] full):
 */
  __pyx_v_full_ptr = ((double *)__pyx_v_full->data);

  /* "lurrn/sparsmat.pyx":5459
 *         full[self.idx_ptr[self.my_len-1]]
 *         full_ptr=<double*>full.data
 *         return self._dotFull(full_ptr)             # <<<<<<<<<<<<<<
 *     def dotMatrix(self, numpy.ndarray[double,ndim=2] full):
 *         cdef numpy.ndarray[double,ndim=1] result
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = PyFloat_FromDouble(((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self->__pyx_vtab)->_dotFull(__pyx_v_self, __pyx_v_full_ptr)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5452
 *         full_ptr=<double*>full.data
 *         return self._dotFull_partial(full_ptr,my_len)
 *     def dotFull_check(self, numpy.ndarray[double,ndim=1] full):             # <<<<<<<<<<<<<<
 *         cdef double *full_ptr
 *         cdef int my_len=self.my_len
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_full.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.dotFull_check", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_full.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5460
 *         full_ptr=<double*>full.data
 *         return self._dotFull(full_ptr)
 *     def dotMatrix(self, numpy.ndarray[double,ndim=2] full):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[double,ndim=1] result
 *         result = numpy.zeros(full.shape[1], numpy.float64)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_31dotMatrix(PyObject *__pyx_v_self, PyObject *__pyx_v_full); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_31dotMatrix(PyObject *__pyx_v_self, PyObject *__pyx_v_full) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dotMatrix (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_full), __pyx_ptype_5numpy_ndarray, 1, "full", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_30dotMatrix(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((PyArrayObject *)__pyx_v_full));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_30dotMatrix(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, PyArrayObject *__pyx_v_full) {
  PyArrayObject *__pyx_v_result = 0;
  long __pyx_v_i;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_full;
  __Pyx_Buffer __pyx_pybuffer_full;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  unsigned int __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dotMatrix", 0);
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
  __pyx_pybuffer_full.pybuffer.buf = NULL;
  __pyx_pybuffer_full.refcount = 0;
  __pyx_pybuffernd_full.data = NULL;
  __pyx_pybuffernd_full.rcbuffer = &__pyx_pybuffer_full;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_full.rcbuffer->pybuffer, (PyObject*)__pyx_v_full, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_full.diminfo[0].strides = __pyx_pybuffernd_full.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_full.diminfo[0].shape = __pyx_pybuffernd_full.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_full.diminfo[1].strides = __pyx_pybuffernd_full.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_full.diminfo[1].shape = __pyx_pybuffernd_full.rcbuffer->pybuffer.shape[1];

  /* "lurrn/sparsmat.pyx":5462
 *     def dotMatrix(self, numpy.ndarray[double,ndim=2] full):
 *         cdef numpy.ndarray[double,ndim=1] result
 *         result = numpy.zeros(full.shape[1], numpy.float64)             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result += full[self.idx_ptr[i]] * self.vals_ptr[i]
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_full->dimensions[1])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __pyx_v_result = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5463
 *         cdef numpy.ndarray[double,ndim=1] result
 *         result = numpy.zeros(full.shape[1], numpy.float64)
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result += full[self.idx_ptr[i]] * self.vals_ptr[i]
 *         return result
 */
  __pyx_t_13 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_13; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5464
 *         result = numpy.zeros(full.shape[1], numpy.float64)
 *         for i from 0<=i<self.my_len:
 *             result += full[self.idx_ptr[i]] * self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *         return result
 *     cdef void _axpy(self, double *x_ptr, double a):
 */
    __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_full), (__pyx_v_self->idx_ptr[__pyx_v_i]), coordinate_t, 0, __Pyx_PyInt_From_coordinate_t, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5464; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyFloat_FromDouble((__pyx_v_self->vals_ptr[__pyx_v_i])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = PyNumber_Multiply(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), __pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = ((PyArrayObject *)__pyx_t_3);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
      __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_9 < 0)) {
        PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_12, __pyx_t_11, __pyx_t_10);
        }
      }
      __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_8 = 0;
    __Pyx_DECREF_SET(__pyx_v_result, ((PyArrayObject *)__pyx_t_3));
    __pyx_t_3 = 0;
  }

  /* "lurrn/sparsmat.pyx":5465
 *         for i from 0<=i<self.my_len:
 *             result += full[self.idx_ptr[i]] * self.vals_ptr[i]
 *         return result             # <<<<<<<<<<<<<<
 *     cdef void _axpy(self, double *x_ptr, double a):
 *         for i from 0<=i<self.my_len:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5460
 *         full_ptr=<double*>full.data
 *         return self._dotFull(full_ptr)
 *     def dotMatrix(self, numpy.ndarray[double,ndim=2] full):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[double,ndim=1] result
 *         result = numpy.zeros(full.shape[1], numpy.float64)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_full.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.dotMatrix", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_full.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5466
 *             result += full[self.idx_ptr[i]] * self.vals_ptr[i]
 *         return result
 *     cdef void _axpy(self, double *x_ptr, double a):             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             x_ptr[self.idx_ptr[i]]+=a*self.vals_ptr[i]
 */

static void __pyx_f_5lurrn_8sparsmat_13SparseVectorD__axpy(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, double *__pyx_v_x_ptr, double __pyx_v_a) {
  long __pyx_v_i;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  coordinate_t __pyx_t_2;
  __Pyx_RefNannySetupContext("_axpy", 0);

  /* "lurrn/sparsmat.pyx":5467
 *         return result
 *     cdef void _axpy(self, double *x_ptr, double a):
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             x_ptr[self.idx_ptr[i]]+=a*self.vals_ptr[i]
 *     def axpy(self, numpy.ndarray[double,ndim=1] x, double a=1):
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5468
 *     cdef void _axpy(self, double *x_ptr, double a):
 *         for i from 0<=i<self.my_len:
 *             x_ptr[self.idx_ptr[i]]+=a*self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *     def axpy(self, numpy.ndarray[double,ndim=1] x, double a=1):
 *         # boundary check
 */
    __pyx_t_2 = (__pyx_v_self->idx_ptr[__pyx_v_i]);
    (__pyx_v_x_ptr[__pyx_t_2]) = ((__pyx_v_x_ptr[__pyx_t_2]) + (__pyx_v_a * (__pyx_v_self->vals_ptr[__pyx_v_i])));
  }

  /* "lurrn/sparsmat.pyx":5466
 *             result += full[self.idx_ptr[i]] * self.vals_ptr[i]
 *         return result
 *     cdef void _axpy(self, double *x_ptr, double a):             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             x_ptr[self.idx_ptr[i]]+=a*self.vals_ptr[i]
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":5469
 *         for i from 0<=i<self.my_len:
 *             x_ptr[self.idx_ptr[i]]+=a*self.vals_ptr[i]
 *     def axpy(self, numpy.ndarray[double,ndim=1] x, double a=1):             # <<<<<<<<<<<<<<
 *         # boundary check
 *         x[self.idx_ptr[self.my_len-1]]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_33axpy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_33axpy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_x = 0;
  double __pyx_v_a;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("axpy (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_a,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "axpy") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5469; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_x = ((PyArrayObject *)values[0]);
    if (values[1]) {
      __pyx_v_a = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_a == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5469; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_a = ((double)1.0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("axpy", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5469; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.axpy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_32axpy(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), __pyx_v_x, __pyx_v_a);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_32axpy(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, PyArrayObject *__pyx_v_x, double __pyx_v_a) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_x;
  __Pyx_Buffer __pyx_pybuffer_x;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  coordinate_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("axpy", 0);
  __pyx_pybuffer_x.pybuffer.buf = NULL;
  __pyx_pybuffer_x.refcount = 0;
  __pyx_pybuffernd_x.data = NULL;
  __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0];

  /* "lurrn/sparsmat.pyx":5471
 *     def axpy(self, numpy.ndarray[double,ndim=1] x, double a=1):
 *         # boundary check
 *         x[self.idx_ptr[self.my_len-1]]             # <<<<<<<<<<<<<<
 *         self._axpy(<double *>x.data,a)
 *     cpdef double sqdist(self, SparseVectorD other):
 */
  __pyx_t_1 = (__pyx_v_self->idx_ptr[(__pyx_v_self->my_len - 1)]);
  __pyx_t_2 = -1;
  if (unlikely(__pyx_t_1 >= (size_t)__pyx_pybuffernd_x.diminfo[0].shape)) __pyx_t_2 = 0;
  if (unlikely(__pyx_t_2 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_2);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_x.diminfo[0].strides));

  /* "lurrn/sparsmat.pyx":5472
 *         # boundary check
 *         x[self.idx_ptr[self.my_len-1]]
 *         self._axpy(<double *>x.data,a)             # <<<<<<<<<<<<<<
 *     cpdef double sqdist(self, SparseVectorD other):
 *         """computes ||x-y||^2"""
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self->__pyx_vtab)->_axpy(__pyx_v_self, ((double *)__pyx_v_x->data), __pyx_v_a);

  /* "lurrn/sparsmat.pyx":5469
 *         for i from 0<=i<self.my_len:
 *             x_ptr[self.idx_ptr[i]]+=a*self.vals_ptr[i]
 *     def axpy(self, numpy.ndarray[double,ndim=1] x, double a=1):             # <<<<<<<<<<<<<<
 *         # boundary check
 *         x[self.idx_ptr[self.my_len-1]]
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.axpy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5473
 *         x[self.idx_ptr[self.my_len-1]]
 *         self._axpy(<double *>x.data,a)
 *     cpdef double sqdist(self, SparseVectorD other):             # <<<<<<<<<<<<<<
 *         """computes ||x-y||^2"""
 *         cdef double s=0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_35sqdist(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static double __pyx_f_5lurrn_8sparsmat_13SparseVectorD_sqdist(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other, int __pyx_skip_dispatch) {
  double __pyx_v_s;
  double __pyx_v_val;
  int __pyx_v_i1;
  int __pyx_v_i2;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sqdist", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_sqdist); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_35sqdist)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5475
 *     cpdef double sqdist(self, SparseVectorD other):
 *         """computes ||x-y||^2"""
 *         cdef double s=0             # <<<<<<<<<<<<<<
 *         cdef double val
 *         cdef int i1=0,i2=0
 */
  __pyx_v_s = 0.0;

  /* "lurrn/sparsmat.pyx":5477
 *         cdef double s=0
 *         cdef double val
 *         cdef int i1=0,i2=0             # <<<<<<<<<<<<<<
 *         while i1<self.my_len and i2<other.my_len:
 *             if self.idx_ptr[i1]<other.idx_ptr[i2]:
 */
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":5478
 *         cdef double val
 *         cdef int i1=0,i2=0
 *         while i1<self.my_len and i2<other.my_len:             # <<<<<<<<<<<<<<
 *             if self.idx_ptr[i1]<other.idx_ptr[i2]:
 *                 val=self.vals_ptr[i1]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i1 < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_i2 < __pyx_v_other->my_len) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":5479
 *         cdef int i1=0,i2=0
 *         while i1<self.my_len and i2<other.my_len:
 *             if self.idx_ptr[i1]<other.idx_ptr[i2]:             # <<<<<<<<<<<<<<
 *                 val=self.vals_ptr[i1]
 *                 s+=val*val
 */
    __pyx_t_7 = (((__pyx_v_self->idx_ptr[__pyx_v_i1]) < (__pyx_v_other->idx_ptr[__pyx_v_i2])) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":5480
 *         while i1<self.my_len and i2<other.my_len:
 *             if self.idx_ptr[i1]<other.idx_ptr[i2]:
 *                 val=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                 s+=val*val
 *                 i1+=1
 */
      __pyx_v_val = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

      /* "lurrn/sparsmat.pyx":5481
 *             if self.idx_ptr[i1]<other.idx_ptr[i2]:
 *                 val=self.vals_ptr[i1]
 *                 s+=val*val             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             elif self.idx_ptr[i1]>other.idx_ptr[i2]:
 */
      __pyx_v_s = (__pyx_v_s + (__pyx_v_val * __pyx_v_val));

      /* "lurrn/sparsmat.pyx":5482
 *                 val=self.vals_ptr[i1]
 *                 s+=val*val
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             elif self.idx_ptr[i1]>other.idx_ptr[i2]:
 *                 val=other.vals_ptr[i2]
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L7;
    }

    /* "lurrn/sparsmat.pyx":5483
 *                 s+=val*val
 *                 i1+=1
 *             elif self.idx_ptr[i1]>other.idx_ptr[i2]:             # <<<<<<<<<<<<<<
 *                 val=other.vals_ptr[i2]
 *                 s+=val*val
 */
    __pyx_t_7 = (((__pyx_v_self->idx_ptr[__pyx_v_i1]) > (__pyx_v_other->idx_ptr[__pyx_v_i2])) != 0);
    if (__pyx_t_7) {

      /* "lurrn/sparsmat.pyx":5484
 *                 i1+=1
 *             elif self.idx_ptr[i1]>other.idx_ptr[i2]:
 *                 val=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 s+=val*val
 *                 i2+=1
 */
      __pyx_v_val = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":5485
 *             elif self.idx_ptr[i1]>other.idx_ptr[i2]:
 *                 val=other.vals_ptr[i2]
 *                 s+=val*val             # <<<<<<<<<<<<<<
 *                 i2+=1
 *             else:
 */
      __pyx_v_s = (__pyx_v_s + (__pyx_v_val * __pyx_v_val));

      /* "lurrn/sparsmat.pyx":5486
 *                 val=other.vals_ptr[i2]
 *                 s+=val*val
 *                 i2+=1             # <<<<<<<<<<<<<<
 *             else:
 *                 val=self.vals_ptr[i1]-other.vals_ptr[i2]
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":5488
 *                 i2+=1
 *             else:
 *                 val=self.vals_ptr[i1]-other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 s+=val*val
 *                 i1+=1
 */
      __pyx_v_val = ((__pyx_v_self->vals_ptr[__pyx_v_i1]) - (__pyx_v_other->vals_ptr[__pyx_v_i2]));

      /* "lurrn/sparsmat.pyx":5489
 *             else:
 *                 val=self.vals_ptr[i1]-other.vals_ptr[i2]
 *                 s+=val*val             # <<<<<<<<<<<<<<
 *                 i1+=1
 *                 i2+=1
 */
      __pyx_v_s = (__pyx_v_s + (__pyx_v_val * __pyx_v_val));

      /* "lurrn/sparsmat.pyx":5490
 *                 val=self.vals_ptr[i1]-other.vals_ptr[i2]
 *                 s+=val*val
 *                 i1+=1             # <<<<<<<<<<<<<<
 *                 i2+=1
 *         while i1<self.my_len:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);

      /* "lurrn/sparsmat.pyx":5491
 *                 s+=val*val
 *                 i1+=1
 *                 i2+=1             # <<<<<<<<<<<<<<
 *         while i1<self.my_len:
 *             val=self.vals_ptr[i1]
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
    }
    __pyx_L7:;
  }

  /* "lurrn/sparsmat.pyx":5492
 *                 i1+=1
 *                 i2+=1
 *         while i1<self.my_len:             # <<<<<<<<<<<<<<
 *             val=self.vals_ptr[i1]
 *             s+=val*val
 */
  while (1) {
    __pyx_t_7 = ((__pyx_v_i1 < __pyx_v_self->my_len) != 0);
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":5493
 *                 i2+=1
 *         while i1<self.my_len:
 *             val=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *             s+=val*val
 *             i1+=1
 */
    __pyx_v_val = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":5494
 *         while i1<self.my_len:
 *             val=self.vals_ptr[i1]
 *             s+=val*val             # <<<<<<<<<<<<<<
 *             i1+=1
 *         while i2<other.my_len:
 */
    __pyx_v_s = (__pyx_v_s + (__pyx_v_val * __pyx_v_val));

    /* "lurrn/sparsmat.pyx":5495
 *             val=self.vals_ptr[i1]
 *             s+=val*val
 *             i1+=1             # <<<<<<<<<<<<<<
 *         while i2<other.my_len:
 *             val=other.vals_ptr[i2]
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);
  }

  /* "lurrn/sparsmat.pyx":5496
 *             s+=val*val
 *             i1+=1
 *         while i2<other.my_len:             # <<<<<<<<<<<<<<
 *             val=other.vals_ptr[i2]
 *             s+=val*val
 */
  while (1) {
    __pyx_t_7 = ((__pyx_v_i2 < __pyx_v_other->my_len) != 0);
    if (!__pyx_t_7) break;

    /* "lurrn/sparsmat.pyx":5497
 *             i1+=1
 *         while i2<other.my_len:
 *             val=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *             s+=val*val
 *             i2+=1
 */
    __pyx_v_val = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":5498
 *         while i2<other.my_len:
 *             val=other.vals_ptr[i2]
 *             s+=val*val             # <<<<<<<<<<<<<<
 *             i2+=1
 *         return s
 */
    __pyx_v_s = (__pyx_v_s + (__pyx_v_val * __pyx_v_val));

    /* "lurrn/sparsmat.pyx":5499
 *             val=other.vals_ptr[i2]
 *             s+=val*val
 *             i2+=1             # <<<<<<<<<<<<<<
 *         return s
 *     def write_pairs(self, f, delim=':'):
 */
    __pyx_v_i2 = (__pyx_v_i2 + 1);
  }

  /* "lurrn/sparsmat.pyx":5500
 *             s+=val*val
 *             i2+=1
 *         return s             # <<<<<<<<<<<<<<
 *     def write_pairs(self, f, delim=':'):
 *         cdef int i
 */
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5473
 *         x[self.idx_ptr[self.my_len-1]]
 *         self._axpy(<double *>x.data,a)
 *     cpdef double sqdist(self, SparseVectorD other):             # <<<<<<<<<<<<<<
 *         """computes ||x-y||^2"""
 *         cdef double s=0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorD.sqdist", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_35sqdist(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_5lurrn_8sparsmat_13SparseVectorD_34sqdist[] = "computes ||x-y||^2";
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_35sqdist(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sqdist (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorD, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_34sqdist(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_34sqdist(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sqdist", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_5lurrn_8sparsmat_13SparseVectorD_sqdist(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.sqdist", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5501
 *             i2+=1
 *         return s
 *     def write_pairs(self, f, delim=':'):             # <<<<<<<<<<<<<<
 *         cdef int i
 *         w_func=f.write
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_37write_pairs(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_37write_pairs(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_f = 0;
  PyObject *__pyx_v_delim = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_pairs (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_f,&__pyx_n_s_delim,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_kp_s__24);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_f)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_delim);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_pairs") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5501; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_f = values[0];
    __pyx_v_delim = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_pairs", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5501; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.write_pairs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_36write_pairs(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), __pyx_v_f, __pyx_v_delim);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_36write_pairs(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, PyObject *__pyx_v_f, PyObject *__pyx_v_delim) {
  int __pyx_v_i;
  PyObject *__pyx_v_w_func = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  unsigned int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("write_pairs", 0);

  /* "lurrn/sparsmat.pyx":5503
 *     def write_pairs(self, f, delim=':'):
 *         cdef int i
 *         w_func=f.write             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             # svmlight does not want 0 as index
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_w_func = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5504
 *         cdef int i
 *         w_func=f.write
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             # svmlight does not want 0 as index
 *             w_func(' %d%s%s'%(self.idx_ptr[i]+1,delim,self.vals_ptr[i]))
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5506
 *         for i from 0<=i<self.my_len:
 *             # svmlight does not want 0 as index
 *             w_func(' %d%s%s'%(self.idx_ptr[i]+1,delim,self.vals_ptr[i]))             # <<<<<<<<<<<<<<
 *     def __imul__(self, double a):
 *         cdef coordinate_t i
 */
    __pyx_t_3 = __Pyx_PyInt_From_long(((__pyx_v_self->idx_ptr[__pyx_v_i]) + 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyFloat_FromDouble((__pyx_v_self->vals_ptr[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_delim);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_delim);
    __Pyx_GIVEREF(__pyx_v_delim);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_d_s_s, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_INCREF(__pyx_v_w_func);
    __pyx_t_5 = __pyx_v_w_func; __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5501
 *             i2+=1
 *         return s
 *     def write_pairs(self, f, delim=':'):             # <<<<<<<<<<<<<<
 *         cdef int i
 *         w_func=f.write
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.write_pairs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_w_func);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5507
 *             # svmlight does not want 0 as index
 *             w_func(' %d%s%s'%(self.idx_ptr[i]+1,delim,self.vals_ptr[i]))
 *     def __imul__(self, double a):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_39__imul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_a); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_39__imul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_a) {
  double __pyx_v_a;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__imul__ (wrapper)", 0);
  assert(__pyx_arg_a); {
    __pyx_v_a = __pyx_PyFloat_AsDouble(__pyx_arg_a); if (unlikely((__pyx_v_a == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5507; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.__imul__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_38__imul__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((double)__pyx_v_a));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_38__imul__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, double __pyx_v_a) {
  coordinate_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  coordinate_t __pyx_t_2;
  __Pyx_RefNannySetupContext("__imul__", 0);

  /* "lurrn/sparsmat.pyx":5509
 *     def __imul__(self, double a):
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             self.vals_ptr[i] *= a
 *         return self
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5510
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 *             self.vals_ptr[i] *= a             # <<<<<<<<<<<<<<
 *         return self
 *     def __idiv__(self, double a):
 */
    __pyx_t_2 = __pyx_v_i;
    (__pyx_v_self->vals_ptr[__pyx_t_2]) = ((__pyx_v_self->vals_ptr[__pyx_t_2]) * __pyx_v_a);
  }

  /* "lurrn/sparsmat.pyx":5511
 *         for i from 0<=i<self.my_len:
 *             self.vals_ptr[i] *= a
 *         return self             # <<<<<<<<<<<<<<
 *     def __idiv__(self, double a):
 *         cdef coordinate_t i
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5507
 *             # svmlight does not want 0 as index
 *             w_func(' %d%s%s'%(self.idx_ptr[i]+1,delim,self.vals_ptr[i]))
 *     def __imul__(self, double a):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5512
 *             self.vals_ptr[i] *= a
 *         return self
 *     def __idiv__(self, double a):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 */

/* Python wrapper */
#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_41__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_a); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_41__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_a) {
  double __pyx_v_a;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__idiv__ (wrapper)", 0);
  assert(__pyx_arg_a); {
    __pyx_v_a = __pyx_PyFloat_AsDouble(__pyx_arg_a); if (unlikely((__pyx_v_a == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.__idiv__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_40__idiv__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((double)__pyx_v_a));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_40__idiv__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, double __pyx_v_a) {
  coordinate_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  coordinate_t __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__idiv__", 0);

  /* "lurrn/sparsmat.pyx":5514
 *     def __idiv__(self, double a):
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             self.vals_ptr[i] /= a
 *         return self
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5515
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 *             self.vals_ptr[i] /= a             # <<<<<<<<<<<<<<
 *         return self
 *     cpdef SparseVectorD min_vals(self, SparseVectorD other):
 */
    __pyx_t_2 = __pyx_v_i;
    if (unlikely(__pyx_v_a == 0)) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      #ifdef WITH_THREAD
      PyGILState_Release(__pyx_gilstate_save);
      #endif
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    (__pyx_v_self->vals_ptr[__pyx_t_2]) = ((__pyx_v_self->vals_ptr[__pyx_t_2]) / __pyx_v_a);
  }

  /* "lurrn/sparsmat.pyx":5516
 *         for i from 0<=i<self.my_len:
 *             self.vals_ptr[i] /= a
 *         return self             # <<<<<<<<<<<<<<
 *     cpdef SparseVectorD min_vals(self, SparseVectorD other):
 *         cdef SparseVectorD result
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5512
 *             self.vals_ptr[i] *= a
 *         return self
 *     def __idiv__(self, double a):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.__idiv__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

/* "lurrn/sparsmat.pyx":5517
 *             self.vals_ptr[i] /= a
 *         return self
 *     cpdef SparseVectorD min_vals(self, SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorD result
 *         cdef coordinate_t i1, i2, k, idx1, idx2
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_43min_vals(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_f_5lurrn_8sparsmat_13SparseVectorD_min_vals(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other, int __pyx_skip_dispatch) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_result = 0;
  coordinate_t __pyx_v_i1;
  coordinate_t __pyx_v_i2;
  coordinate_t __pyx_v_k;
  coordinate_t __pyx_v_idx1;
  coordinate_t __pyx_v_idx2;
  double __pyx_v_val1;
  double __pyx_v_val2;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  unsigned int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("min_vals", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_min_vals); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_43min_vals)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_SparseVectorD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5520
 *         cdef SparseVectorD result
 *         cdef coordinate_t i1, i2, k, idx1, idx2
 *         result=SparseVectorD()             # <<<<<<<<<<<<<<
 *         if self.my_len<other.my_len:
 *             result.my_len=self.my_len
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorD)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5521
 *         cdef coordinate_t i1, i2, k, idx1, idx2
 *         result=SparseVectorD()
 *         if self.my_len<other.my_len:             # <<<<<<<<<<<<<<
 *             result.my_len=self.my_len
 *         else:
 */
  __pyx_t_6 = ((__pyx_v_self->my_len < __pyx_v_other->my_len) != 0);
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":5522
 *         result=SparseVectorD()
 *         if self.my_len<other.my_len:
 *             result.my_len=self.my_len             # <<<<<<<<<<<<<<
 *         else:
 *             result.my_len=other.my_len
 */
    __pyx_t_7 = __pyx_v_self->my_len;
    __pyx_v_result->my_len = __pyx_t_7;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":5524
 *             result.my_len=self.my_len
 *         else:
 *             result.my_len=other.my_len             # <<<<<<<<<<<<<<
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))
 */
    __pyx_t_7 = __pyx_v_other->my_len;
    __pyx_v_result->my_len = __pyx_t_7;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":5525
 *         else:
 *             result.my_len=other.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))
 *         i1=i2=k=0
 */
  __pyx_v_result->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":5526
 *             result.my_len=other.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))             # <<<<<<<<<<<<<<
 *         i1=i2=k=0
 *         while i1<self.my_len and i2<other.my_len:
 */
  __pyx_v_result->vals_ptr = ((double *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(double)))));

  /* "lurrn/sparsmat.pyx":5527
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))
 *         i1=i2=k=0             # <<<<<<<<<<<<<<
 *         while i1<self.my_len and i2<other.my_len:
 *            idx1=self.idx_ptr[i1]
 */
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":5528
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))
 *         i1=i2=k=0
 *         while i1<self.my_len and i2<other.my_len:             # <<<<<<<<<<<<<<
 *            idx1=self.idx_ptr[i1]
 *            idx2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_8 = ((__pyx_v_i1 < __pyx_v_self->my_len) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_6 = __pyx_t_8;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_i2 < __pyx_v_other->my_len) != 0);
    __pyx_t_6 = __pyx_t_8;
    __pyx_L6_bool_binop_done:;
    if (!__pyx_t_6) break;

    /* "lurrn/sparsmat.pyx":5529
 *         i1=i2=k=0
 *         while i1<self.my_len and i2<other.my_len:
 *            idx1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *            idx2=other.idx_ptr[i2]
 *            if idx1<idx2:
 */
    __pyx_v_idx1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":5530
 *         while i1<self.my_len and i2<other.my_len:
 *            idx1=self.idx_ptr[i1]
 *            idx2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *            if idx1<idx2:
 *                i1+=1
 */
    __pyx_v_idx2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":5531
 *            idx1=self.idx_ptr[i1]
 *            idx2=other.idx_ptr[i2]
 *            if idx1<idx2:             # <<<<<<<<<<<<<<
 *                i1+=1
 *            elif idx1>idx2:
 */
    __pyx_t_6 = ((__pyx_v_idx1 < __pyx_v_idx2) != 0);
    if (__pyx_t_6) {

      /* "lurrn/sparsmat.pyx":5532
 *            idx2=other.idx_ptr[i2]
 *            if idx1<idx2:
 *                i1+=1             # <<<<<<<<<<<<<<
 *            elif idx1>idx2:
 *                i2+=1
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L8;
    }

    /* "lurrn/sparsmat.pyx":5533
 *            if idx1<idx2:
 *                i1+=1
 *            elif idx1>idx2:             # <<<<<<<<<<<<<<
 *                i2+=1
 *            else:
 */
    __pyx_t_6 = ((__pyx_v_idx1 > __pyx_v_idx2) != 0);
    if (__pyx_t_6) {

      /* "lurrn/sparsmat.pyx":5534
 *                i1+=1
 *            elif idx1>idx2:
 *                i2+=1             # <<<<<<<<<<<<<<
 *            else:
 *                result.idx_ptr[k]=idx1
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      goto __pyx_L8;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":5536
 *                i2+=1
 *            else:
 *                result.idx_ptr[k]=idx1             # <<<<<<<<<<<<<<
 *                val1=self.vals_ptr[i1]
 *                val2=other.vals_ptr[i2]
 */
      (__pyx_v_result->idx_ptr[__pyx_v_k]) = __pyx_v_idx1;

      /* "lurrn/sparsmat.pyx":5537
 *            else:
 *                result.idx_ptr[k]=idx1
 *                val1=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                val2=other.vals_ptr[i2]
 *                if val1<val2:
 */
      __pyx_v_val1 = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

      /* "lurrn/sparsmat.pyx":5538
 *                result.idx_ptr[k]=idx1
 *                val1=self.vals_ptr[i1]
 *                val2=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                if val1<val2:
 *                    result.vals_ptr[k]=val1
 */
      __pyx_v_val2 = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":5539
 *                val1=self.vals_ptr[i1]
 *                val2=other.vals_ptr[i2]
 *                if val1<val2:             # <<<<<<<<<<<<<<
 *                    result.vals_ptr[k]=val1
 *                else:
 */
      __pyx_t_6 = ((__pyx_v_val1 < __pyx_v_val2) != 0);
      if (__pyx_t_6) {

        /* "lurrn/sparsmat.pyx":5540
 *                val2=other.vals_ptr[i2]
 *                if val1<val2:
 *                    result.vals_ptr[k]=val1             # <<<<<<<<<<<<<<
 *                else:
 *                    result.vals_ptr[k]=val2
 */
        (__pyx_v_result->vals_ptr[__pyx_v_k]) = __pyx_v_val1;
        goto __pyx_L9;
      }
      /*else*/ {

        /* "lurrn/sparsmat.pyx":5542
 *                    result.vals_ptr[k]=val1
 *                else:
 *                    result.vals_ptr[k]=val2             # <<<<<<<<<<<<<<
 *                i1+=1
 *                i2+=1
 */
        (__pyx_v_result->vals_ptr[__pyx_v_k]) = __pyx_v_val2;
      }
      __pyx_L9:;

      /* "lurrn/sparsmat.pyx":5543
 *                else:
 *                    result.vals_ptr[k]=val2
 *                i1+=1             # <<<<<<<<<<<<<<
 *                i2+=1
 *                k+=1
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);

      /* "lurrn/sparsmat.pyx":5544
 *                    result.vals_ptr[k]=val2
 *                i1+=1
 *                i2+=1             # <<<<<<<<<<<<<<
 *                k+=1
 *         result.my_len=k
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":5545
 *                i1+=1
 *                i2+=1
 *                k+=1             # <<<<<<<<<<<<<<
 *         result.my_len=k
 *         return result
 */
      __pyx_v_k = (__pyx_v_k + 1);
    }
    __pyx_L8:;
  }

  /* "lurrn/sparsmat.pyx":5546
 *                i2+=1
 *                k+=1
 *         result.my_len=k             # <<<<<<<<<<<<<<
 *         return result
 *     def scale_array(SparseVectorD self, numpy.ndarray[double, ndim=1] a):
 */
  __pyx_v_result->my_len = __pyx_v_k;

  /* "lurrn/sparsmat.pyx":5547
 *                k+=1
 *         result.my_len=k
 *         return result             # <<<<<<<<<<<<<<
 *     def scale_array(SparseVectorD self, numpy.ndarray[double, ndim=1] a):
 *         cdef SparseVectorD result
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5517
 *             self.vals_ptr[i] /= a
 *         return self
 *     cpdef SparseVectorD min_vals(self, SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorD result
 *         cdef coordinate_t i1, i2, k, idx1, idx2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.min_vals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_43min_vals(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_43min_vals(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("min_vals (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorD, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_42min_vals(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_42min_vals(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("min_vals", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_13SparseVectorD_min_vals(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.min_vals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5548
 *         result.my_len=k
 *         return result
 *     def scale_array(SparseVectorD self, numpy.ndarray[double, ndim=1] a):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorD result
 *         cdef coordinate_t i
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_45scale_array(PyObject *__pyx_v_self, PyObject *__pyx_v_a); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_45scale_array(PyObject *__pyx_v_self, PyObject *__pyx_v_a) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("scale_array (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_5numpy_ndarray, 1, "a", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_44scale_array(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((PyArrayObject *)__pyx_v_a));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_44scale_array(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, PyArrayObject *__pyx_v_a) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_result = 0;
  coordinate_t __pyx_v_i;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_a;
  __Pyx_Buffer __pyx_pybuffer_a;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  unsigned int __pyx_t_2;
  coordinate_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("scale_array", 0);
  __pyx_pybuffer_a.pybuffer.buf = NULL;
  __pyx_pybuffer_a.refcount = 0;
  __pyx_pybuffernd_a.data = NULL;
  __pyx_pybuffernd_a.rcbuffer = &__pyx_pybuffer_a;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_a.rcbuffer->pybuffer, (PyObject*)__pyx_v_a, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_a.diminfo[0].strides = __pyx_pybuffernd_a.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_a.diminfo[0].shape = __pyx_pybuffernd_a.rcbuffer->pybuffer.shape[0];

  /* "lurrn/sparsmat.pyx":5551
 *         cdef SparseVectorD result
 *         cdef coordinate_t i
 *         result=SparseVectorD()             # <<<<<<<<<<<<<<
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorD)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5552
 *         cdef coordinate_t i
 *         result=SparseVectorD()
 *         result.my_len=self.my_len             # <<<<<<<<<<<<<<
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  __pyx_v_result->my_len = __pyx_t_2;

  /* "lurrn/sparsmat.pyx":5553
 *         result=SparseVectorD()
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_result->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":5554
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]
 */
  __pyx_v_result->vals_ptr = ((double *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(double)))));

  /* "lurrn/sparsmat.pyx":5555
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result.idx_ptr[i]=self.idx_ptr[i]
 *         for i from 0<=i<self.my_len:
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5556
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]*a[self.idx_ptr[i]]
 */
    (__pyx_v_result->idx_ptr[__pyx_v_i]) = (__pyx_v_self->idx_ptr[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":5557
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result.vals_ptr[i]=self.vals_ptr[i]*a[self.idx_ptr[i]]
 *         return result
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5558
 *             result.idx_ptr[i]=self.idx_ptr[i]
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]*a[self.idx_ptr[i]]             # <<<<<<<<<<<<<<
 *         return result
 *     def __div__(SparseVectorD self, double a):
 */
    __pyx_t_3 = (__pyx_v_self->idx_ptr[__pyx_v_i]);
    __pyx_t_4 = -1;
    if (unlikely(__pyx_t_3 >= (size_t)__pyx_pybuffernd_a.diminfo[0].shape)) __pyx_t_4 = 0;
    if (unlikely(__pyx_t_4 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_4);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    (__pyx_v_result->vals_ptr[__pyx_v_i]) = ((__pyx_v_self->vals_ptr[__pyx_v_i]) * (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_a.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_a.diminfo[0].strides)));
  }

  /* "lurrn/sparsmat.pyx":5559
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]*a[self.idx_ptr[i]]
 *         return result             # <<<<<<<<<<<<<<
 *     def __div__(SparseVectorD self, double a):
 *         cdef SparseVectorD result
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5548
 *         result.my_len=k
 *         return result
 *     def scale_array(SparseVectorD self, numpy.ndarray[double, ndim=1] a):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorD result
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_a.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.scale_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_a.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5560
 *             result.vals_ptr[i]=self.vals_ptr[i]*a[self.idx_ptr[i]]
 *         return result
 *     def __div__(SparseVectorD self, double a):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorD result
 *         cdef coordinate_t i
 */

/* Python wrapper */
#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_47__div__(PyObject *__pyx_v_self, PyObject *__pyx_arg_a); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_47__div__(PyObject *__pyx_v_self, PyObject *__pyx_arg_a) {
  double __pyx_v_a;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__div__ (wrapper)", 0);
  assert(__pyx_arg_a); {
    __pyx_v_a = __pyx_PyFloat_AsDouble(__pyx_arg_a); if (unlikely((__pyx_v_a == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5560; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.__div__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_SparseVectorD, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_46__div__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((double)__pyx_v_a));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_46__div__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, double __pyx_v_a) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_result = 0;
  coordinate_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  unsigned int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__div__", 0);

  /* "lurrn/sparsmat.pyx":5563
 *         cdef SparseVectorD result
 *         cdef coordinate_t i
 *         result=SparseVectorD()             # <<<<<<<<<<<<<<
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorD)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5564
 *         cdef coordinate_t i
 *         result=SparseVectorD()
 *         result.my_len=self.my_len             # <<<<<<<<<<<<<<
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  __pyx_v_result->my_len = __pyx_t_2;

  /* "lurrn/sparsmat.pyx":5565
 *         result=SparseVectorD()
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_result->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":5566
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]
 */
  __pyx_v_result->vals_ptr = ((double *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(double)))));

  /* "lurrn/sparsmat.pyx":5567
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result.idx_ptr[i]=self.idx_ptr[i]
 *         for i from 0<=i<self.my_len:
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5568
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]/a
 */
    (__pyx_v_result->idx_ptr[__pyx_v_i]) = (__pyx_v_self->idx_ptr[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":5569
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result.vals_ptr[i]=self.vals_ptr[i]/a
 *         return result
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5570
 *             result.idx_ptr[i]=self.idx_ptr[i]
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]/a             # <<<<<<<<<<<<<<
 *         return result
 *     def __len__(self):
 */
    if (unlikely(__pyx_v_a == 0)) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      #ifdef WITH_THREAD
      PyGILState_Release(__pyx_gilstate_save);
      #endif
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    (__pyx_v_result->vals_ptr[__pyx_v_i]) = ((__pyx_v_self->vals_ptr[__pyx_v_i]) / __pyx_v_a);
  }

  /* "lurrn/sparsmat.pyx":5571
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]/a
 *         return result             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return self.my_len
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5560
 *             result.vals_ptr[i]=self.vals_ptr[i]*a[self.idx_ptr[i]]
 *         return result
 *     def __div__(SparseVectorD self, double a):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorD result
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.__div__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

/* "lurrn/sparsmat.pyx":5572
 *             result.vals_ptr[i]=self.vals_ptr[i]/a
 *         return result
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.my_len
 *     def __add__(SparseVectorD self,SparseVectorD other):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_49__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_49__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_48__len__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_48__len__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":5573
 *         return result
 *     def __len__(self):
 *         return self.my_len             # <<<<<<<<<<<<<<
 *     def __add__(SparseVectorD self,SparseVectorD other):
 *         cdef coordinate_t *new_idx
 */
  __pyx_r = __pyx_v_self->my_len;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5572
 *             result.vals_ptr[i]=self.vals_ptr[i]/a
 *         return result
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.my_len
 *     def __add__(SparseVectorD self,SparseVectorD other):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5574
 *     def __len__(self):
 *         return self.my_len
 *     def __add__(SparseVectorD self,SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *new_idx
 *         cdef double *new_vals
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_51__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_51__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_SparseVectorD, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorD, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_50__add__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_50__add__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other) {
  coordinate_t *__pyx_v_new_idx;
  double *__pyx_v_new_vals;
  coordinate_t __pyx_v_i1;
  coordinate_t __pyx_v_i2;
  coordinate_t __pyx_v_i_all;
  coordinate_t __pyx_v_n1;
  coordinate_t __pyx_v_n2;
  coordinate_t __pyx_v_n_all;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  coordinate_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":5582
 *         cdef SparseVectorD result
 *         # first pass: determine how much space we need
 *         n1=self.my_len             # <<<<<<<<<<<<<<
 *         n2=other.my_len
 *         n_all=i1=i2=0
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  __pyx_v_n1 = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":5583
 *         # first pass: determine how much space we need
 *         n1=self.my_len
 *         n2=other.my_len             # <<<<<<<<<<<<<<
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:
 */
  __pyx_t_1 = __pyx_v_other->my_len;
  __pyx_v_n2 = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":5584
 *         n1=self.my_len
 *         n2=other.my_len
 *         n_all=i1=i2=0             # <<<<<<<<<<<<<<
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 */
  __pyx_v_n_all = 0;
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":5585
 *         n2=other.my_len
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:             # <<<<<<<<<<<<<<
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":5586
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1
 */
    __pyx_v_k1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":5587
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1
 */
    __pyx_v_k2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":5588
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1             # <<<<<<<<<<<<<<
 *             if k2>=k1: i1+=1
 *             n_all+=1
 */
    __pyx_t_2 = ((__pyx_v_k1 >= __pyx_v_k2) != 0);
    if (__pyx_t_2) {
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "lurrn/sparsmat.pyx":5589
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1             # <<<<<<<<<<<<<<
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1
 */
    __pyx_t_2 = ((__pyx_v_k2 >= __pyx_v_k1) != 0);
    if (__pyx_t_2) {
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "lurrn/sparsmat.pyx":5590
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1
 *             n_all+=1             # <<<<<<<<<<<<<<
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2
 */
    __pyx_v_n_all = (__pyx_v_n_all + 1);
  }

  /* "lurrn/sparsmat.pyx":5591
 *             if k2>=k1: i1+=1
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1             # <<<<<<<<<<<<<<
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 */
  __pyx_t_2 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
  if (__pyx_t_2) {
    __pyx_v_n_all = (__pyx_v_n_all + (__pyx_v_n1 - __pyx_v_i1));
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "lurrn/sparsmat.pyx":5592
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2             # <<<<<<<<<<<<<<
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 *         new_vals=<double *>PyMem_Malloc(n_all*sizeof(double))
 */
  __pyx_t_2 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
  if (__pyx_t_2) {
    __pyx_v_n_all = (__pyx_v_n_all + (__pyx_v_n2 - __pyx_v_i2));
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "lurrn/sparsmat.pyx":5593
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         new_vals=<double *>PyMem_Malloc(n_all*sizeof(double))
 *         # second pass: fill in the actual values
 */
  __pyx_v_new_idx = ((coordinate_t *)PyMem_Malloc((__pyx_v_n_all * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":5594
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 *         new_vals=<double *>PyMem_Malloc(n_all*sizeof(double))             # <<<<<<<<<<<<<<
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0
 */
  __pyx_v_new_vals = ((double *)PyMem_Malloc((__pyx_v_n_all * (sizeof(double)))));

  /* "lurrn/sparsmat.pyx":5596
 *         new_vals=<double *>PyMem_Malloc(n_all*sizeof(double))
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0             # <<<<<<<<<<<<<<
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 */
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;
  __pyx_v_i_all = 0;

  /* "lurrn/sparsmat.pyx":5597
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0
 *         while i1<n1 and i2<n2:             # <<<<<<<<<<<<<<
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L13_bool_binop_done:;
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":5598
 *         i1=i2=i_all=0
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:
 */
    __pyx_v_k1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":5599
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *             if k1>=k2:
 *                 new_idx[i_all]=k2
 */
    __pyx_v_k2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":5600
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=other.vals_ptr[i2]
 */
    __pyx_t_2 = ((__pyx_v_k1 >= __pyx_v_k2) != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":5601
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:
 *                 new_idx[i_all]=k2             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = __pyx_v_k2;

      /* "lurrn/sparsmat.pyx":5602
 *             if k1>=k2:
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 i2+=1
 *                 if k1==k2:
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":5603
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1             # <<<<<<<<<<<<<<
 *                 if k1==k2:
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":5604
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 *                 if k1==k2:             # <<<<<<<<<<<<<<
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 *                     i1+=1
 */
      __pyx_t_2 = ((__pyx_v_k1 == __pyx_v_k2) != 0);
      if (__pyx_t_2) {

        /* "lurrn/sparsmat.pyx":5605
 *                 i2+=1
 *                 if k1==k2:
 *                     new_vals[i_all]+=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                     i1+=1
 *             elif k2>=k1:
 */
        __pyx_t_4 = __pyx_v_i_all;
        (__pyx_v_new_vals[__pyx_t_4]) = ((__pyx_v_new_vals[__pyx_t_4]) + (__pyx_v_self->vals_ptr[__pyx_v_i1]));

        /* "lurrn/sparsmat.pyx":5606
 *                 if k1==k2:
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 *                     i1+=1             # <<<<<<<<<<<<<<
 *             elif k2>=k1:
 *                 new_idx[i_all]=k1
 */
        __pyx_v_i1 = (__pyx_v_i1 + 1);
        goto __pyx_L16;
      }
      __pyx_L16:;
      goto __pyx_L15;
    }

    /* "lurrn/sparsmat.pyx":5607
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 *                     i1+=1
 *             elif k2>=k1:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]
 */
    __pyx_t_2 = ((__pyx_v_k2 >= __pyx_v_k1) != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":5608
 *                     i1+=1
 *             elif k2>=k1:
 *                 new_idx[i_all]=k1             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = __pyx_v_k1;

      /* "lurrn/sparsmat.pyx":5609
 *             elif k2>=k1:
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             i_all+=1
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

      /* "lurrn/sparsmat.pyx":5610
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             i_all+=1
 *         while i1<n1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L15;
    }
    __pyx_L15:;

    /* "lurrn/sparsmat.pyx":5611
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1
 *             i_all+=1             # <<<<<<<<<<<<<<
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]
 */
    __pyx_v_i_all = (__pyx_v_i_all + 1);
  }

  /* "lurrn/sparsmat.pyx":5612
 *                 i1+=1
 *             i_all+=1
 *         while i1<n1:             # <<<<<<<<<<<<<<
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":5613
 *             i_all+=1
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1
 */
    (__pyx_v_new_idx[__pyx_v_i_all]) = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":5614
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *             i1+=1
 *             i_all+=1
 */
    (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":5615
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1             # <<<<<<<<<<<<<<
 *             i_all+=1
 *         else:
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);

    /* "lurrn/sparsmat.pyx":5616
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1
 *             i_all+=1             # <<<<<<<<<<<<<<
 *         else:
 *             while i2<n2:
 */
    __pyx_v_i_all = (__pyx_v_i_all + 1);
  }

  /* "lurrn/sparsmat.pyx":5618
 *             i_all+=1
 *         else:
 *             while i2<n2:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=other.vals_ptr[i2]
 */
  /*else*/ {
    while (1) {
      __pyx_t_2 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
      if (!__pyx_t_2) break;

      /* "lurrn/sparsmat.pyx":5619
 *         else:
 *             while i2<n2:
 *                 new_idx[i_all]=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":5620
 *             while i2<n2:
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 i2+=1
 *                 i_all+=1
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":5621
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1             # <<<<<<<<<<<<<<
 *                 i_all+=1
 *         assert i_all==n_all
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":5622
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 *                 i_all+=1             # <<<<<<<<<<<<<<
 *         assert i_all==n_all
 *         result=SparseVectorD()
 */
      __pyx_v_i_all = (__pyx_v_i_all + 1);
    }
  }

  /* "lurrn/sparsmat.pyx":5623
 *                 i2+=1
 *                 i_all+=1
 *         assert i_all==n_all             # <<<<<<<<<<<<<<
 *         result=SparseVectorD()
 *         result.my_len=n_all
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_i_all == __pyx_v_n_all) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":5624
 *                 i_all+=1
 *         assert i_all==n_all
 *         result=SparseVectorD()             # <<<<<<<<<<<<<<
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx
 */
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorD)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "lurrn/sparsmat.pyx":5625
 *         assert i_all==n_all
 *         result=SparseVectorD()
 *         result.my_len=n_all             # <<<<<<<<<<<<<<
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals
 */
  __pyx_v_result->my_len = __pyx_v_n_all;

  /* "lurrn/sparsmat.pyx":5626
 *         result=SparseVectorD()
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx             # <<<<<<<<<<<<<<
 *         result.vals_ptr=new_vals
 *         return result
 */
  __pyx_v_result->idx_ptr = __pyx_v_new_idx;

  /* "lurrn/sparsmat.pyx":5627
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals             # <<<<<<<<<<<<<<
 *         return result
 *     def __sub__(SparseVectorD self,SparseVectorD other):
 */
  __pyx_v_result->vals_ptr = __pyx_v_new_vals;

  /* "lurrn/sparsmat.pyx":5628
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals
 *         return result             # <<<<<<<<<<<<<<
 *     def __sub__(SparseVectorD self,SparseVectorD other):
 *         cdef coordinate_t *new_idx
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5574
 *     def __len__(self):
 *         return self.my_len
 *     def __add__(SparseVectorD self,SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *new_idx
 *         cdef double *new_vals
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5629
 *         result.vals_ptr=new_vals
 *         return result
 *     def __sub__(SparseVectorD self,SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *new_idx
 *         cdef double *new_vals
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_53__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_53__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__sub__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_SparseVectorD, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorD, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_52__sub__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_52__sub__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other) {
  coordinate_t *__pyx_v_new_idx;
  double *__pyx_v_new_vals;
  coordinate_t __pyx_v_i1;
  coordinate_t __pyx_v_i2;
  coordinate_t __pyx_v_i_all;
  coordinate_t __pyx_v_n1;
  coordinate_t __pyx_v_n2;
  coordinate_t __pyx_v_n_all;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  coordinate_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__sub__", 0);

  /* "lurrn/sparsmat.pyx":5637
 *         cdef SparseVectorD result
 *         # first pass: determine how much space we need
 *         n1=self.my_len             # <<<<<<<<<<<<<<
 *         n2=other.my_len
 *         n_all=i1=i2=0
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  __pyx_v_n1 = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":5638
 *         # first pass: determine how much space we need
 *         n1=self.my_len
 *         n2=other.my_len             # <<<<<<<<<<<<<<
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:
 */
  __pyx_t_1 = __pyx_v_other->my_len;
  __pyx_v_n2 = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":5639
 *         n1=self.my_len
 *         n2=other.my_len
 *         n_all=i1=i2=0             # <<<<<<<<<<<<<<
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 */
  __pyx_v_n_all = 0;
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":5640
 *         n2=other.my_len
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:             # <<<<<<<<<<<<<<
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":5641
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1
 */
    __pyx_v_k1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":5642
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1
 */
    __pyx_v_k2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":5643
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1             # <<<<<<<<<<<<<<
 *             if k2>=k1: i1+=1
 *             n_all+=1
 */
    __pyx_t_2 = ((__pyx_v_k1 >= __pyx_v_k2) != 0);
    if (__pyx_t_2) {
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "lurrn/sparsmat.pyx":5644
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1             # <<<<<<<<<<<<<<
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1
 */
    __pyx_t_2 = ((__pyx_v_k2 >= __pyx_v_k1) != 0);
    if (__pyx_t_2) {
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "lurrn/sparsmat.pyx":5645
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1
 *             n_all+=1             # <<<<<<<<<<<<<<
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2
 */
    __pyx_v_n_all = (__pyx_v_n_all + 1);
  }

  /* "lurrn/sparsmat.pyx":5646
 *             if k2>=k1: i1+=1
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1             # <<<<<<<<<<<<<<
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 */
  __pyx_t_2 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
  if (__pyx_t_2) {
    __pyx_v_n_all = (__pyx_v_n_all + (__pyx_v_n1 - __pyx_v_i1));
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "lurrn/sparsmat.pyx":5647
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2             # <<<<<<<<<<<<<<
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 *         new_vals=<double *>PyMem_Malloc(n_all*sizeof(double))
 */
  __pyx_t_2 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
  if (__pyx_t_2) {
    __pyx_v_n_all = (__pyx_v_n_all + (__pyx_v_n2 - __pyx_v_i2));
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "lurrn/sparsmat.pyx":5648
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         new_vals=<double *>PyMem_Malloc(n_all*sizeof(double))
 *         # second pass: fill in the actual values
 */
  __pyx_v_new_idx = ((coordinate_t *)PyMem_Malloc((__pyx_v_n_all * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":5649
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 *         new_vals=<double *>PyMem_Malloc(n_all*sizeof(double))             # <<<<<<<<<<<<<<
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0
 */
  __pyx_v_new_vals = ((double *)PyMem_Malloc((__pyx_v_n_all * (sizeof(double)))));

  /* "lurrn/sparsmat.pyx":5651
 *         new_vals=<double *>PyMem_Malloc(n_all*sizeof(double))
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0             # <<<<<<<<<<<<<<
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 */
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;
  __pyx_v_i_all = 0;

  /* "lurrn/sparsmat.pyx":5652
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0
 *         while i1<n1 and i2<n2:             # <<<<<<<<<<<<<<
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L13_bool_binop_done:;
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":5653
 *         i1=i2=i_all=0
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:
 */
    __pyx_v_k1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":5654
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *             if k1>=k2:
 *                 new_idx[i_all]=k2
 */
    __pyx_v_k2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":5655
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 */
    __pyx_t_2 = ((__pyx_v_k1 >= __pyx_v_k2) != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":5656
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:
 *                 new_idx[i_all]=k2             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 *                 i2+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = __pyx_v_k2;

      /* "lurrn/sparsmat.pyx":5657
 *             if k1>=k2:
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=-other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 i2+=1
 *                 if k1==k2:
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (-(__pyx_v_other->vals_ptr[__pyx_v_i2]));

      /* "lurrn/sparsmat.pyx":5658
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 *                 i2+=1             # <<<<<<<<<<<<<<
 *                 if k1==k2:
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":5659
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 *                 i2+=1
 *                 if k1==k2:             # <<<<<<<<<<<<<<
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 *                     i1+=1
 */
      __pyx_t_2 = ((__pyx_v_k1 == __pyx_v_k2) != 0);
      if (__pyx_t_2) {

        /* "lurrn/sparsmat.pyx":5660
 *                 i2+=1
 *                 if k1==k2:
 *                     new_vals[i_all]+=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                     i1+=1
 *             elif k2>=k1:
 */
        __pyx_t_4 = __pyx_v_i_all;
        (__pyx_v_new_vals[__pyx_t_4]) = ((__pyx_v_new_vals[__pyx_t_4]) + (__pyx_v_self->vals_ptr[__pyx_v_i1]));

        /* "lurrn/sparsmat.pyx":5661
 *                 if k1==k2:
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 *                     i1+=1             # <<<<<<<<<<<<<<
 *             elif k2>=k1:
 *                 new_idx[i_all]=k1
 */
        __pyx_v_i1 = (__pyx_v_i1 + 1);
        goto __pyx_L16;
      }
      __pyx_L16:;
      goto __pyx_L15;
    }

    /* "lurrn/sparsmat.pyx":5662
 *                     new_vals[i_all]+=self.vals_ptr[i1]
 *                     i1+=1
 *             elif k2>=k1:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]
 */
    __pyx_t_2 = ((__pyx_v_k2 >= __pyx_v_k1) != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":5663
 *                     i1+=1
 *             elif k2>=k1:
 *                 new_idx[i_all]=k1             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = __pyx_v_k1;

      /* "lurrn/sparsmat.pyx":5664
 *             elif k2>=k1:
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             i_all+=1
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

      /* "lurrn/sparsmat.pyx":5665
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             i_all+=1
 *         while i1<n1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L15;
    }
    __pyx_L15:;

    /* "lurrn/sparsmat.pyx":5666
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1
 *             i_all+=1             # <<<<<<<<<<<<<<
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]
 */
    __pyx_v_i_all = (__pyx_v_i_all + 1);
  }

  /* "lurrn/sparsmat.pyx":5667
 *                 i1+=1
 *             i_all+=1
 *         while i1<n1:             # <<<<<<<<<<<<<<
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":5668
 *             i_all+=1
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1
 */
    (__pyx_v_new_idx[__pyx_v_i_all]) = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":5669
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *             i1+=1
 *             i_all+=1
 */
    (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":5670
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1             # <<<<<<<<<<<<<<
 *             i_all+=1
 *         else:
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);

    /* "lurrn/sparsmat.pyx":5671
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1
 *             i_all+=1             # <<<<<<<<<<<<<<
 *         else:
 *             while i2<n2:
 */
    __pyx_v_i_all = (__pyx_v_i_all + 1);
  }

  /* "lurrn/sparsmat.pyx":5673
 *             i_all+=1
 *         else:
 *             while i2<n2:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 */
  /*else*/ {
    while (1) {
      __pyx_t_2 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
      if (!__pyx_t_2) break;

      /* "lurrn/sparsmat.pyx":5674
 *         else:
 *             while i2<n2:
 *                 new_idx[i_all]=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 *                 i2+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":5675
 *             while i2<n2:
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=-other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 i2+=1
 *                 i_all+=1
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (-(__pyx_v_other->vals_ptr[__pyx_v_i2]));

      /* "lurrn/sparsmat.pyx":5676
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 *                 i2+=1             # <<<<<<<<<<<<<<
 *                 i_all+=1
 *         assert i_all==n_all
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":5677
 *                 new_vals[i_all]=-other.vals_ptr[i2]
 *                 i2+=1
 *                 i_all+=1             # <<<<<<<<<<<<<<
 *         assert i_all==n_all
 *         result=SparseVectorD()
 */
      __pyx_v_i_all = (__pyx_v_i_all + 1);
    }
  }

  /* "lurrn/sparsmat.pyx":5678
 *                 i2+=1
 *                 i_all+=1
 *         assert i_all==n_all             # <<<<<<<<<<<<<<
 *         result=SparseVectorD()
 *         result.my_len=n_all
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_i_all == __pyx_v_n_all) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":5679
 *                 i_all+=1
 *         assert i_all==n_all
 *         result=SparseVectorD()             # <<<<<<<<<<<<<<
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx
 */
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorD)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "lurrn/sparsmat.pyx":5680
 *         assert i_all==n_all
 *         result=SparseVectorD()
 *         result.my_len=n_all             # <<<<<<<<<<<<<<
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals
 */
  __pyx_v_result->my_len = __pyx_v_n_all;

  /* "lurrn/sparsmat.pyx":5681
 *         result=SparseVectorD()
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx             # <<<<<<<<<<<<<<
 *         result.vals_ptr=new_vals
 *         return result
 */
  __pyx_v_result->idx_ptr = __pyx_v_new_idx;

  /* "lurrn/sparsmat.pyx":5682
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals             # <<<<<<<<<<<<<<
 *         return result
 *     def __or__(SparseVectorD self,SparseVectorD other):
 */
  __pyx_v_result->vals_ptr = __pyx_v_new_vals;

  /* "lurrn/sparsmat.pyx":5683
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals
 *         return result             # <<<<<<<<<<<<<<
 *     def __or__(SparseVectorD self,SparseVectorD other):
 *         cdef coordinate_t *new_idx
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5629
 *         result.vals_ptr=new_vals
 *         return result
 *     def __sub__(SparseVectorD self,SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *new_idx
 *         cdef double *new_vals
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.__sub__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5684
 *         result.vals_ptr=new_vals
 *         return result
 *     def __or__(SparseVectorD self,SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *new_idx
 *         cdef double *new_vals
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_55__or__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_55__or__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__or__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_SparseVectorD, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_SparseVectorD, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_54__or__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_54__or__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_other) {
  coordinate_t *__pyx_v_new_idx;
  double *__pyx_v_new_vals;
  coordinate_t __pyx_v_i1;
  coordinate_t __pyx_v_i2;
  coordinate_t __pyx_v_i_all;
  coordinate_t __pyx_v_n1;
  coordinate_t __pyx_v_n2;
  coordinate_t __pyx_v_n_all;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_result = 0;
  double __pyx_v_val;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__or__", 0);

  /* "lurrn/sparsmat.pyx":5693
 *         cdef double val
 *         # first pass: determine how much space we need
 *         n1=self.my_len             # <<<<<<<<<<<<<<
 *         n2=other.my_len
 *         n_all=i1=i2=0
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  __pyx_v_n1 = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":5694
 *         # first pass: determine how much space we need
 *         n1=self.my_len
 *         n2=other.my_len             # <<<<<<<<<<<<<<
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:
 */
  __pyx_t_1 = __pyx_v_other->my_len;
  __pyx_v_n2 = __pyx_t_1;

  /* "lurrn/sparsmat.pyx":5695
 *         n1=self.my_len
 *         n2=other.my_len
 *         n_all=i1=i2=0             # <<<<<<<<<<<<<<
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 */
  __pyx_v_n_all = 0;
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":5696
 *         n2=other.my_len
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:             # <<<<<<<<<<<<<<
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":5697
 *         n_all=i1=i2=0
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1
 */
    __pyx_v_k1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":5698
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1
 */
    __pyx_v_k2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":5699
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1             # <<<<<<<<<<<<<<
 *             if k2>=k1: i1+=1
 *             n_all+=1
 */
    __pyx_t_2 = ((__pyx_v_k1 >= __pyx_v_k2) != 0);
    if (__pyx_t_2) {
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "lurrn/sparsmat.pyx":5700
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1             # <<<<<<<<<<<<<<
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1
 */
    __pyx_t_2 = ((__pyx_v_k2 >= __pyx_v_k1) != 0);
    if (__pyx_t_2) {
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "lurrn/sparsmat.pyx":5701
 *             if k1>=k2: i2+=1
 *             if k2>=k1: i1+=1
 *             n_all+=1             # <<<<<<<<<<<<<<
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2
 */
    __pyx_v_n_all = (__pyx_v_n_all + 1);
  }

  /* "lurrn/sparsmat.pyx":5702
 *             if k2>=k1: i1+=1
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1             # <<<<<<<<<<<<<<
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 */
  __pyx_t_2 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
  if (__pyx_t_2) {
    __pyx_v_n_all = (__pyx_v_n_all + (__pyx_v_n1 - __pyx_v_i1));
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "lurrn/sparsmat.pyx":5703
 *             n_all+=1
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2             # <<<<<<<<<<<<<<
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 *         new_vals=<double *>PyMem_Malloc(n_all*sizeof(double))
 */
  __pyx_t_2 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
  if (__pyx_t_2) {
    __pyx_v_n_all = (__pyx_v_n_all + (__pyx_v_n2 - __pyx_v_i2));
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "lurrn/sparsmat.pyx":5704
 *         if i1<n1: n_all+=n1-i1
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         new_vals=<double *>PyMem_Malloc(n_all*sizeof(double))
 *         # second pass: fill in the actual values
 */
  __pyx_v_new_idx = ((coordinate_t *)PyMem_Malloc((__pyx_v_n_all * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":5705
 *         if i2<n2: n_all+=n2-i2
 *         new_idx=<coordinate_t *>PyMem_Malloc(n_all*sizeof(coordinate_t))
 *         new_vals=<double *>PyMem_Malloc(n_all*sizeof(double))             # <<<<<<<<<<<<<<
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0
 */
  __pyx_v_new_vals = ((double *)PyMem_Malloc((__pyx_v_n_all * (sizeof(double)))));

  /* "lurrn/sparsmat.pyx":5707
 *         new_vals=<double *>PyMem_Malloc(n_all*sizeof(double))
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0             # <<<<<<<<<<<<<<
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 */
  __pyx_v_i1 = 0;
  __pyx_v_i2 = 0;
  __pyx_v_i_all = 0;

  /* "lurrn/sparsmat.pyx":5708
 *         # second pass: fill in the actual values
 *         i1=i2=i_all=0
 *         while i1<n1 and i2<n2:             # <<<<<<<<<<<<<<
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L13_bool_binop_done:;
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":5709
 *         i1=i2=i_all=0
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:
 */
    __pyx_v_k1 = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":5710
 *         while i1<n1 and i2<n2:
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *             if k1>=k2:
 *                 new_idx[i_all]=k2
 */
    __pyx_v_k2 = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

    /* "lurrn/sparsmat.pyx":5711
 *             k1=self.idx_ptr[i1]
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=other.vals_ptr[i2]
 */
    __pyx_t_2 = ((__pyx_v_k1 >= __pyx_v_k2) != 0);
    if (__pyx_t_2) {

      /* "lurrn/sparsmat.pyx":5712
 *             k2=other.idx_ptr[i2]
 *             if k1>=k2:
 *                 new_idx[i_all]=k2             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = __pyx_v_k2;

      /* "lurrn/sparsmat.pyx":5713
 *             if k1>=k2:
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 i2+=1
 *                 if k1==k2:
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":5714
 *                 new_idx[i_all]=k2
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1             # <<<<<<<<<<<<<<
 *                 if k1==k2:
 *                     val=self.vals_ptr[i1]
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":5715
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 *                 if k1==k2:             # <<<<<<<<<<<<<<
 *                     val=self.vals_ptr[i1]
 *                     if new_vals[i_all]<val:
 */
      __pyx_t_2 = ((__pyx_v_k1 == __pyx_v_k2) != 0);
      if (__pyx_t_2) {

        /* "lurrn/sparsmat.pyx":5716
 *                 i2+=1
 *                 if k1==k2:
 *                     val=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                     if new_vals[i_all]<val:
 *                         new_vals[i_all]=val
 */
        __pyx_v_val = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

        /* "lurrn/sparsmat.pyx":5717
 *                 if k1==k2:
 *                     val=self.vals_ptr[i1]
 *                     if new_vals[i_all]<val:             # <<<<<<<<<<<<<<
 *                         new_vals[i_all]=val
 *                     i1+=1
 */
        __pyx_t_2 = (((__pyx_v_new_vals[__pyx_v_i_all]) < __pyx_v_val) != 0);
        if (__pyx_t_2) {

          /* "lurrn/sparsmat.pyx":5718
 *                     val=self.vals_ptr[i1]
 *                     if new_vals[i_all]<val:
 *                         new_vals[i_all]=val             # <<<<<<<<<<<<<<
 *                     i1+=1
 *             else: # k2>k1:
 */
          (__pyx_v_new_vals[__pyx_v_i_all]) = __pyx_v_val;
          goto __pyx_L17;
        }
        __pyx_L17:;

        /* "lurrn/sparsmat.pyx":5719
 *                     if new_vals[i_all]<val:
 *                         new_vals[i_all]=val
 *                     i1+=1             # <<<<<<<<<<<<<<
 *             else: # k2>k1:
 *                 new_idx[i_all]=k1
 */
        __pyx_v_i1 = (__pyx_v_i1 + 1);
        goto __pyx_L16;
      }
      __pyx_L16:;
      goto __pyx_L15;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":5721
 *                     i1+=1
 *             else: # k2>k1:
 *                 new_idx[i_all]=k1             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = __pyx_v_k1;

      /* "lurrn/sparsmat.pyx":5722
 *             else: # k2>k1:
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             i_all+=1
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

      /* "lurrn/sparsmat.pyx":5723
 *                 new_idx[i_all]=k1
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             i_all+=1
 *         while i1<n1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
    }
    __pyx_L15:;

    /* "lurrn/sparsmat.pyx":5724
 *                 new_vals[i_all]=self.vals_ptr[i1]
 *                 i1+=1
 *             i_all+=1             # <<<<<<<<<<<<<<
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]
 */
    __pyx_v_i_all = (__pyx_v_i_all + 1);
  }

  /* "lurrn/sparsmat.pyx":5725
 *                 i1+=1
 *             i_all+=1
 *         while i1<n1:             # <<<<<<<<<<<<<<
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_i1 < __pyx_v_n1) != 0);
    if (!__pyx_t_2) break;

    /* "lurrn/sparsmat.pyx":5726
 *             i_all+=1
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]             # <<<<<<<<<<<<<<
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1
 */
    (__pyx_v_new_idx[__pyx_v_i_all]) = (__pyx_v_self->idx_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":5727
 *         while i1<n1:
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]             # <<<<<<<<<<<<<<
 *             i1+=1
 *             i_all+=1
 */
    (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_self->vals_ptr[__pyx_v_i1]);

    /* "lurrn/sparsmat.pyx":5728
 *             new_idx[i_all]=self.idx_ptr[i1]
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1             # <<<<<<<<<<<<<<
 *             i_all+=1
 *         else:
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);

    /* "lurrn/sparsmat.pyx":5729
 *             new_vals[i_all]=self.vals_ptr[i1]
 *             i1+=1
 *             i_all+=1             # <<<<<<<<<<<<<<
 *         else:
 *             while i2<n2:
 */
    __pyx_v_i_all = (__pyx_v_i_all + 1);
  }

  /* "lurrn/sparsmat.pyx":5731
 *             i_all+=1
 *         else:
 *             while i2<n2:             # <<<<<<<<<<<<<<
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=other.vals_ptr[i2]
 */
  /*else*/ {
    while (1) {
      __pyx_t_2 = ((__pyx_v_i2 < __pyx_v_n2) != 0);
      if (!__pyx_t_2) break;

      /* "lurrn/sparsmat.pyx":5732
 *         else:
 *             while i2<n2:
 *                 new_idx[i_all]=other.idx_ptr[i2]             # <<<<<<<<<<<<<<
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 */
      (__pyx_v_new_idx[__pyx_v_i_all]) = (__pyx_v_other->idx_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":5733
 *             while i2<n2:
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=other.vals_ptr[i2]             # <<<<<<<<<<<<<<
 *                 i2+=1
 *                 i_all+=1
 */
      (__pyx_v_new_vals[__pyx_v_i_all]) = (__pyx_v_other->vals_ptr[__pyx_v_i2]);

      /* "lurrn/sparsmat.pyx":5734
 *                 new_idx[i_all]=other.idx_ptr[i2]
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1             # <<<<<<<<<<<<<<
 *                 i_all+=1
 *         assert i_all==n_all
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);

      /* "lurrn/sparsmat.pyx":5735
 *                 new_vals[i_all]=other.vals_ptr[i2]
 *                 i2+=1
 *                 i_all+=1             # <<<<<<<<<<<<<<
 *         assert i_all==n_all
 *         result=SparseVectorD()
 */
      __pyx_v_i_all = (__pyx_v_i_all + 1);
    }
  }

  /* "lurrn/sparsmat.pyx":5736
 *                 i2+=1
 *                 i_all+=1
 *         assert i_all==n_all             # <<<<<<<<<<<<<<
 *         result=SparseVectorD()
 *         result.my_len=n_all
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_i_all == __pyx_v_n_all) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":5737
 *                 i_all+=1
 *         assert i_all==n_all
 *         result=SparseVectorD()             # <<<<<<<<<<<<<<
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx
 */
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorD)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "lurrn/sparsmat.pyx":5738
 *         assert i_all==n_all
 *         result=SparseVectorD()
 *         result.my_len=n_all             # <<<<<<<<<<<<<<
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals
 */
  __pyx_v_result->my_len = __pyx_v_n_all;

  /* "lurrn/sparsmat.pyx":5739
 *         result=SparseVectorD()
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx             # <<<<<<<<<<<<<<
 *         result.vals_ptr=new_vals
 *         return result
 */
  __pyx_v_result->idx_ptr = __pyx_v_new_idx;

  /* "lurrn/sparsmat.pyx":5740
 *         result.my_len=n_all
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals             # <<<<<<<<<<<<<<
 *         return result
 *     def __lshift__(self, int k):
 */
  __pyx_v_result->vals_ptr = __pyx_v_new_vals;

  /* "lurrn/sparsmat.pyx":5741
 *         result.idx_ptr=new_idx
 *         result.vals_ptr=new_vals
 *         return result             # <<<<<<<<<<<<<<
 *     def __lshift__(self, int k):
 *         cdef SparseVectorD result
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5684
 *         result.vals_ptr=new_vals
 *         return result
 *     def __or__(SparseVectorD self,SparseVectorD other):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *new_idx
 *         cdef double *new_vals
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.__or__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5742
 *         result.vals_ptr=new_vals
 *         return result
 *     def __lshift__(self, int k):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorD result
 *         cdef coordinate_t i
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_57__lshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_57__lshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__lshift__ (wrapper)", 0);
  assert(__pyx_arg_k); {
    __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5742; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.__lshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_56__lshift__(((PyObject *)__pyx_v_self), ((int)__pyx_v_k));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_56__lshift__(PyObject *__pyx_v_self, int __pyx_v_k) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_result = 0;
  coordinate_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  unsigned int __pyx_t_2;
  coordinate_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  coordinate_t __pyx_t_6;
  double __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__lshift__", 0);

  /* "lurrn/sparsmat.pyx":5745
 *         cdef SparseVectorD result
 *         cdef coordinate_t i
 *         result=SparseVectorD()             # <<<<<<<<<<<<<<
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorD)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5746
 *         cdef coordinate_t i
 *         result=SparseVectorD()
 *         result.my_len=self.my_len             # <<<<<<<<<<<<<<
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_my_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_unsigned_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_result->my_len = __pyx_t_2;

  /* "lurrn/sparsmat.pyx":5747
 *         result=SparseVectorD()
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))
 *         for i from 0<=i<self.my_len:
 */
  __pyx_v_result->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(coordinate_t)))));

  /* "lurrn/sparsmat.pyx":5748
 *         result.my_len=self.my_len
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]+k
 */
  __pyx_v_result->vals_ptr = ((double *)PyMem_Malloc((__pyx_v_result->my_len * (sizeof(double)))));

  /* "lurrn/sparsmat.pyx":5749
 *         result.idx_ptr=<coordinate_t *>PyMem_Malloc(result.my_len*sizeof(coordinate_t))
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result.idx_ptr[i]=self.idx_ptr[i]+k
 *         for i from 0<=i<self.my_len:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_my_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_coordinate_t(__pyx_t_1); if (unlikely((__pyx_t_3 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5750
 *         result.vals_ptr=<double *>PyMem_Malloc(result.my_len*sizeof(double))
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]+k             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_idx_ptr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_i, coordinate_t, 0, __Pyx_PyInt_From_coordinate_t, 0, 0, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5750; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = __Pyx_PyInt_As_coordinate_t(__pyx_t_5); if (unlikely((__pyx_t_6 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    (__pyx_v_result->idx_ptr[__pyx_v_i]) = __pyx_t_6;
  }

  /* "lurrn/sparsmat.pyx":5751
 *         for i from 0<=i<self.my_len:
 *             result.idx_ptr[i]=self.idx_ptr[i]+k
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             result.vals_ptr[i]=self.vals_ptr[i]
 *         return result
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_my_len); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyInt_As_coordinate_t(__pyx_t_5); if (unlikely((__pyx_t_3 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5752
 *             result.idx_ptr[i]=self.idx_ptr[i]+k
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *         return result
 *     def __ilshift__(self, int k):
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_vals_ptr); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_5, __pyx_v_i, coordinate_t, 0, __Pyx_PyInt_From_coordinate_t, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5752; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    (__pyx_v_result->vals_ptr[__pyx_v_i]) = __pyx_t_7;
  }

  /* "lurrn/sparsmat.pyx":5753
 *         for i from 0<=i<self.my_len:
 *             result.vals_ptr[i]=self.vals_ptr[i]
 *         return result             # <<<<<<<<<<<<<<
 *     def __ilshift__(self, int k):
 *         cdef SparseVectorD result
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5742
 *         result.vals_ptr=new_vals
 *         return result
 *     def __lshift__(self, int k):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorD result
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.__lshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5754
 *             result.vals_ptr[i]=self.vals_ptr[i]
 *         return result
 *     def __ilshift__(self, int k):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorD result
 *         cdef coordinate_t i
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_59__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_59__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ilshift__ (wrapper)", 0);
  assert(__pyx_arg_k); {
    __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5754; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.__ilshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_58__ilshift__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((int)__pyx_v_k));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_58__ilshift__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, int __pyx_v_k) {
  coordinate_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  coordinate_t __pyx_t_2;
  __Pyx_RefNannySetupContext("__ilshift__", 0);

  /* "lurrn/sparsmat.pyx":5757
 *         cdef SparseVectorD result
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             self.idx_ptr[i]+=k
 *         return self
 */
  __pyx_t_1 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5758
 *         cdef coordinate_t i
 *         for i from 0<=i<self.my_len:
 *             self.idx_ptr[i]+=k             # <<<<<<<<<<<<<<
 *         return self
 *     def __getitem__(self, int i):
 */
    __pyx_t_2 = __pyx_v_i;
    (__pyx_v_self->idx_ptr[__pyx_t_2]) = ((__pyx_v_self->idx_ptr[__pyx_t_2]) + __pyx_v_k);
  }

  /* "lurrn/sparsmat.pyx":5759
 *         for i from 0<=i<self.my_len:
 *             self.idx_ptr[i]+=k
 *         return self             # <<<<<<<<<<<<<<
 *     def __getitem__(self, int i):
 *         if i<0:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5754
 *             result.vals_ptr[i]=self.vals_ptr[i]
 *         return result
 *     def __ilshift__(self, int k):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorD result
 *         cdef coordinate_t i
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5760
 *             self.idx_ptr[i]+=k
 *         return self
 *     def __getitem__(self, int i):             # <<<<<<<<<<<<<<
 *         if i<0:
 *             i=self.my_len+i
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_61__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_i); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_61__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_i) {
  int __pyx_v_i;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  assert(__pyx_arg_i); {
    __pyx_v_i = __Pyx_PyInt_As_int(__pyx_arg_i); if (unlikely((__pyx_v_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5760; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_60__getitem__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((int)__pyx_v_i));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_60__getitem__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, int __pyx_v_i) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "lurrn/sparsmat.pyx":5761
 *         return self
 *     def __getitem__(self, int i):
 *         if i<0:             # <<<<<<<<<<<<<<
 *             i=self.my_len+i
 *         if i>=self.my_len or i<0:
 */
  __pyx_t_1 = ((__pyx_v_i < 0) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":5762
 *     def __getitem__(self, int i):
 *         if i<0:
 *             i=self.my_len+i             # <<<<<<<<<<<<<<
 *         if i>=self.my_len or i<0:
 *             raise IndexError
 */
    __pyx_v_i = (__pyx_v_self->my_len + __pyx_v_i);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":5763
 *         if i<0:
 *             i=self.my_len+i
 *         if i>=self.my_len or i<0:             # <<<<<<<<<<<<<<
 *             raise IndexError
 *         return (self.idx_ptr[i],self.vals_ptr[i])
 */
  __pyx_t_2 = ((__pyx_v_i >= __pyx_v_self->my_len) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_i < 0) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":5764
 *             i=self.my_len+i
 *         if i>=self.my_len or i<0:
 *             raise IndexError             # <<<<<<<<<<<<<<
 *         return (self.idx_ptr[i],self.vals_ptr[i])
 *     def __repr__(self):
 */
    __Pyx_Raise(__pyx_builtin_IndexError, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lurrn/sparsmat.pyx":5765
 *         if i>=self.my_len or i<0:
 *             raise IndexError
 *         return (self.idx_ptr[i],self.vals_ptr[i])             # <<<<<<<<<<<<<<
 *     def __repr__(self):
 *         cdef unsigned int i
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->idx_ptr[__pyx_v_i])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble((__pyx_v_self->vals_ptr[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5760
 *             self.idx_ptr[i]+=k
 *         return self
 *     def __getitem__(self, int i):             # <<<<<<<<<<<<<<
 *         if i<0:
 *             i=self.my_len+i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5766
 *             raise IndexError
 *         return (self.idx_ptr[i],self.vals_ptr[i])
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         cdef unsigned int i
 *         ss=[]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_63__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_63__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_62__repr__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_62__repr__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self) {
  unsigned int __pyx_v_i;
  PyObject *__pyx_v_ss = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  unsigned int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "lurrn/sparsmat.pyx":5768
 *     def __repr__(self):
 *         cdef unsigned int i
 *         ss=[]             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             ss.append('(%d,%s)'%(self.idx_ptr[i],self.vals_ptr[i]))
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ss = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5769
 *         cdef unsigned int i
 *         ss=[]
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             ss.append('(%d,%s)'%(self.idx_ptr[i],self.vals_ptr[i]))
 *         return 'SparseVectorD([%s])'%(','.join(ss))
 */
  __pyx_t_2 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5770
 *         ss=[]
 *         for i from 0<=i<self.my_len:
 *             ss.append('(%d,%s)'%(self.idx_ptr[i],self.vals_ptr[i]))             # <<<<<<<<<<<<<<
 *         return 'SparseVectorD([%s])'%(','.join(ss))
 *     def __reduce_ex__(self,protocol):
 */
    __pyx_t_1 = __Pyx_PyInt_From_coordinate_t((__pyx_v_self->idx_ptr[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyFloat_FromDouble((__pyx_v_self->vals_ptr[__pyx_v_i])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_d_s, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyList_Append(__pyx_v_ss, __pyx_t_3); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }

  /* "lurrn/sparsmat.pyx":5771
 *         for i from 0<=i<self.my_len:
 *             ss.append('(%d,%s)'%(self.idx_ptr[i],self.vals_ptr[i]))
 *         return 'SparseVectorD([%s])'%(','.join(ss))             # <<<<<<<<<<<<<<
 *     def __reduce_ex__(self,protocol):
 *         if protocol==0:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyString_Join(__pyx_kp_s__25, __pyx_v_ss); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_SparseVectorD_s, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5766
 *             raise IndexError
 *         return (self.idx_ptr[i],self.vals_ptr[i])
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         cdef unsigned int i
 *         ss=[]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ss);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5772
 *             ss.append('(%d,%s)'%(self.idx_ptr[i],self.vals_ptr[i]))
 *         return 'SparseVectorD([%s])'%(','.join(ss))
 *     def __reduce_ex__(self,protocol):             # <<<<<<<<<<<<<<
 *         if protocol==0:
 *             # choose compatibility over performance.
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_65__reduce_ex__(PyObject *__pyx_v_self, PyObject *__pyx_v_protocol); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_65__reduce_ex__(PyObject *__pyx_v_self, PyObject *__pyx_v_protocol) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_ex__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_64__reduce_ex__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((PyObject *)__pyx_v_protocol));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_64__reduce_ex__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, PyObject *__pyx_v_protocol) {
  PyObject *__pyx_v_s_idx = NULL;
  PyObject *__pyx_v_s_vals = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_ex__", 0);

  /* "lurrn/sparsmat.pyx":5773
 *         return 'SparseVectorD([%s])'%(','.join(ss))
 *     def __reduce_ex__(self,protocol):
 *         if protocol==0:             # <<<<<<<<<<<<<<
 *             # choose compatibility over performance.
 *             return (SparseVectorD,(list(self),),())
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_protocol, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "lurrn/sparsmat.pyx":5775
 *         if protocol==0:
 *             # choose compatibility over performance.
 *             return (SparseVectorD,(list(self),),())             # <<<<<<<<<<<<<<
 *         else:
 *             s_idx=PyString_FromStringAndSize(<char *>self.idx_ptr,self.my_len*sizeof(coordinate_t))
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorD)));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorD)));
    __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorD)));
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_empty_tuple);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_empty_tuple);
    __Pyx_GIVEREF(__pyx_empty_tuple);
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":5777
 *             return (SparseVectorD,(list(self),),())
 *         else:
 *             s_idx=PyString_FromStringAndSize(<char *>self.idx_ptr,self.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *             s_vals=PyString_FromStringAndSize(<char *>self.vals_ptr,self.my_len*sizeof(double))
 *             return (SparseVectorD,(None,),(s_idx,s_vals))
 */
    __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->idx_ptr), (__pyx_v_self->my_len * (sizeof(coordinate_t)))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_s_idx = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "lurrn/sparsmat.pyx":5778
 *         else:
 *             s_idx=PyString_FromStringAndSize(<char *>self.idx_ptr,self.my_len*sizeof(coordinate_t))
 *             s_vals=PyString_FromStringAndSize(<char *>self.vals_ptr,self.my_len*sizeof(double))             # <<<<<<<<<<<<<<
 *             return (SparseVectorD,(None,),(s_idx,s_vals))
 *     def __setstate__(self,state):
 */
    __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->vals_ptr), (__pyx_v_self->my_len * (sizeof(double)))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_s_vals = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "lurrn/sparsmat.pyx":5779
 *             s_idx=PyString_FromStringAndSize(<char *>self.idx_ptr,self.my_len*sizeof(coordinate_t))
 *             s_vals=PyString_FromStringAndSize(<char *>self.vals_ptr,self.my_len*sizeof(double))
 *             return (SparseVectorD,(None,),(s_idx,s_vals))             # <<<<<<<<<<<<<<
 *     def __setstate__(self,state):
 *         cdef coordinate_t *p_idx
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_s_idx);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_s_idx);
    __Pyx_GIVEREF(__pyx_v_s_idx);
    __Pyx_INCREF(__pyx_v_s_vals);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_s_vals);
    __Pyx_GIVEREF(__pyx_v_s_vals);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorD)));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorD)));
    __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorD)));
    __Pyx_INCREF(__pyx_tuple__72);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_tuple__72);
    __Pyx_GIVEREF(__pyx_tuple__72);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":5772
 *             ss.append('(%d,%s)'%(self.idx_ptr[i],self.vals_ptr[i]))
 *         return 'SparseVectorD([%s])'%(','.join(ss))
 *     def __reduce_ex__(self,protocol):             # <<<<<<<<<<<<<<
 *         if protocol==0:
 *             # choose compatibility over performance.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.__reduce_ex__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s_idx);
  __Pyx_XDECREF(__pyx_v_s_vals);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5780
 *             s_vals=PyString_FromStringAndSize(<char *>self.vals_ptr,self.my_len*sizeof(double))
 *             return (SparseVectorD,(None,),(s_idx,s_vals))
 *     def __setstate__(self,state):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *p_idx
 *         cdef double *p_vals
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_67__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_67__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_66__setstate__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self), ((PyObject *)__pyx_v_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_66__setstate__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self, PyObject *__pyx_v_state) {
  coordinate_t *__pyx_v_p_idx;
  double *__pyx_v_p_vals;
  PyObject *__pyx_v_s_idx = NULL;
  PyObject *__pyx_v_s_vals = NULL;
  long __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  char *__pyx_t_7;
  size_t __pyx_t_8;
  unsigned int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* "lurrn/sparsmat.pyx":5783
 *         cdef coordinate_t *p_idx
 *         cdef double *p_vals
 *         if len(state)==0:             # <<<<<<<<<<<<<<
 *             pass
 *         elif len(state)==2:
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_state); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((__pyx_t_1 == 0) != 0);
  if (__pyx_t_2) {
    goto __pyx_L3;
  }

  /* "lurrn/sparsmat.pyx":5785
 *         if len(state)==0:
 *             pass
 *         elif len(state)==2:             # <<<<<<<<<<<<<<
 *             assert (self.idx_ptr==NULL)
 *             (s_idx, s_vals)=state
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_state); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((__pyx_t_1 == 2) != 0);
  if (__pyx_t_2) {

    /* "lurrn/sparsmat.pyx":5786
 *             pass
 *         elif len(state)==2:
 *             assert (self.idx_ptr==NULL)             # <<<<<<<<<<<<<<
 *             (s_idx, s_vals)=state
 *             p_idx=<coordinate_t *>(<char *>s_idx)
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      if (unlikely(!((__pyx_v_self->idx_ptr == NULL) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":5787
 *         elif len(state)==2:
 *             assert (self.idx_ptr==NULL)
 *             (s_idx, s_vals)=state             # <<<<<<<<<<<<<<
 *             p_idx=<coordinate_t *>(<char *>s_idx)
 *             p_vals=<double *>(<char *>s_vals)
 */
    if ((likely(PyTuple_CheckExact(__pyx_v_state))) || (PyList_CheckExact(__pyx_v_state))) {
      PyObject* sequence = __pyx_v_state;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      #endif
    } else {
      Py_ssize_t index = -1;
      __pyx_t_5 = PyObject_GetIter(__pyx_v_state); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = NULL;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L5_unpacking_done;
      __pyx_L4_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L5_unpacking_done:;
    }
    __pyx_v_s_idx = __pyx_t_3;
    __pyx_t_3 = 0;
    __pyx_v_s_vals = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":5788
 *             assert (self.idx_ptr==NULL)
 *             (s_idx, s_vals)=state
 *             p_idx=<coordinate_t *>(<char *>s_idx)             # <<<<<<<<<<<<<<
 *             p_vals=<double *>(<char *>s_vals)
 *             self.my_len=len(s_idx)/sizeof(coordinate_t)
 */
    __pyx_t_7 = __Pyx_PyObject_AsString(__pyx_v_s_idx); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_p_idx = ((coordinate_t *)((char *)__pyx_t_7));

    /* "lurrn/sparsmat.pyx":5789
 *             (s_idx, s_vals)=state
 *             p_idx=<coordinate_t *>(<char *>s_idx)
 *             p_vals=<double *>(<char *>s_vals)             # <<<<<<<<<<<<<<
 *             self.my_len=len(s_idx)/sizeof(coordinate_t)
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 */
    __pyx_t_7 = __Pyx_PyObject_AsString(__pyx_v_s_vals); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_p_vals = ((double *)((char *)__pyx_t_7));

    /* "lurrn/sparsmat.pyx":5790
 *             p_idx=<coordinate_t *>(<char *>s_idx)
 *             p_vals=<double *>(<char *>s_vals)
 *             self.my_len=len(s_idx)/sizeof(coordinate_t)             # <<<<<<<<<<<<<<
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *             self.vals_ptr=<double *>PyMem_Malloc(self.my_len*sizeof(double))
 */
    __pyx_t_1 = PyObject_Length(__pyx_v_s_idx); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = (sizeof(coordinate_t));
    if (unlikely(__pyx_t_8 == 0)) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      #ifdef WITH_THREAD
      PyGILState_Release(__pyx_gilstate_save);
      #endif
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_self->my_len = (__pyx_t_1 / __pyx_t_8);

    /* "lurrn/sparsmat.pyx":5791
 *             p_vals=<double *>(<char *>s_vals)
 *             self.my_len=len(s_idx)/sizeof(coordinate_t)
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))             # <<<<<<<<<<<<<<
 *             self.vals_ptr=<double *>PyMem_Malloc(self.my_len*sizeof(double))
 *             for i from 0<=i<self.my_len:
 */
    __pyx_v_self->idx_ptr = ((coordinate_t *)PyMem_Malloc((__pyx_v_self->my_len * (sizeof(coordinate_t)))));

    /* "lurrn/sparsmat.pyx":5792
 *             self.my_len=len(s_idx)/sizeof(coordinate_t)
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *             self.vals_ptr=<double *>PyMem_Malloc(self.my_len*sizeof(double))             # <<<<<<<<<<<<<<
 *             for i from 0<=i<self.my_len:
 *                 self.idx_ptr[i]=p_idx[i]
 */
    __pyx_v_self->vals_ptr = ((double *)PyMem_Malloc((__pyx_v_self->my_len * (sizeof(double)))));

    /* "lurrn/sparsmat.pyx":5793
 *             self.idx_ptr=<coordinate_t *>PyMem_Malloc(self.my_len*sizeof(coordinate_t))
 *             self.vals_ptr=<double *>PyMem_Malloc(self.my_len*sizeof(double))
 *             for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *                 self.idx_ptr[i]=p_idx[i]
 *                 self.vals_ptr[i]=p_vals[i]
 */
    __pyx_t_9 = __pyx_v_self->my_len;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {

      /* "lurrn/sparsmat.pyx":5794
 *             self.vals_ptr=<double *>PyMem_Malloc(self.my_len*sizeof(double))
 *             for i from 0<=i<self.my_len:
 *                 self.idx_ptr[i]=p_idx[i]             # <<<<<<<<<<<<<<
 *                 self.vals_ptr[i]=p_vals[i]
 *     def __dealloc__(self):
 */
      (__pyx_v_self->idx_ptr[__pyx_v_i]) = (__pyx_v_p_idx[__pyx_v_i]);

      /* "lurrn/sparsmat.pyx":5795
 *             for i from 0<=i<self.my_len:
 *                 self.idx_ptr[i]=p_idx[i]
 *                 self.vals_ptr[i]=p_vals[i]             # <<<<<<<<<<<<<<
 *     def __dealloc__(self):
 *         if self.buf is None:
 */
      (__pyx_v_self->vals_ptr[__pyx_v_i]) = (__pyx_v_p_vals[__pyx_v_i]);
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":5780
 *             s_vals=PyString_FromStringAndSize(<char *>self.vals_ptr,self.my_len*sizeof(double))
 *             return (SparseVectorD,(None,),(s_idx,s_vals))
 *     def __setstate__(self,state):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t *p_idx
 *         cdef double *p_vals
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.__setstate__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s_idx);
  __Pyx_XDECREF(__pyx_v_s_vals);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5796
 *                 self.idx_ptr[i]=p_idx[i]
 *                 self.vals_ptr[i]=p_vals[i]
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.buf is None:
 *             PyMem_Free(self.idx_ptr)
 */

/* Python wrapper */
static void __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_69__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_69__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_68__dealloc__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_68__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lurrn/sparsmat.pyx":5797
 *                 self.vals_ptr[i]=p_vals[i]
 *     def __dealloc__(self):
 *         if self.buf is None:             # <<<<<<<<<<<<<<
 *             PyMem_Free(self.idx_ptr)
 *             PyMem_Free(self.vals_ptr)
 */
  __pyx_t_1 = (__pyx_v_self->buf == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lurrn/sparsmat.pyx":5798
 *     def __dealloc__(self):
 *         if self.buf is None:
 *             PyMem_Free(self.idx_ptr)             # <<<<<<<<<<<<<<
 *             PyMem_Free(self.vals_ptr)
 *         else:
 */
    PyMem_Free(__pyx_v_self->idx_ptr);

    /* "lurrn/sparsmat.pyx":5799
 *         if self.buf is None:
 *             PyMem_Free(self.idx_ptr)
 *             PyMem_Free(self.vals_ptr)             # <<<<<<<<<<<<<<
 *         else:
 *             self.buf=None
 */
    PyMem_Free(__pyx_v_self->vals_ptr);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":5801
 *             PyMem_Free(self.vals_ptr)
 *         else:
 *             self.buf=None             # <<<<<<<<<<<<<<
 *         self.idx_ptr=<coordinate_t *>0
 *         self.vals_ptr=<double *>0
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->buf);
    __Pyx_DECREF(__pyx_v_self->buf);
    __pyx_v_self->buf = Py_None;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":5802
 *         else:
 *             self.buf=None
 *         self.idx_ptr=<coordinate_t *>0             # <<<<<<<<<<<<<<
 *         self.vals_ptr=<double *>0
 *         self.my_len=0
 */
  __pyx_v_self->idx_ptr = ((coordinate_t *)0);

  /* "lurrn/sparsmat.pyx":5803
 *             self.buf=None
 *         self.idx_ptr=<coordinate_t *>0
 *         self.vals_ptr=<double *>0             # <<<<<<<<<<<<<<
 *         self.my_len=0
 *     def to_scipy(self):
 */
  __pyx_v_self->vals_ptr = ((double *)0);

  /* "lurrn/sparsmat.pyx":5804
 *         self.idx_ptr=<coordinate_t *>0
 *         self.vals_ptr=<double *>0
 *         self.my_len=0             # <<<<<<<<<<<<<<
 *     def to_scipy(self):
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] data
 */
  __pyx_v_self->my_len = 0;

  /* "lurrn/sparsmat.pyx":5796
 *                 self.idx_ptr[i]=p_idx[i]
 *                 self.vals_ptr[i]=p_vals[i]
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.buf is None:
 *             PyMem_Free(self.idx_ptr)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":5805
 *         self.vals_ptr=<double *>0
 *         self.my_len=0
 *     def to_scipy(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] data
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indices
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_71to_scipy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_71to_scipy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_scipy (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_13SparseVectorD_70to_scipy(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_13SparseVectorD_70to_scipy(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_self) {
  PyArrayObject *__pyx_v_data = 0;
  PyArrayObject *__pyx_v_indices = 0;
  PyArrayObject *__pyx_v_indptr = 0;
  int __pyx_v_i;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_data;
  __Pyx_Buffer __pyx_pybuffer_data;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indices;
  __Pyx_Buffer __pyx_pybuffer_indices;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indptr;
  __Pyx_Buffer __pyx_pybuffer_indptr;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyArrayObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyArrayObject *__pyx_t_13 = NULL;
  PyArrayObject *__pyx_t_14 = NULL;
  unsigned int __pyx_t_15;
  long __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_scipy", 0);
  __pyx_pybuffer_data.pybuffer.buf = NULL;
  __pyx_pybuffer_data.refcount = 0;
  __pyx_pybuffernd_data.data = NULL;
  __pyx_pybuffernd_data.rcbuffer = &__pyx_pybuffer_data;
  __pyx_pybuffer_indices.pybuffer.buf = NULL;
  __pyx_pybuffer_indices.refcount = 0;
  __pyx_pybuffernd_indices.data = NULL;
  __pyx_pybuffernd_indices.rcbuffer = &__pyx_pybuffer_indices;
  __pyx_pybuffer_indptr.pybuffer.buf = NULL;
  __pyx_pybuffer_indptr.refcount = 0;
  __pyx_pybuffernd_indptr.data = NULL;
  __pyx_pybuffernd_indptr.rcbuffer = &__pyx_pybuffer_indptr;

  /* "lurrn/sparsmat.pyx":5810
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indptr
 *         cdef int i,j
 *         indptr=numpy.zeros(2, numpy.int32)             # <<<<<<<<<<<<<<
 *         indices=numpy.zeros(self.my_len, numpy.int32)
 *         data=numpy.zeros(self.my_len, numpy.float64)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_int_2);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
    __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_8 < 0)) {
      PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer, (PyObject*)__pyx_v_indptr, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
    }
    __pyx_pybuffernd_indptr.diminfo[0].strides = __pyx_pybuffernd_indptr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indptr.diminfo[0].shape = __pyx_pybuffernd_indptr.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_7 = 0;
  __pyx_v_indptr = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5811
 *         cdef int i,j
 *         indptr=numpy.zeros(2, numpy.int32)
 *         indices=numpy.zeros(self.my_len, numpy.int32)             # <<<<<<<<<<<<<<
 *         data=numpy.zeros(self.my_len, numpy.float64)
 *         indptr[1]=self.my_len
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->my_len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_12 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_5, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_5, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_13 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
    __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indices.rcbuffer->pybuffer, (PyObject*)__pyx_t_13, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_8 < 0)) {
      PyErr_Fetch(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indices.rcbuffer->pybuffer, (PyObject*)__pyx_v_indices, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_11, __pyx_t_10, __pyx_t_9);
      }
    }
    __pyx_pybuffernd_indices.diminfo[0].strides = __pyx_pybuffernd_indices.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indices.diminfo[0].shape = __pyx_pybuffernd_indices.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_13 = 0;
  __pyx_v_indices = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5812
 *         indptr=numpy.zeros(2, numpy.int32)
 *         indices=numpy.zeros(self.my_len, numpy.int32)
 *         data=numpy.zeros(self.my_len, numpy.float64)             # <<<<<<<<<<<<<<
 *         indptr[1]=self.my_len
 *         for i from 0<=i<self.my_len:
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_zeros); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->my_len); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float64); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_6 = 0;
  __pyx_t_3 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
    __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_8 < 0)) {
      PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data.rcbuffer->pybuffer, (PyObject*)__pyx_v_data, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
    }
    __pyx_pybuffernd_data.diminfo[0].strides = __pyx_pybuffernd_data.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_data.diminfo[0].shape = __pyx_pybuffernd_data.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_14 = 0;
  __pyx_v_data = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5813
 *         indices=numpy.zeros(self.my_len, numpy.int32)
 *         data=numpy.zeros(self.my_len, numpy.float64)
 *         indptr[1]=self.my_len             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             indices[i]=0
 */
  __pyx_t_15 = __pyx_v_self->my_len;
  __pyx_t_16 = 1;
  __pyx_t_8 = -1;
  if (__pyx_t_16 < 0) {
    __pyx_t_16 += __pyx_pybuffernd_indptr.diminfo[0].shape;
    if (unlikely(__pyx_t_16 < 0)) __pyx_t_8 = 0;
  } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_indptr.diminfo[0].shape)) __pyx_t_8 = 0;
  if (unlikely(__pyx_t_8 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_8);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_indptr.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_indptr.diminfo[0].strides) = __pyx_t_15;

  /* "lurrn/sparsmat.pyx":5814
 *         data=numpy.zeros(self.my_len, numpy.float64)
 *         indptr[1]=self.my_len
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             indices[i]=0
 *         for i from 0<=i<self.my_len:
 */
  __pyx_t_15 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_15; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5815
 *         indptr[1]=self.my_len
 *         for i from 0<=i<self.my_len:
 *             indices[i]=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<self.my_len:
 *             data[i]=self.vals_ptr[i]
 */
    __pyx_t_8 = __pyx_v_i;
    __pyx_t_17 = -1;
    if (__pyx_t_8 < 0) {
      __pyx_t_8 += __pyx_pybuffernd_indices.diminfo[0].shape;
      if (unlikely(__pyx_t_8 < 0)) __pyx_t_17 = 0;
    } else if (unlikely(__pyx_t_8 >= __pyx_pybuffernd_indices.diminfo[0].shape)) __pyx_t_17 = 0;
    if (unlikely(__pyx_t_17 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_17);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_indices.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_indices.diminfo[0].strides) = 0;
  }

  /* "lurrn/sparsmat.pyx":5816
 *         for i from 0<=i<self.my_len:
 *             indices[i]=0
 *         for i from 0<=i<self.my_len:             # <<<<<<<<<<<<<<
 *             data[i]=self.vals_ptr[i]
 *         return (data,indices,indptr)
 */
  __pyx_t_15 = __pyx_v_self->my_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_15; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5817
 *             indices[i]=0
 *         for i from 0<=i<self.my_len:
 *             data[i]=self.vals_ptr[i]             # <<<<<<<<<<<<<<
 *         return (data,indices,indptr)
 * 
 */
    __pyx_t_17 = __pyx_v_i;
    __pyx_t_18 = -1;
    if (__pyx_t_17 < 0) {
      __pyx_t_17 += __pyx_pybuffernd_data.diminfo[0].shape;
      if (unlikely(__pyx_t_17 < 0)) __pyx_t_18 = 0;
    } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_data.diminfo[0].shape)) __pyx_t_18 = 0;
    if (unlikely(__pyx_t_18 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_18);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_data.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_data.diminfo[0].strides) = (__pyx_v_self->vals_ptr[__pyx_v_i]);
  }

  /* "lurrn/sparsmat.pyx":5818
 *         for i from 0<=i<self.my_len:
 *             data[i]=self.vals_ptr[i]
 *         return (data,indices,indptr)             # <<<<<<<<<<<<<<
 * 
 * emptyvec_D=SparseVectorD([])
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_data));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_data));
  __Pyx_INCREF(((PyObject *)__pyx_v_indices));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_indices));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_indices));
  __Pyx_INCREF(((PyObject *)__pyx_v_indptr));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_indptr));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_indptr));
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5805
 *         self.vals_ptr=<double *>0
 *         self.my_len=0
 *     def to_scipy(self):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.float64_t, ndim=1] data
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] indices
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_12);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorD.to_scipy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_data);
  __Pyx_XDECREF((PyObject *)__pyx_v_indices);
  __Pyx_XDECREF((PyObject *)__pyx_v_indptr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5823
 * 
 * cdef class SparseVectorsD:
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *        self.vecs = []
 *     cpdef SparseVectorD to_vec(self):
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsD___init__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_14SparseVectorsD___init__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":5824
 * cdef class SparseVectorsD:
 *     def __init__(self):
 *        self.vecs = []             # <<<<<<<<<<<<<<
 *     cpdef SparseVectorD to_vec(self):
 *         cdef SparseVectorD vec
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->vecs);
  __Pyx_DECREF(__pyx_v_self->vecs);
  __pyx_v_self->vecs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5823
 * 
 * cdef class SparseVectorsD:
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *        self.vecs = []
 *     cpdef SparseVectorD to_vec(self):
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsD.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5825
 *     def __init__(self):
 *        self.vecs = []
 *     cpdef SparseVectorD to_vec(self):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorD vec
 *         cdef double weight
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_3to_vec(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_f_5lurrn_8sparsmat_14SparseVectorsD_to_vec(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_self, int __pyx_skip_dispatch) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_vec = 0;
  double __pyx_v_weight;
  size_t __pyx_v_i;
  size_t __pyx_v_j;
  struct __pyx_obj_5lurrn_8sparsmat_VecD1 *__pyx_v_result = 0;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  unsigned int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_vec", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_to_vec); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_3to_vec)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_SparseVectorD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5829
 *         cdef double weight
 *         cdef size_t i, j
 *         cdef VecD1 result = VecD1()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecD1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5830
 *         cdef size_t i, j
 *         cdef VecD1 result = VecD1()
 *         for i from 0<=i<len(self.vecs):             # <<<<<<<<<<<<<<
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 */
  __pyx_t_1 = __pyx_v_self->vecs;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5831
 *         cdef VecD1 result = VecD1()
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = self.vecs[i]
 *             for j from 0<=j<vec.my_len:
 */
    __pyx_v_weight = __pyx_v_self->weights.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":5832
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]             # <<<<<<<<<<<<<<
 *             for j from 0<=j<vec.my_len:
 *                 result.add_count(vec.idx_ptr[j], weight*vec.vals_ptr[j])
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->vecs, __pyx_v_i, size_t, 0, __Pyx_PyInt_FromSize_t, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5832; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_SparseVectorD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":5833
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 *             for j from 0<=j<vec.my_len:             # <<<<<<<<<<<<<<
 *                 result.add_count(vec.idx_ptr[j], weight*vec.vals_ptr[j])
 *         return result.to_sparse()
 */
    __pyx_t_6 = __pyx_v_vec->my_len;
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_6; __pyx_v_j++) {

      /* "lurrn/sparsmat.pyx":5834
 *             vec = self.vecs[i]
 *             for j from 0<=j<vec.my_len:
 *                 result.add_count(vec.idx_ptr[j], weight*vec.vals_ptr[j])             # <<<<<<<<<<<<<<
 *         return result.to_sparse()
 *     cpdef add(self, SparseVectorD vec, double weight=1):
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_result), __pyx_n_s_add_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyInt_From_coordinate_t((__pyx_v_vec->idx_ptr[__pyx_v_j])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyFloat_FromDouble((__pyx_v_weight * (__pyx_v_vec->vals_ptr[__pyx_v_j]))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_8 = 1;
        }
      }
      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
  }

  /* "lurrn/sparsmat.pyx":5835
 *             for j from 0<=j<vec.my_len:
 *                 result.add_count(vec.idx_ptr[j], weight*vec.vals_ptr[j])
 *         return result.to_sparse()             # <<<<<<<<<<<<<<
 *     cpdef add(self, SparseVectorD vec, double weight=1):
 *         self.vecs.append(vec)
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD1 *)__pyx_v_result->__pyx_vtab)->to_sparse(__pyx_v_result, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5825
 *     def __init__(self):
 *        self.vecs = []
 *     cpdef SparseVectorD to_vec(self):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorD vec
 *         cdef double weight
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsD.to_vec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_vec);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_3to_vec(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_3to_vec(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_vec (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_2to_vec(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_2to_vec(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_vec", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_14SparseVectorsD_to_vec(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsD.to_vec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5836
 *                 result.add_count(vec.idx_ptr[j], weight*vec.vals_ptr[j])
 *         return result.to_sparse()
 *     cpdef add(self, SparseVectorD vec, double weight=1):             # <<<<<<<<<<<<<<
 *         self.vecs.append(vec)
 *         self.weights.push_back(weight)
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_5add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5lurrn_8sparsmat_14SparseVectorsD_add(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_vec, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsD_add *__pyx_optional_args) {
  double __pyx_v_weight = ((double)1.0);
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_weight = __pyx_optional_args->weight;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_add); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_5add)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_weight); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_vec));
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_vec));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_vec));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5837
 *         return result.to_sparse()
 *     cpdef add(self, SparseVectorD vec, double weight=1):
 *         self.vecs.append(vec)             # <<<<<<<<<<<<<<
 *         self.weights.push_back(weight)
 *     def __mul__(self, factor):
 */
  __pyx_t_8 = __Pyx_PyObject_Append(__pyx_v_self->vecs, ((PyObject *)__pyx_v_vec)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lurrn/sparsmat.pyx":5838
 *     cpdef add(self, SparseVectorD vec, double weight=1):
 *         self.vecs.append(vec)
 *         self.weights.push_back(weight)             # <<<<<<<<<<<<<<
 *     def __mul__(self, factor):
 *         cdef SparseVectorD vec
 */
  __pyx_v_self->weights.push_back(__pyx_v_weight);

  /* "lurrn/sparsmat.pyx":5836
 *                 result.add_count(vec.idx_ptr[j], weight*vec.vals_ptr[j])
 *         return result.to_sparse()
 *     cpdef add(self, SparseVectorD vec, double weight=1):             # <<<<<<<<<<<<<<
 *         self.vecs.append(vec)
 *         self.weights.push_back(weight)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsD.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_5add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_5add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_vec = 0;
  double __pyx_v_weight;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_vec,&__pyx_n_s_weight,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weight);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5836; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_vec = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)values[0]);
    if (values[1]) {
      __pyx_v_weight = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_weight == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5836; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_weight = ((double)1.0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5836; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsD.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vec), __pyx_ptype_5lurrn_8sparsmat_SparseVectorD, 1, "vec", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_4add(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *)__pyx_v_self), __pyx_v_vec, __pyx_v_weight);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_4add(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_vec, double __pyx_v_weight) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsD_add __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.weight = __pyx_v_weight;
  __pyx_t_1 = __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorsD->add(__pyx_v_self, __pyx_v_vec, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsD.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5839
 *         self.vecs.append(vec)
 *         self.weights.push_back(weight)
 *     def __mul__(self, factor):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorD vec
 *         cdef double weight
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_7__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_factor); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_7__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_factor) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__mul__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_6__mul__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_factor));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_6__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_factor) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_vec = 0;
  double __pyx_v_weight;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_result = 0;
  long __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  double __pyx_t_7;
  struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsD_add __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__mul__", 0);

  /* "lurrn/sparsmat.pyx":5842
 *         cdef SparseVectorD vec
 *         cdef double weight
 *         cdef SparseVectorsD result = SparseVectorsD             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 */
  if (!(likely(((((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsD))) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsD)), __pyx_ptype_5lurrn_8sparsmat_SparseVectorsD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsD));
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5843
 *         cdef double weight
 *         cdef SparseVectorsD result = SparseVectorsD
 *         for i from 0<=i<len(self.vecs):             # <<<<<<<<<<<<<<
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_vecs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5844
 *         cdef SparseVectorsD result = SparseVectorsD
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = self.vecs[i]
 *             result.add(vec, weight*factor)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_weights); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_at); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_weight = __pyx_t_7;

    /* "lurrn/sparsmat.pyx":5845
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]             # <<<<<<<<<<<<<<
 *             result.add(vec, weight*factor)
 *     def __add__(self, others):
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_vecs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_i, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5845; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5lurrn_8sparsmat_SparseVectorD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":5846
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 *             result.add(vec, weight*factor)             # <<<<<<<<<<<<<<
 *     def __add__(self, others):
 *         cdef SparseVectorD vec
 */
    __pyx_t_4 = PyFloat_FromDouble(__pyx_v_weight); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyNumber_Multiply(__pyx_t_4, __pyx_v_factor); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_8.__pyx_n = 1;
    __pyx_t_8.weight = __pyx_t_7;
    __pyx_t_1 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsD *)__pyx_v_result->__pyx_vtab)->add(__pyx_v_result, __pyx_v_vec, 0, &__pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5839
 *         self.vecs.append(vec)
 *         self.weights.push_back(weight)
 *     def __mul__(self, factor):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorD vec
 *         cdef double weight
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsD.__mul__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_vec);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5847
 *             vec = self.vecs[i]
 *             result.add(vec, weight*factor)
 *     def __add__(self, others):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorD vec
 *         cdef double weight
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_9__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_others); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_9__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_others) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_8__add__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_others));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_8__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_others) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_vec = 0;
  double __pyx_v_weight;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_oth_vecs = 0;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_result = 0;
  long __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  double __pyx_t_7;
  struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsD_add __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":5850
 *         cdef SparseVectorD vec
 *         cdef double weight
 *         cdef SparseVectorsD oth_vecs = others             # <<<<<<<<<<<<<<
 *         cdef SparseVectorsD result = SparseVectorsD
 *         for i from 0<=i<len(self.vecs):
 */
  if (!(likely(((__pyx_v_others) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_others, __pyx_ptype_5lurrn_8sparsmat_SparseVectorsD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_others;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_oth_vecs = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5851
 *         cdef double weight
 *         cdef SparseVectorsD oth_vecs = others
 *         cdef SparseVectorsD result = SparseVectorsD             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 */
  if (!(likely(((((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsD))) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsD)), __pyx_ptype_5lurrn_8sparsmat_SparseVectorsD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsD));
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5852
 *         cdef SparseVectorsD oth_vecs = others
 *         cdef SparseVectorsD result = SparseVectorsD
 *         for i from 0<=i<len(self.vecs):             # <<<<<<<<<<<<<<
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_vecs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5853
 *         cdef SparseVectorsD result = SparseVectorsD
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = self.vecs[i]
 *             result.add(vec, weight)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_weights); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_at); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_weight = __pyx_t_7;

    /* "lurrn/sparsmat.pyx":5854
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]             # <<<<<<<<<<<<<<
 *             result.add(vec, weight)
 *         for i from 0<=i<len(oth_vecs.vecs):
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_vecs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_i, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5854; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5lurrn_8sparsmat_SparseVectorD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":5855
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 *             result.add(vec, weight)             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(oth_vecs.vecs):
 *             weight = oth_vecs.weights.at(i)
 */
    __pyx_t_8.__pyx_n = 1;
    __pyx_t_8.weight = __pyx_v_weight;
    __pyx_t_4 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsD *)__pyx_v_result->__pyx_vtab)->add(__pyx_v_result, __pyx_v_vec, 0, &__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }

  /* "lurrn/sparsmat.pyx":5856
 *             vec = self.vecs[i]
 *             result.add(vec, weight)
 *         for i from 0<=i<len(oth_vecs.vecs):             # <<<<<<<<<<<<<<
 *             weight = oth_vecs.weights.at(i)
 *             vec = oth_vecs.vecs[i]
 */
  __pyx_t_4 = __pyx_v_oth_vecs->vecs;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_2 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5857
 *             result.add(vec, weight)
 *         for i from 0<=i<len(oth_vecs.vecs):
 *             weight = oth_vecs.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = oth_vecs.vecs[i]
 *             result.add(vec, weight)
 */
    __pyx_v_weight = __pyx_v_oth_vecs->weights.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":5858
 *         for i from 0<=i<len(oth_vecs.vecs):
 *             weight = oth_vecs.weights.at(i)
 *             vec = oth_vecs.vecs[i]             # <<<<<<<<<<<<<<
 *             result.add(vec, weight)
 *         return result
 */
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_oth_vecs->vecs, __pyx_v_i, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5858; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5lurrn_8sparsmat_SparseVectorD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":5859
 *             weight = oth_vecs.weights.at(i)
 *             vec = oth_vecs.vecs[i]
 *             result.add(vec, weight)             # <<<<<<<<<<<<<<
 *         return result
 *     def __sub__(SparseVectorsD self, SparseVectorsD others):
 */
    __pyx_t_8.__pyx_n = 1;
    __pyx_t_8.weight = __pyx_v_weight;
    __pyx_t_4 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsD *)__pyx_v_result->__pyx_vtab)->add(__pyx_v_result, __pyx_v_vec, 0, &__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }

  /* "lurrn/sparsmat.pyx":5860
 *             vec = oth_vecs.vecs[i]
 *             result.add(vec, weight)
 *         return result             # <<<<<<<<<<<<<<
 *     def __sub__(SparseVectorsD self, SparseVectorsD others):
 *         cdef SparseVectorD vec
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5847
 *             vec = self.vecs[i]
 *             result.add(vec, weight*factor)
 *     def __add__(self, others):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorD vec
 *         cdef double weight
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsD.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_vec);
  __Pyx_XDECREF((PyObject *)__pyx_v_oth_vecs);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5861
 *             result.add(vec, weight)
 *         return result
 *     def __sub__(SparseVectorsD self, SparseVectorsD others):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorD vec
 *         cdef double weight
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_11__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_others); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_11__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_others) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__sub__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_SparseVectorsD, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_others), __pyx_ptype_5lurrn_8sparsmat_SparseVectorsD, 1, "others", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_10__sub__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *)__pyx_v_others));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_10__sub__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_others) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_vec = 0;
  double __pyx_v_weight;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_oth_vecs = 0;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_result = 0;
  long __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsD_add __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__sub__", 0);

  /* "lurrn/sparsmat.pyx":5864
 *         cdef SparseVectorD vec
 *         cdef double weight
 *         cdef SparseVectorsD oth_vecs = others             # <<<<<<<<<<<<<<
 *         cdef SparseVectorsD result = SparseVectorsD()
 *         for i from 0<=i<len(self.vecs):
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_others));
  __pyx_v_oth_vecs = __pyx_v_others;

  /* "lurrn/sparsmat.pyx":5865
 *         cdef double weight
 *         cdef SparseVectorsD oth_vecs = others
 *         cdef SparseVectorsD result = SparseVectorsD()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorsD)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5866
 *         cdef SparseVectorsD oth_vecs = others
 *         cdef SparseVectorsD result = SparseVectorsD()
 *         for i from 0<=i<len(self.vecs):             # <<<<<<<<<<<<<<
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 */
  __pyx_t_1 = __pyx_v_self->vecs;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5867
 *         cdef SparseVectorsD result = SparseVectorsD()
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = self.vecs[i]
 *             result.add(vec, weight)
 */
    __pyx_v_weight = __pyx_v_self->weights.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":5868
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]             # <<<<<<<<<<<<<<
 *             result.add(vec, weight)
 *         for i from 0<=i<len(oth_vecs.vecs):
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->vecs, __pyx_v_i, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5868; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_SparseVectorD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":5869
 *             weight = self.weights.at(i)
 *             vec = self.vecs[i]
 *             result.add(vec, weight)             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(oth_vecs.vecs):
 *             weight = oth_vecs.weights.at(i)
 */
    __pyx_t_3.__pyx_n = 1;
    __pyx_t_3.weight = __pyx_v_weight;
    __pyx_t_1 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsD *)__pyx_v_result->__pyx_vtab)->add(__pyx_v_result, __pyx_v_vec, 0, &__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5870
 *             vec = self.vecs[i]
 *             result.add(vec, weight)
 *         for i from 0<=i<len(oth_vecs.vecs):             # <<<<<<<<<<<<<<
 *             weight = oth_vecs.weights.at(i)
 *             vec = oth_vecs.vecs[i]
 */
  __pyx_t_1 = __pyx_v_oth_vecs->vecs;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5871
 *             result.add(vec, weight)
 *         for i from 0<=i<len(oth_vecs.vecs):
 *             weight = oth_vecs.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = oth_vecs.vecs[i]
 *             result.add(vec, -weight)
 */
    __pyx_v_weight = __pyx_v_oth_vecs->weights.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":5872
 *         for i from 0<=i<len(oth_vecs.vecs):
 *             weight = oth_vecs.weights.at(i)
 *             vec = oth_vecs.vecs[i]             # <<<<<<<<<<<<<<
 *             result.add(vec, -weight)
 *         return result
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_oth_vecs->vecs, __pyx_v_i, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5872; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_SparseVectorD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":5873
 *             weight = oth_vecs.weights.at(i)
 *             vec = oth_vecs.vecs[i]
 *             result.add(vec, -weight)             # <<<<<<<<<<<<<<
 *         return result
 *     cdef double _dotFull(self, const_double_ptr full_ptr):
 */
    __pyx_t_3.__pyx_n = 1;
    __pyx_t_3.weight = (-__pyx_v_weight);
    __pyx_t_1 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsD *)__pyx_v_result->__pyx_vtab)->add(__pyx_v_result, __pyx_v_vec, 0, &__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5874
 *             vec = oth_vecs.vecs[i]
 *             result.add(vec, -weight)
 *         return result             # <<<<<<<<<<<<<<
 *     cdef double _dotFull(self, const_double_ptr full_ptr):
 *         cdef size_t i, j
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5861
 *             result.add(vec, weight)
 *         return result
 *     def __sub__(SparseVectorsD self, SparseVectorsD others):             # <<<<<<<<<<<<<<
 *         cdef SparseVectorD vec
 *         cdef double weight
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsD.__sub__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_vec);
  __Pyx_XDECREF((PyObject *)__pyx_v_oth_vecs);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5875
 *             result.add(vec, -weight)
 *         return result
 *     cdef double _dotFull(self, const_double_ptr full_ptr):             # <<<<<<<<<<<<<<
 *         cdef size_t i, j
 *         cdef double weight
 */

static double __pyx_f_5lurrn_8sparsmat_14SparseVectorsD__dotFull(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_self, const double * __pyx_v_full_ptr) {
  size_t __pyx_v_i;
  size_t __pyx_v_j;
  double __pyx_v_weight;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *__pyx_v_vec = 0;
  double __pyx_v_result;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  unsigned int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_dotFull", 0);

  /* "lurrn/sparsmat.pyx":5879
 *         cdef double weight
 *         cdef SparseVectorD vec
 *         cdef double result=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 */
  __pyx_v_result = 0.0;

  /* "lurrn/sparsmat.pyx":5880
 *         cdef SparseVectorD vec
 *         cdef double result=0
 *         for i from 0<=i<len(self.vecs):             # <<<<<<<<<<<<<<
 *             weight = self.weights.at(i)
 *             vec = self.vecs.at(i)
 */
  __pyx_t_1 = __pyx_v_self->vecs;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5881
 *         cdef double result=0
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)             # <<<<<<<<<<<<<<
 *             vec = self.vecs.at(i)
 *             for j from 0<=j<vec.my_len:
 */
    __pyx_v_weight = __pyx_v_self->weights.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":5882
 *         for i from 0<=i<len(self.vecs):
 *             weight = self.weights.at(i)
 *             vec = self.vecs.at(i)             # <<<<<<<<<<<<<<
 *             for j from 0<=j<vec.my_len:
 *                 result += full_ptr[vec.indices[j]]*weight*vec.vals_ptr[j]
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->vecs, __pyx_n_s_at); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5lurrn_8sparsmat_SparseVectorD))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_vec, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":5883
 *             weight = self.weights.at(i)
 *             vec = self.vecs.at(i)
 *             for j from 0<=j<vec.my_len:             # <<<<<<<<<<<<<<
 *                 result += full_ptr[vec.indices[j]]*weight*vec.vals_ptr[j]
 *         return result
 */
    __pyx_t_7 = __pyx_v_vec->my_len;
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_7; __pyx_v_j++) {

      /* "lurrn/sparsmat.pyx":5884
 *             vec = self.vecs.at(i)
 *             for j from 0<=j<vec.my_len:
 *                 result += full_ptr[vec.indices[j]]*weight*vec.vals_ptr[j]             # <<<<<<<<<<<<<<
 *         return result
 *     def __len__(self):
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_vec), __pyx_n_s_indices); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_j, size_t, 0, __Pyx_PyInt_FromSize_t, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5884; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_result = (__pyx_v_result + (((__pyx_v_full_ptr[__pyx_t_8]) * __pyx_v_weight) * (__pyx_v_vec->vals_ptr[__pyx_v_j])));
    }
  }

  /* "lurrn/sparsmat.pyx":5885
 *             for j from 0<=j<vec.my_len:
 *                 result += full_ptr[vec.indices[j]]*weight*vec.vals_ptr[j]
 *         return result             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return len(self.vecs)
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5875
 *             result.add(vec, -weight)
 *         return result
 *     cdef double _dotFull(self, const_double_ptr full_ptr):             # <<<<<<<<<<<<<<
 *         cdef size_t i, j
 *         cdef double weight
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.SparseVectorsD._dotFull", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_vec);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5886
 *                 result += full_ptr[vec.indices[j]]*weight*vec.vals_ptr[j]
 *         return result
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return len(self.vecs)
 *     def __getitem__(self, k):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_13__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_13__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_12__len__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_12__len__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":5887
 *         return result
 *     def __len__(self):
 *         return len(self.vecs)             # <<<<<<<<<<<<<<
 *     def __getitem__(self, k):
 *         vec = self.vecs[k]
 */
  __pyx_t_1 = __pyx_v_self->vecs;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5886
 *                 result += full_ptr[vec.indices[j]]*weight*vec.vals_ptr[j]
 *         return result
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return len(self.vecs)
 *     def __getitem__(self, k):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsD.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5888
 *     def __len__(self):
 *         return len(self.vecs)
 *     def __getitem__(self, k):             # <<<<<<<<<<<<<<
 *         vec = self.vecs[k]
 *         return (self.weights.at(k), vec)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_15__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_k); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_15__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_14__getitem__(((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *)__pyx_v_self), ((PyObject *)__pyx_v_k));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_14SparseVectorsD_14__getitem__(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_v_vec = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "lurrn/sparsmat.pyx":5889
 *         return len(self.vecs)
 *     def __getitem__(self, k):
 *         vec = self.vecs[k]             # <<<<<<<<<<<<<<
 *         return (self.weights.at(k), vec)
 * ## V -> void
 */
  __pyx_t_1 = PyObject_GetItem(__pyx_v_self->vecs, __pyx_v_k); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5889; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_vec = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5890
 *     def __getitem__(self, k):
 *         vec = self.vecs[k]
 *         return (self.weights.at(k), vec)             # <<<<<<<<<<<<<<
 * ## V -> void
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_v_k); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->weights.at(__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_vec);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_vec);
  __Pyx_GIVEREF(__pyx_v_vec);
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5888
 *     def __len__(self):
 *         return len(self.vecs)
 *     def __getitem__(self, k):             # <<<<<<<<<<<<<<
 *         vec = self.vecs[k]
 *         return (self.weights.at(k), vec)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.SparseVectorsD.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_vec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5898
 * cdef class VecV1:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_5VecV1_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_5VecV1_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1___init__(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_5VecV1___init__(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":5899
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     def item_iter(self):
 *         self.ensure_compact()
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":5898
 * cdef class VecV1:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5900
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecV1_iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("item_iter (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1_2item_iter(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("item_iter", 0);

  /* "lurrn/sparsmat.pyx":5901
 *         self.is_compact=True
 *     def item_iter(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return IVecV1_iter(self)
 *     def get_size(self,compactify=True):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":5902
 *     def item_iter(self):
 *         self.ensure_compact()
 *         return IVecV1_iter(self)             # <<<<<<<<<<<<<<
 *     def get_size(self,compactify=True):
 *         if compactify:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_IVecV1_iter)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5900
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecV1_iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.item_iter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5903
 *         self.ensure_compact()
 *         return IVecV1_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5903; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5903; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1_4get_size(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":5904
 *         return IVecV1_iter(self)
 *     def get_size(self,compactify=True):
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *         return self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":5905
 *     def get_size(self,compactify=True):
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return self.vec.size()
 *     def __len__(self):
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":5906
 *         if compactify:
 *             self.ensure_compact()
 *         return self.vec.size()             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return self.get_size(True)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_self->vec.size()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5903
 *         self.ensure_compact()
 *         return IVecV1_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5907
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecV1_7__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecV1_7__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1_6__len__(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecV1_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":5908
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__73, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5907
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5909
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1_8clear(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear", 0);

  /* "lurrn/sparsmat.pyx":5910
 *         return self.get_size(True)
 *     def clear(self):
 *         self.vec.resize(0)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void compactify(self):
 */
  __pyx_v_self->vec.resize(0);

  /* "lurrn/sparsmat.pyx":5911
 *     def clear(self):
 *         self.vec.resize(0)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrV1 comp
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":5909
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5912
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrV1 comp
 *         c_IVecV1_sort(self.vec.begin(),self.vec.end(),comp)
 */

static void __pyx_f_5lurrn_8sparsmat_5VecV1_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self) {
  struct smallerAddr<1,void> __pyx_v_comp;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compactify", 0);

  /* "lurrn/sparsmat.pyx":5914
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrV1 comp
 *         c_IVecV1_sort(self.vec.begin(),self.vec.end(),comp)             # <<<<<<<<<<<<<<
 *         c_compactifyV1(&self.vec)
 *         self.is_compact=True
 */
  sort(__pyx_v_self->vec.begin(), __pyx_v_self->vec.end(), __pyx_v_comp);

  /* "lurrn/sparsmat.pyx":5915
 *         cdef c_SmallerAddrV1 comp
 *         c_IVecV1_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyV1(&self.vec)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 */
  compactify_set((&__pyx_v_self->vec));

  /* "lurrn/sparsmat.pyx":5916
 *         c_IVecV1_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyV1(&self.vec)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":5912
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrV1 comp
 *         c_IVecV1_sort(self.vec.begin(),self.vec.end(),comp)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":5917
 *         c_compactifyV1(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

static void __pyx_f_5lurrn_8sparsmat_5VecV1_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":5918
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:             # <<<<<<<<<<<<<<
 *             self.compactify()
 *     cpdef bint get_count(self,coordinate_t k0):
 */
  __pyx_t_1 = ((!(__pyx_v_self->is_compact != 0)) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":5919
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 *             self.compactify()             # <<<<<<<<<<<<<<
 *     cpdef bint get_count(self,coordinate_t k0):
 *         cdef c_CItemV1 ci
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV1 *)__pyx_v_self->__pyx_vtab)->compactify(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":5917
 *         c_compactifyV1(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":5920
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef bint get_count(self,coordinate_t k0):             # <<<<<<<<<<<<<<
 *         cdef c_CItemV1 ci
 *         ci.addr[0]=k0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_arg_k0); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecV1_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, coordinate_t __pyx_v_k0, int __pyx_skip_dispatch) {
  struct CountItem<1,void> __pyx_v_ci;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV1_11get_count)) {
      __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":5922
 *     cpdef bint get_count(self,coordinate_t k0):
 *         cdef c_CItemV1 ci
 *         ci.addr[0]=k0             # <<<<<<<<<<<<<<
 *         return c_get_countV1(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0):
 */
  (__pyx_v_ci.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":5923
 *         cdef c_CItemV1 ci
 *         ci.addr[0]=k0
 *         return c_get_countV1(&self.vec,ci)             # <<<<<<<<<<<<<<
 *     cdef void c_add(self, coordinate_t k0):
 *         cdef c_CItemV1 c
 */
  __pyx_r = get_count_set((&__pyx_v_self->vec), __pyx_v_ci);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5920
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef bint get_count(self,coordinate_t k0):             # <<<<<<<<<<<<<<
 *         cdef c_CItemV1 ci
 *         ci.addr[0]=k0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecV1.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_arg_k0); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_arg_k0) {
  coordinate_t __pyx_v_k0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_count (wrapper)", 0);
  assert(__pyx_arg_k0); {
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(__pyx_arg_k0); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5920; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1_10get_count(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self), ((coordinate_t)__pyx_v_k0));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, coordinate_t __pyx_v_k0) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_5lurrn_8sparsmat_5VecV1_get_count(__pyx_v_self, __pyx_v_k0, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5924
 *         ci.addr[0]=k0
 *         return c_get_countV1(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0):             # <<<<<<<<<<<<<<
 *         cdef c_CItemV1 c
 *         c.addr[0]=k0
 */

static void __pyx_f_5lurrn_8sparsmat_5VecV1_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, coordinate_t __pyx_v_k0) {
  struct CountItem<1,void> __pyx_v_c;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_add", 0);

  /* "lurrn/sparsmat.pyx":5926
 *     cdef void c_add(self, coordinate_t k0):
 *         cdef c_CItemV1 c
 *         c.addr[0]=k0             # <<<<<<<<<<<<<<
 *         self.vec.push_back(c)
 *         self.is_compact=False
 */
  (__pyx_v_c.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":5927
 *         cdef c_CItemV1 c
 *         c.addr[0]=k0
 *         self.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0):
 */
  __pyx_v_self->vec.push_back(__pyx_v_c);

  /* "lurrn/sparsmat.pyx":5928
 *         c.addr[0]=k0
 *         self.vec.push_back(c)
 *         self.is_compact=False             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0):
 *         self.c_add(k0)
 */
  __pyx_v_self->is_compact = 0;

  /* "lurrn/sparsmat.pyx":5924
 *         ci.addr[0]=k0
 *         return c_get_countV1(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0):             # <<<<<<<<<<<<<<
 *         cdef c_CItemV1 c
 *         c.addr[0]=k0
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":5929
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0):             # <<<<<<<<<<<<<<
 *         self.c_add(k0)
 *     def __add__(VecV1 self, VecV1 other):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_arg_k0); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_arg_k0) {
  coordinate_t __pyx_v_k0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  assert(__pyx_arg_k0); {
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(__pyx_arg_k0); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5929; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1_12add_count(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self), ((coordinate_t)__pyx_v_k0));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, coordinate_t __pyx_v_k0) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":5930
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0):
 *         self.c_add(k0)             # <<<<<<<<<<<<<<
 *     def __add__(VecV1 self, VecV1 other):
 *         cdef c_CItemV1 c1, c2
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV1 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_v_k0);

  /* "lurrn/sparsmat.pyx":5929
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0):             # <<<<<<<<<<<<<<
 *         self.c_add(k0)
 *     def __add__(VecV1 self, VecV1 other):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5931
 *     def add_count(self, coordinate_t k0):
 *         self.c_add(k0)
 *     def __add__(VecV1 self, VecV1 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemV1 c1, c2
 *         cdef unsigned int i1, i2
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_VecV1, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_VecV1, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1_14__add__(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_other) {
  struct CountItem<1,void> __pyx_v_c1;
  struct CountItem<1,void> __pyx_v_c2;
  unsigned int __pyx_v_i1;
  unsigned int __pyx_v_i2;
  int __pyx_v_k;
  int __pyx_v_delta;
  struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":5936
 *         cdef int k, delta
 *         cdef VecV1 result
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         other.ensure_compact()
 *         result=VecV1()
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":5937
 *         cdef VecV1 result
 *         self.ensure_compact()
 *         other.ensure_compact()             # <<<<<<<<<<<<<<
 *         result=VecV1()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV1 *)__pyx_v_other->__pyx_vtab)->ensure_compact(__pyx_v_other);

  /* "lurrn/sparsmat.pyx":5938
 *         self.ensure_compact()
 *         other.ensure_compact()
 *         result=VecV1()             # <<<<<<<<<<<<<<
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5939
 *         other.ensure_compact()
 *         result=VecV1()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))             # <<<<<<<<<<<<<<
 *         i1=0
 *         i2=0
 */
  __pyx_t_2 = __pyx_v_other->vec.size();
  __pyx_t_3 = __pyx_v_self->vec.size();
  if (((__pyx_t_2 > __pyx_t_3) != 0)) {
    __pyx_t_4 = __pyx_t_2;
  } else {
    __pyx_t_4 = __pyx_t_3;
  }
  __pyx_v_result->vec.reserve(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":5940
 *         result=VecV1()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0             # <<<<<<<<<<<<<<
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 */
  __pyx_v_i1 = 0;

  /* "lurrn/sparsmat.pyx":5941
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 *         i2=0             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 */
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":5942
 *         i1=0
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 */
  while (1) {
    __pyx_t_6 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_6 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":5943
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             delta=0
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":5944
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             delta=0
 *             for k from 0<=k<1:
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":5945
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 *             delta=0             # <<<<<<<<<<<<<<
 *             for k from 0<=k<1:
 *                 if c1.addr[k]<c2.addr[k]:
 */
    __pyx_v_delta = 0;

    /* "lurrn/sparsmat.pyx":5946
 *             c2=other.vec.at(i2)
 *             delta=0
 *             for k from 0<=k<1:             # <<<<<<<<<<<<<<
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 */
    for (__pyx_v_k = 0; __pyx_v_k < 1; __pyx_v_k++) {

      /* "lurrn/sparsmat.pyx":5947
 *             delta=0
 *             for k from 0<=k<1:
 *                 if c1.addr[k]<c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=-1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) < (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":5948
 *             for k from 0<=k<1:
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1             # <<<<<<<<<<<<<<
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 */
        __pyx_v_delta = -1;

        /* "lurrn/sparsmat.pyx":5949
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 *                     break             # <<<<<<<<<<<<<<
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 */
        goto __pyx_L8_break;
      }

      /* "lurrn/sparsmat.pyx":5950
 *                     delta=-1
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) > (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":5951
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1             # <<<<<<<<<<<<<<
 *                     break
 *             if delta==0:
 */
        __pyx_v_delta = 1;

        /* "lurrn/sparsmat.pyx":5952
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 *                     break             # <<<<<<<<<<<<<<
 *             if delta==0:
 *                 result.vec.push_back(c1)
 */
        goto __pyx_L8_break;
      }
    }
    __pyx_L8_break:;

    /* "lurrn/sparsmat.pyx":5957
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
    switch (__pyx_v_delta) {

      /* "lurrn/sparsmat.pyx":5953
 *                     delta=1
 *                     break
 *             if delta==0:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      case 0:

      /* "lurrn/sparsmat.pyx":5954
 *                     break
 *             if delta==0:
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *                 i2+=1
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":5955
 *             if delta==0:
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *                 i2+=1
 *             elif delta==-1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);

      /* "lurrn/sparsmat.pyx":5956
 *                 result.vec.push_back(c1)
 *                 i1+=1
 *                 i2+=1             # <<<<<<<<<<<<<<
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;

      /* "lurrn/sparsmat.pyx":5957
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      case -1:

      /* "lurrn/sparsmat.pyx":5958
 *                 i2+=1
 *             elif delta==-1:
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             else:
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":5959
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             else:
 *                 result.vec.push_back(c2)
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      break;
      default:

      /* "lurrn/sparsmat.pyx":5961
 *                 i1+=1
 *             else:
 *                 result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *                 i2+=1
 *         while i1<self.vec.size():
 */
      __pyx_v_result->vec.push_back(__pyx_v_c2);

      /* "lurrn/sparsmat.pyx":5962
 *             else:
 *                 result.vec.push_back(c2)
 *                 i2+=1             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;
    }
  }

  /* "lurrn/sparsmat.pyx":5963
 *                 result.vec.push_back(c2)
 *                 i2+=1
 *         while i1<self.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":5964
 *                 i2+=1
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c1)
 *             i1+=1
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":5965
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *             i1+=1
 *         while i2<other.vec.size():
 */
    __pyx_v_result->vec.push_back(__pyx_v_c1);

    /* "lurrn/sparsmat.pyx":5966
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 *             i1+=1             # <<<<<<<<<<<<<<
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);
  }

  /* "lurrn/sparsmat.pyx":5967
 *             result.vec.push_back(c1)
 *             i1+=1
 *         while i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":5968
 *             i1+=1
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c2)
 *             i2+=1
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":5969
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *             i2+=1
 *         return result
 */
    __pyx_v_result->vec.push_back(__pyx_v_c2);

    /* "lurrn/sparsmat.pyx":5970
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 *             i2+=1             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_v_i2 = (__pyx_v_i2 + 1);
  }

  /* "lurrn/sparsmat.pyx":5971
 *             result.vec.push_back(c2)
 *             i2+=1
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def to_array(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5931
 *     def add_count(self, coordinate_t k0):
 *         self.c_add(k0)
 *     def __add__(VecV1 self, VecV1 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemV1 c1, c2
 *         cdef unsigned int i1, i2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5973
 *         return result
 * 
 *     def to_array(self):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t n, i
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_17to_array(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_17to_array(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_array (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1_16to_array(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_16to_array(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self) {
  coordinate_t __pyx_v_n;
  coordinate_t __pyx_v_i;
  PyArrayObject *__pyx_v_result = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  coordinate_t __pyx_t_13;
  coordinate_t __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_array", 0);
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;

  /* "lurrn/sparsmat.pyx":5976
 *         cdef coordinate_t n, i
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         result=numpy.zeros(n, numpy.int32)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":5977
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         self.ensure_compact()
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         result=numpy.zeros(n, numpy.int32)
 *         for i from 0<=i<n:
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":5978
 *         self.ensure_compact()
 *         n=self.vec.size()
 *         result=numpy.zeros(n, numpy.int32)             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             result[i]=self.vec.at(i).addr[0]
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_coordinate_t(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __pyx_v_result = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5979
 *         n=self.vec.size()
 *         result=numpy.zeros(n, numpy.int32)
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             result[i]=self.vec.at(i).addr[0]
 *         return result
 */
  __pyx_t_13 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_13; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5980
 *         result=numpy.zeros(n, numpy.int32)
 *         for i from 0<=i<n:
 *             result[i]=self.vec.at(i).addr[0]             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_t_14 = __pyx_v_i;
    __pyx_t_9 = -1;
    if (unlikely(__pyx_t_14 >= (size_t)__pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_9 = 0;
    if (unlikely(__pyx_t_9 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_9);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_result.diminfo[0].strides) = (__pyx_v_self->vec.at(__pyx_v_i).addr[0]);
  }

  /* "lurrn/sparsmat.pyx":5981
 *         for i from 0<=i<n:
 *             result[i]=self.vec.at(i).addr[0]
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def tofile(self, f):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":5973
 *         return result
 * 
 *     def to_array(self):             # <<<<<<<<<<<<<<
 *         cdef coordinate_t n, i
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.to_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5983
 *         return result
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_19tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_19tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tofile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1_18tofile(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_18tofile(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  long __pyx_v_k;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  long __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("tofile", 0);

  /* "lurrn/sparsmat.pyx":5985
 *     def tofile(self, f):
 *         cdef long i, n, k, k_max
 *         n=self.get_size()             # <<<<<<<<<<<<<<
 *         f.write('V1 %d\n'%(n,))
 *         k=0
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":5986
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 *         f.write('V1 %d\n'%(n,))             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_V1_d, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5987
 *         n=self.get_size()
 *         f.write('V1 %d\n'%(n,))
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecV1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemV1))
 */
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":5988
 *         f.write('V1 %d\n'%(n,))
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecV1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemV1))
 *             f.write(s)
 */
  __pyx_t_4 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":5989
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecV1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemV1))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *             k+=CHUNK_SIZE
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), (256 * (sizeof(struct CountItem<1,void>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":5990
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecV1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemV1))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":5991
 *             s=PyString_FromStringAndSize(<char *>c_VecV1_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemV1))
 *             f.write(s)
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecV1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemV1))
 */
    __pyx_v_k = (__pyx_v_k + 256);
  }

  /* "lurrn/sparsmat.pyx":5992
 *             f.write(s)
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecV1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemV1))
 *             f.write(s)
 */
  __pyx_t_7 = ((__pyx_v_k < __pyx_v_n) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":5993
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecV1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemV1))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *     def fromfile(self, f):
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), ((__pyx_v_n - __pyx_v_k) * (sizeof(struct CountItem<1,void>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":5994
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecV1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemV1))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *     def fromfile(self, f):
 *         cdef long i, n
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":5983
 *         return result
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.tofile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":5995
 *             s=PyString_FromStringAndSize(<char *>c_VecV1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemV1))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_21fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_21fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fromfile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1_20fromfile(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_20fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  PyObject *__pyx_v_line = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  long __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  size_t __pyx_t_9;
  char *__pyx_t_10;
  size_t __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromfile", 0);

  /* "lurrn/sparsmat.pyx":5997
 *     def fromfile(self, f):
 *         cdef long i, n
 *         line=f.readline().strip().split()             # <<<<<<<<<<<<<<
 *         assert line[0]=='V1'
 *         n=long(line[1])
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_readline); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_line = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5998
 *         cdef long i, n
 *         line=f.readline().strip().split()
 *         assert line[0]=='V1'             # <<<<<<<<<<<<<<
 *         n=long(line[1])
 *         self.clear()
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5998; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_V1, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_6)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":5999
 *         line=f.readline().strip().split()
 *         assert line[0]=='V1'
 *         n=long(line[1])             # <<<<<<<<<<<<<<
 *         self.clear()
 *         self.vec.resize(n)
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5999; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyLong_Type))), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_7;

  /* "lurrn/sparsmat.pyx":6000
 *         assert line[0]=='V1'
 *         n=long(line[1])
 *         self.clear()             # <<<<<<<<<<<<<<
 *         self.vec.resize(n)
 *         k=0
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clear); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6001
 *         n=long(line[1])
 *         self.clear()
 *         self.vec.resize(n)             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_v_self->vec.resize(__pyx_v_n);

  /* "lurrn/sparsmat.pyx":6002
 *         self.clear()
 *         self.vec.resize(n)
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemV1))
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_k = __pyx_int_0;

  /* "lurrn/sparsmat.pyx":6003
 *         self.vec.resize(n)
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemV1))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemV1)
 */
  __pyx_t_7 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":6004
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemV1))             # <<<<<<<<<<<<<<
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemV1)
 *             memcpy(<void *>c_VecV1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemV1))
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyInt_FromSize_t((256 * (sizeof(struct CountItem<1,void>)))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":6005
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemV1))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemV1)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecV1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemV1))
 *             k+=CHUNK_SIZE
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!((__pyx_t_8 == (256 * (sizeof(struct CountItem<1,void>)))) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":6006
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemV1))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemV1)
 *             memcpy(<void *>c_VecV1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemV1))             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), (256 * (sizeof(struct CountItem<1,void>))));

    /* "lurrn/sparsmat.pyx":6007
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemV1)
 *             memcpy(<void *>c_VecV1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemV1))
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemV1))
 */
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_k, __pyx_int_256); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_1);
    __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":6008
 *             memcpy(<void *>c_VecV1_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemV1))
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=f.read((n-k)*sizeof(c_CItemV1))
 *             assert len(s)==(n-k)*sizeof(c_CItemV1)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":6009
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemV1))             # <<<<<<<<<<<<<<
 *             assert len(s)==(n-k)*sizeof(c_CItemV1)
 *             memcpy(<void *>c_VecV1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemV1))
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_5, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<1,void>))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":6010
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemV1))
 *             assert len(s)==(n-k)*sizeof(c_CItemV1)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecV1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemV1))
 *     cpdef int get_maxcol(self, int k=0):
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<1,void>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_6)) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":6011
 *             s=f.read((n-k)*sizeof(c_CItemV1))
 *             assert len(s)==(n-k)*sizeof(c_CItemV1)
 *             memcpy(<void *>c_VecV1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemV1))             # <<<<<<<<<<<<<<
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<1,void>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), __pyx_t_11);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":5995
 *             s=PyString_FromStringAndSize(<char *>c_VecV1_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemV1))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.fromfile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_line);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6012
 *             assert len(s)==(n-k)*sizeof(c_CItemV1)
 *             memcpy(<void *>c_VecV1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemV1))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<1
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecV1_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV1_get_maxcol *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_i;
  int __pyx_v_n;
  int __pyx_v_new_val;
  int __pyx_v_col;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_maxcol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV1_23get_maxcol)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":6014
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<1             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         if n==0:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_9 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_9 = ((__pyx_v_k < 1) != 0);
    __pyx_t_8 = __pyx_t_9;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_8)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":6015
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<1
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         if n==0:
 *             return -1
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":6016
 *         assert k>=0 and k<1
 *         n=self.vec.size()
 *         if n==0:             # <<<<<<<<<<<<<<
 *             return -1
 *         if k==0:
 */
  __pyx_t_8 = ((__pyx_v_n == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":6017
 *         n=self.vec.size()
 *         if n==0:
 *             return -1             # <<<<<<<<<<<<<<
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 */
    __pyx_r = -1;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":6018
 *         if n==0:
 *             return -1
 *         if k==0:             # <<<<<<<<<<<<<<
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 */
  __pyx_t_8 = ((__pyx_v_k == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":6019
 *             return -1
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]             # <<<<<<<<<<<<<<
 *         col=-1
 *         n=self.vec.size()
 */
    __pyx_r = (__pyx_v_self->vec.at((__pyx_v_n - 1)).addr[0]);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":6020
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 *         col=-1             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_v_col = -1;

  /* "lurrn/sparsmat.pyx":6021
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":6022
 *         col=-1
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 */
  __pyx_t_7 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":6023
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             if new_val>col:
 *                 col=new_val
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":6024
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:             # <<<<<<<<<<<<<<
 *                 col=new_val
 *         return col
 */
    __pyx_t_8 = ((__pyx_v_new_val > __pyx_v_col) != 0);
    if (__pyx_t_8) {

      /* "lurrn/sparsmat.pyx":6025
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 *                 col=new_val             # <<<<<<<<<<<<<<
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 */
      __pyx_v_col = __pyx_v_new_val;
      goto __pyx_L9;
    }
    __pyx_L9:;
  }

  /* "lurrn/sparsmat.pyx":6026
 *             if new_val>col:
 *                 col=new_val
 *         return col             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 *         cdef int old_val, new_val, i, n, count
 */
  __pyx_r = __pyx_v_col;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6012
 *             assert len(s)==(n-k)*sizeof(c_CItemV1)
 *             memcpy(<void *>c_VecV1_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemV1))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecV1.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_23get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_maxcol (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_maxcol") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6012; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6012; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_maxcol", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6012; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1_22get_maxcol(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_22get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecV1_get_maxcol __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = __pyx_vtabptr_5lurrn_8sparsmat_VecV1->get_maxcol(__pyx_v_self, 1, &__pyx_t_2); 
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6027
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecV1_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV1_get_type_counts *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_new_val;
  int __pyx_v_i;
  int __pyx_v_n;
  PyArrayObject *__pyx_v_result = 0;
  long __pyx_v_n_types;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecV1_get_maxcol __pyx_t_11;
  PyArrayObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV1_25get_type_counts)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":6030
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<1             # <<<<<<<<<<<<<<
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_8 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_k < 1) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_7)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":6031
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<1
 *         if self.vec.size()==0:             # <<<<<<<<<<<<<<
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 */
  __pyx_t_7 = ((__pyx_v_self->vec.size() == 0) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":6032
 *         assert k>=0 and k<1
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_9 = 1;
      }
    }
    __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_2) {
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":6033
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":6034
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1             # <<<<<<<<<<<<<<
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 */
  __pyx_t_11.__pyx_n = 1;
  __pyx_t_11.k = __pyx_v_k;
  __pyx_t_10 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV1 *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0, &__pyx_t_11); 
  __pyx_v_n_types = (__pyx_t_10 + 1);

  /* "lurrn/sparsmat.pyx":6035
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_n_types); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_9 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_6) {
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_12 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
    }
    __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_12 = 0;
  __pyx_v_result = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6036
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":6037
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":6038
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             result[new_val]+=1
 *         return result
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":6039
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1             # <<<<<<<<<<<<<<
 *         return result
 *     cpdef VecV1 remap(self, int k, numpy.ndarray filt):
 */
    __pyx_t_16 = __pyx_v_new_val;
    __pyx_t_17 = -1;
    if (__pyx_t_16 < 0) {
      __pyx_t_16 += __pyx_pybuffernd_result.diminfo[0].shape;
      if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 0;
    } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_17 = 0;
    if (unlikely(__pyx_t_17 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_17);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_result.diminfo[0].strides) += 1;
  }

  /* "lurrn/sparsmat.pyx":6040
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 *         return result             # <<<<<<<<<<<<<<
 *     cpdef VecV1 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyArrayObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6027
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_25get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6027; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6027; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6027; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1_24get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_24get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecV1_get_type_counts __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_5lurrn_8sparsmat_VecV1->get_type_counts(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6041
 *             result[new_val]+=1
 *         return result
 *     cpdef VecV1 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_f_5lurrn_8sparsmat_5VecV1_remap(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_wanted = 0;
  PyArrayObject *__pyx_v_target = 0;
  int __pyx_v_n;
  int __pyx_v_i;
  struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_result = 0;
  struct CountItem<1,void> __pyx_v_c;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_target;
  __Pyx_Buffer __pyx_pybuffer_target;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_wanted;
  __Pyx_Buffer __pyx_pybuffer_wanted;
  struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __pyx_pybuffer_wanted.pybuffer.buf = NULL;
  __pyx_pybuffer_wanted.refcount = 0;
  __pyx_pybuffernd_wanted.data = NULL;
  __pyx_pybuffernd_wanted.rcbuffer = &__pyx_pybuffer_wanted;
  __pyx_pybuffer_target.pybuffer.buf = NULL;
  __pyx_pybuffer_target.refcount = 0;
  __pyx_pybuffernd_target.data = NULL;
  __pyx_pybuffernd_target.rcbuffer = &__pyx_pybuffer_target;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_remap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV1_27remap)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_filt));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_filt));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_filt));
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_VecV1))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":6042
 *         return result
 *     cpdef VecV1 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__74, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_wanted = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_wanted.diminfo[0].strides = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_wanted.diminfo[0].shape = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_8 = 0;
  __pyx_v_wanted = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6043
 *     cpdef VecV1 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_cumsum); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Subtract(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_target = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_target.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_target.diminfo[0].strides = __pyx_pybuffernd_target.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_target.diminfo[0].shape = __pyx_pybuffernd_target.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_9 = 0;
  __pyx_v_target = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6044
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         cdef int n=self.vec.size()
 *         cdef int i
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV1 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":6045
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()             # <<<<<<<<<<<<<<
 *         cdef int i
 *         cdef VecV1 result=VecV1()
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":6047
 *         cdef int n=self.vec.size()
 *         cdef int i
 *         cdef VecV1 result=VecV1()             # <<<<<<<<<<<<<<
 *         cdef c_CItemV1 c
 *         for i from 0<=i<n:
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6049
 *         cdef VecV1 result=VecV1()
 *         cdef c_CItemV1 c
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":6050
 *         cdef c_CItemV1 c
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)             # <<<<<<<<<<<<<<
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 */
    __pyx_v_c = __pyx_v_self->vec.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":6051
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:             # <<<<<<<<<<<<<<
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 */
    __pyx_t_11 = (__pyx_v_c.addr[__pyx_v_k]);
    __pyx_t_12 = -1;
    if (__pyx_t_11 < 0) {
      __pyx_t_11 += __pyx_pybuffernd_wanted.diminfo[0].shape;
      if (unlikely(__pyx_t_11 < 0)) __pyx_t_12 = 0;
    } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_wanted.diminfo[0].shape)) __pyx_t_12 = 0;
    if (unlikely(__pyx_t_12 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_12);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_wanted.diminfo[0].strides)) != 0);
    if (__pyx_t_13) {

      /* "lurrn/sparsmat.pyx":6052
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c)
 *         return result
 */
      __pyx_t_12 = (__pyx_v_c.addr[__pyx_v_k]);
      __pyx_t_14 = -1;
      if (__pyx_t_12 < 0) {
        __pyx_t_12 += __pyx_pybuffernd_target.diminfo[0].shape;
        if (unlikely(__pyx_t_12 < 0)) __pyx_t_14 = 0;
      } else if (unlikely(__pyx_t_12 >= __pyx_pybuffernd_target.diminfo[0].shape)) __pyx_t_14 = 0;
      if (unlikely(__pyx_t_14 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_14);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      (__pyx_v_c.addr[__pyx_v_k]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_target.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_target.diminfo[0].strides));

      /* "lurrn/sparsmat.pyx":6053
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         return result
 *     def append(self,k):
 */
      __pyx_v_result->vec.push_back(__pyx_v_c);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "lurrn/sparsmat.pyx":6054
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 *         return result             # <<<<<<<<<<<<<<
 *     def append(self,k):
 *         self.c_add(k)
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6041
 *             result[new_val]+=1
 *         return result
 *     cpdef VecV1 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_wanted);
  __Pyx_XDECREF((PyObject *)__pyx_v_target);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_27remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6041; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6041; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6041; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_filt = ((PyArrayObject *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6041; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_filt), __pyx_ptype_5numpy_ndarray, 1, "filt", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1_26remap(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_26remap(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_5VecV1_remap(__pyx_v_self, __pyx_v_k, __pyx_v_filt, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6055
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,k):             # <<<<<<<<<<<<<<
 *         self.c_add(k)
 *     def extend(self,tups):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_29append(PyObject *__pyx_v_self, PyObject *__pyx_v_k); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_29append(PyObject *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("append (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1_28append(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self), ((PyObject *)__pyx_v_k));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_28append(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  coordinate_t __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("append", 0);

  /* "lurrn/sparsmat.pyx":6056
 *         return result
 *     def append(self,k):
 *         self.c_add(k)             # <<<<<<<<<<<<<<
 *     def extend(self,tups):
 *         for k in tups:
 */
  __pyx_t_1 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k); if (unlikely((__pyx_t_1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV1 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_1);

  /* "lurrn/sparsmat.pyx":6055
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,k):             # <<<<<<<<<<<<<<
 *         self.c_add(k)
 *     def extend(self,tups):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6057
 *     def append(self,k):
 *         self.c_add(k)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k in tups:
 *             self.c_add(k)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_31extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_31extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extend (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1_30extend(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self), ((PyObject *)__pyx_v_tups));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_30extend(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  coordinate_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("extend", 0);

  /* "lurrn/sparsmat.pyx":6058
 *         self.c_add(k)
 *     def extend(self,tups):
 *         for k in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k)
 *     def __iter__(self):
 */
  if (likely(PyList_CheckExact(__pyx_v_tups)) || PyTuple_CheckExact(__pyx_v_tups)) {
    __pyx_t_1 = __pyx_v_tups; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_tups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":6059
 *     def extend(self,tups):
 *         for k in tups:
 *             self.c_add(k)             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self.item_iter()
 */
    __pyx_t_5 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k); if (unlikely((__pyx_t_5 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV1 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_5);

    /* "lurrn/sparsmat.pyx":6058
 *         self.c_add(k)
 *     def extend(self,tups):
 *         for k in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k)
 *     def __iter__(self):
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6057
 *     def append(self,k):
 *         self.c_add(k)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k in tups:
 *             self.c_add(k)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.extend", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6060
 *         for k in tups:
 *             self.c_add(k)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_33__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_33__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1_32__iter__(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_32__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":6061
 *             self.c_add(k)
 *     def __iter__(self):
 *         return self.item_iter()             # <<<<<<<<<<<<<<
 *     def __reduce__(self):
 *         return (VecV1,(),(),self.item_iter())
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6060
 *         for k in tups:
 *             self.c_add(k)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6062
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecV1,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_35__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_35__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1_34__reduce__(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_34__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "lurrn/sparsmat.pyx":6063
 *         return self.item_iter()
 *     def __reduce__(self):
 *         return (VecV1,(),(),self.item_iter())             # <<<<<<<<<<<<<<
 *     def __setstate__(self,state):
 *         pass
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV1)));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV1)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV1)));
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6062
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecV1,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6064
 *     def __reduce__(self):
 *         return (VecV1,(),(),self.item_iter())
 *     def __setstate__(self,state):             # <<<<<<<<<<<<<<
 *         pass
 *     def __repr__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_37__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_37__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1_36__setstate__(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self), ((PyObject *)__pyx_v_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_36__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6066
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecV1(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_39__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV1_39__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV1_38__repr__(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV1_38__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "lurrn/sparsmat.pyx":6067
 *         pass
 *     def __repr__(self):
 *         return 'VecV1(%s)'%(str(list(self)),)             # <<<<<<<<<<<<<<
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_VecV1_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6066
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecV1(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV1.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6068
 *     def __repr__(self):
 *         return 'VecV1(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

/* Python wrapper */
static void __pyx_pw_5lurrn_8sparsmat_5VecV1_41__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5lurrn_8sparsmat_5VecV1_41__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5lurrn_8sparsmat_5VecV1_40__dealloc__(((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5lurrn_8sparsmat_5VecV1_40__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lurrn/sparsmat.pyx":6070
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()             # <<<<<<<<<<<<<<
 * 
 * cdef class IVecV1_iter:
 */
  __pyx_v_self->vec.~vector();

  /* "lurrn/sparsmat.pyx":6068
 *     def __repr__(self):
 *         return 'VecV1(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":6076
 *     cdef c_VecV1 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_11IVecV1_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_11IVecV1_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_vec = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_vec,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6076; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_vec = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6076; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.IVecV1_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecV1_iter___init__(((struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter *)__pyx_v_self), __pyx_v_vec);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_11IVecV1_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter *__pyx_v_self, PyObject *__pyx_v_vec) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":6077
 *     cdef unsigned int k
 *     def __init__(self,vec):
 *         self.vec=vec             # <<<<<<<<<<<<<<
 *         self.vecC=&self.vec.vec
 *         self.k=0
 */
  if (!(likely(((__pyx_v_vec) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_vec, __pyx_ptype_5lurrn_8sparsmat_VecV1))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6077; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_vec;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->vec);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->vec));
  __pyx_v_self->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6078
 *     def __init__(self,vec):
 *         self.vec=vec
 *         self.vecC=&self.vec.vec             # <<<<<<<<<<<<<<
 *         self.k=0
 *     def __iter__(self):
 */
  __pyx_v_self->vecC = (&__pyx_v_self->vec->vec);

  /* "lurrn/sparsmat.pyx":6079
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 *         self.k=0             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self
 */
  __pyx_v_self->k = 0;

  /* "lurrn/sparsmat.pyx":6076
 *     cdef c_VecV1 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecV1_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6080
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecV1_iter_3__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecV1_iter_3__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecV1_iter_2__iter__(((struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecV1_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":6081
 *         self.k=0
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6080
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6082
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecV1_iter_5__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecV1_iter_5__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecV1_iter_4__next__(((struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecV1_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter *__pyx_v_self) {
  struct CountItem<1,void> __pyx_v_res;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "lurrn/sparsmat.pyx":6083
 *         return self
 *     def __next__(self):
 *         if self.k>=self.vecC.size():             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         cdef c_CItemV1 res=self.vecC.at(self.k)
 */
  __pyx_t_1 = ((__pyx_v_self->k >= __pyx_v_self->vecC->size()) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":6084
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         cdef c_CItemV1 res=self.vecC.at(self.k)
 *         self.k+=1
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lurrn/sparsmat.pyx":6085
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 *         cdef c_CItemV1 res=self.vecC.at(self.k)             # <<<<<<<<<<<<<<
 *         self.k+=1
 *         return res.addr[0]
 */
  __pyx_v_res = __pyx_v_self->vecC->at(__pyx_v_self->k);

  /* "lurrn/sparsmat.pyx":6086
 *             raise StopIteration
 *         cdef c_CItemV1 res=self.vecC.at(self.k)
 *         self.k+=1             # <<<<<<<<<<<<<<
 *         return res.addr[0]
 * 
 */
  __pyx_v_self->k = (__pyx_v_self->k + 1);

  /* "lurrn/sparsmat.pyx":6087
 *         cdef c_CItemV1 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return res.addr[0]             # <<<<<<<<<<<<<<
 * 
 * cdef class LargeVecV1:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_res.addr[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6082
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecV1_iter.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6092
 *     cdef public object compact
 *     cdef public VecV1 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecV1()
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV1_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV1_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV1___init__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV1___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":6093
 *     cdef public VecV1 loose
 *     def __init__(self):
 *         self.compact=[]             # <<<<<<<<<<<<<<
 *         self.loose=VecV1()
 *         self.loose.vec.reserve(100000)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6093; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6094
 *     def __init__(self):
 *         self.compact=[]
 *         self.loose=VecV1()             # <<<<<<<<<<<<<<
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6095
 *         self.compact=[]
 *         self.loose=VecV1()
 *         self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 */
  __pyx_v_self->loose->vec.reserve(100000);

  /* "lurrn/sparsmat.pyx":6092
 *     cdef public object compact
 *     cdef public VecV1 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecV1()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV1.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6096
 *         self.loose=VecV1()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ensure_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_2ensure_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV1_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":6097
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *         self.loose=VecV1()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":6098
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *         self.loose=VecV1()
 *         while len(self.compact)>=2:
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":6099
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 *         self.loose=VecV1()             # <<<<<<<<<<<<<<
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6100
 *             self.compact.append(self.loose)
 *         self.loose=VecV1()
 *         while len(self.compact)>=2:             # <<<<<<<<<<<<<<
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0):
 */
  while (1) {
    __pyx_t_2 = __pyx_v_self->compact;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = ((__pyx_t_6 >= 2) != 0);
    if (!__pyx_t_4) break;

    /* "lurrn/sparsmat.pyx":6101
 *         self.loose=VecV1()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0):
 *         self.loose.c_add(k0)
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6101; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6101; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_1, -2, 0, NULL, NULL, &__pyx_slice__75, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":6096
 *         self.loose=VecV1()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV1.ensure_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6102
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0)
 *         if self.loose.get_size(False)>=100000:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_arg_k0); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_arg_k0) {
  coordinate_t __pyx_v_k0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  assert(__pyx_arg_k0); {
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(__pyx_arg_k0); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV1.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_4add_count(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *)__pyx_v_self), ((coordinate_t)__pyx_v_k0));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV1_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self, coordinate_t __pyx_v_k0) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":6103
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0):
 *         self.loose.c_add(k0)             # <<<<<<<<<<<<<<
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV1 *)__pyx_v_self->loose->__pyx_vtab)->c_add(__pyx_v_self->loose, __pyx_v_k0);

  /* "lurrn/sparsmat.pyx":6104
 *     def add_count(self, coordinate_t k0):
 *         self.loose.c_add(k0)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__76, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_100000, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {

    /* "lurrn/sparsmat.pyx":6105
 *         self.loose.c_add(k0)
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *             self.loose=VecV1()
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV1 *)__pyx_v_self->loose->__pyx_vtab)->ensure_compact(__pyx_v_self->loose);

    /* "lurrn/sparsmat.pyx":6106
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *             self.loose=VecV1()
 *             self.loose.vec.reserve(100000)
 */
    __pyx_t_4 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lurrn/sparsmat.pyx":6107
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 *             self.loose=VecV1()             # <<<<<<<<<<<<<<
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 */
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->loose);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
    __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":6108
 *             self.compact.append(self.loose)
 *             self.loose=VecV1()
 *             self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 */
    __pyx_v_self->loose->vec.reserve(100000);

    /* "lurrn/sparsmat.pyx":6109
 *             self.loose=VecV1()
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and             # <<<<<<<<<<<<<<
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
    while (1) {
      __pyx_t_1 = __pyx_v_self->compact;
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_6 = ((__pyx_t_5 >= 2) != 0);
      if (__pyx_t_6) {
      } else {
        __pyx_t_3 = __pyx_t_6;
        goto __pyx_L6_bool_binop_done;
      }

      /* "lurrn/sparsmat.pyx":6110
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):             # <<<<<<<<<<<<<<
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 */
      __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6110; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_size); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      if (__pyx_t_2) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6110; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_size); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (__pyx_t_2) {
        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyNumber_Multiply(__pyx_float_0_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyObject_RichCompare(__pyx_t_1, __pyx_t_8, Py_GE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_3 = __pyx_t_6;
      __pyx_L6_bool_binop_done:;
      if (!__pyx_t_3) break;

      /* "lurrn/sparsmat.pyx":6111
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
      __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6111; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6111; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_1 = PyNumber_Add(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_8, -2, 0, NULL, NULL, &__pyx_slice__77, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":6102
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0)
 *         if self.loose.get_size(False)>=100000:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV1.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6112
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_6get_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV1_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_compact", 0);

  /* "lurrn/sparsmat.pyx":6113
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         if len(self.compact)>0:
 *             return self.compact[0]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6114
 *     def get_compact(self):
 *         self.ensure_compact()
 *         if len(self.compact)>0:             # <<<<<<<<<<<<<<
 *             return self.compact[0]
 *         else:
 */
  __pyx_t_1 = __pyx_v_self->compact;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((__pyx_t_4 > 0) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":6115
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 *             return self.compact[0]             # <<<<<<<<<<<<<<
 *         else:
 *             return VecV1()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6115; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":6117
 *             return self.compact[0]
 *         else:
 *             return VecV1()             # <<<<<<<<<<<<<<
 *     def get_size(self, compactify=True):
 *         cdef int n
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV1)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":6112
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV1.get_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6118
 *         else:
 *             return VecV1()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV1.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_8get_size(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV1_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  int __pyx_v_n;
  PyObject *__pyx_v_c = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":6120
 *     def get_size(self, compactify=True):
 *         cdef int n
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *             if self.compact:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":6121
 *         cdef int n
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *             if self.compact:
 *                 return self.compact[0].get_size()
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":6122
 *         if compactify:
 *             self.ensure_compact()
 *             if self.compact:             # <<<<<<<<<<<<<<
 *                 return self.compact[0].get_size()
 *             else:
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->compact); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":6123
 *             self.ensure_compact()
 *             if self.compact:
 *                 return self.compact[0].get_size()             # <<<<<<<<<<<<<<
 *             else:
 *                 return 0
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6123; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":6125
 *                 return self.compact[0].get_size()
 *             else:
 *                 return 0             # <<<<<<<<<<<<<<
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_int_0);
      __pyx_r = __pyx_int_0;
      goto __pyx_L0;
    }
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":6127
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_v_self->compact)) || PyTuple_CheckExact(__pyx_v_self->compact)) {
      __pyx_t_4 = __pyx_v_self->compact; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_self->compact); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_get_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__78, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":6128
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__79, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":6129
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)
 *             return n             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         self.ensure_compact()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":6118
 *         else:
 *             return VecV1()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV1.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_c);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6130
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_11__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_11__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_10__iter__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV1_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":6131
 *             return n
 *     def __iter__(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         try:
 *             return iter(self.compact[0])
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6132
 *     def __iter__(self):
 *         self.ensure_compact()
 *         try:             # <<<<<<<<<<<<<<
 *             return iter(self.compact[0])
 *         except IndexError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "lurrn/sparsmat.pyx":6133
 *         self.ensure_compact()
 *         try:
 *             return iter(self.compact[0])             # <<<<<<<<<<<<<<
 *         except IndexError:
 *             return iter([])
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6133; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6133; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L7_try_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":6134
 *         try:
 *             return iter(self.compact[0])
 *         except IndexError:             # <<<<<<<<<<<<<<
 *             return iter([])
 * 
 */
    __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_IndexError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV1.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6134; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_3);

      /* "lurrn/sparsmat.pyx":6135
 *             return iter(self.compact[0])
 *         except IndexError:
 *             return iter([])             # <<<<<<<<<<<<<<
 * 
 *     def get_type_counts(self, k=0):
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6135; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6135; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_r = __pyx_t_9;
      __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":6130
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV1.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6137
 *             return iter([])
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_13get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_13get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6137; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6137; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_12get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV1_12get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);

  /* "lurrn/sparsmat.pyx":6138
 * 
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)             # <<<<<<<<<<<<<<
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_k);
    __Pyx_GIVEREF(__pyx_v_k);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6137
 *             return iter([])
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV1.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6139
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_15remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_15remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  PyObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6139; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6139; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = values[0];
    __pyx_v_filt = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6139; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_14remap(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV1_14remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);

  /* "lurrn/sparsmat.pyx":6140
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_remap); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_v_k);
  PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_k);
  __Pyx_GIVEREF(__pyx_v_k);
  __Pyx_INCREF(__pyx_v_filt);
  PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_filt);
  __Pyx_GIVEREF(__pyx_v_filt);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6139
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV1.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6090
 * 
 * cdef class LargeVecV1:
 *     cdef public object compact             # <<<<<<<<<<<<<<
 *     cdef public VecV1 loose
 *     def __init__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_7compact_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_7compact_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_7compact___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV1_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->compact);
  __pyx_r = __pyx_v_self->compact;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV1_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV1_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_7compact_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV1_7compact_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV1_7compact_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_7compact_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6091
 * cdef class LargeVecV1:
 *     cdef public object compact
 *     cdef public VecV1 loose             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *         self.compact=[]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_5loose_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_5loose_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_5loose___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV1_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->loose));
  __pyx_r = ((PyObject *)__pyx_v_self->loose);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV1_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV1_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_5loose_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5lurrn_8sparsmat_VecV1))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV1.loose.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV1_5loose_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV1_5loose_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_5loose_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV1_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6147
 * cdef class VecV2:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_5VecV2_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_5VecV2_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV2___init__(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_5VecV2___init__(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":6148
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     def item_iter(self):
 *         self.ensure_compact()
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":6147
 * cdef class VecV2:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6149
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecV2_iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("item_iter (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV2_2item_iter(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("item_iter", 0);

  /* "lurrn/sparsmat.pyx":6150
 *         self.is_compact=True
 *     def item_iter(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return IVecV2_iter(self)
 *     def get_size(self,compactify=True):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":6151
 *     def item_iter(self):
 *         self.ensure_compact()
 *         return IVecV2_iter(self)             # <<<<<<<<<<<<<<
 *     def get_size(self,compactify=True):
 *         if compactify:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_IVecV2_iter)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6149
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecV2_iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.item_iter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6152
 *         self.ensure_compact()
 *         return IVecV2_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6152; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6152; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV2_4get_size(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":6153
 *         return IVecV2_iter(self)
 *     def get_size(self,compactify=True):
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *         return self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":6154
 *     def get_size(self,compactify=True):
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return self.vec.size()
 *     def __len__(self):
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":6155
 *         if compactify:
 *             self.ensure_compact()
 *         return self.vec.size()             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return self.get_size(True)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_self->vec.size()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6152
 *         self.ensure_compact()
 *         return IVecV2_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6156
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecV2_7__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecV2_7__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV2_6__len__(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecV2_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":6157
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__80, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6156
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6158
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV2_8clear(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear", 0);

  /* "lurrn/sparsmat.pyx":6159
 *         return self.get_size(True)
 *     def clear(self):
 *         self.vec.resize(0)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void compactify(self):
 */
  __pyx_v_self->vec.resize(0);

  /* "lurrn/sparsmat.pyx":6160
 *     def clear(self):
 *         self.vec.resize(0)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrV2 comp
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":6158
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6161
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrV2 comp
 *         c_IVecV2_sort(self.vec.begin(),self.vec.end(),comp)
 */

static void __pyx_f_5lurrn_8sparsmat_5VecV2_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self) {
  struct smallerAddr<2,void> __pyx_v_comp;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compactify", 0);

  /* "lurrn/sparsmat.pyx":6163
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrV2 comp
 *         c_IVecV2_sort(self.vec.begin(),self.vec.end(),comp)             # <<<<<<<<<<<<<<
 *         c_compactifyV2(&self.vec)
 *         self.is_compact=True
 */
  sort(__pyx_v_self->vec.begin(), __pyx_v_self->vec.end(), __pyx_v_comp);

  /* "lurrn/sparsmat.pyx":6164
 *         cdef c_SmallerAddrV2 comp
 *         c_IVecV2_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyV2(&self.vec)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 */
  compactify_set((&__pyx_v_self->vec));

  /* "lurrn/sparsmat.pyx":6165
 *         c_IVecV2_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyV2(&self.vec)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":6161
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrV2 comp
 *         c_IVecV2_sort(self.vec.begin(),self.vec.end(),comp)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":6166
 *         c_compactifyV2(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

static void __pyx_f_5lurrn_8sparsmat_5VecV2_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":6167
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:             # <<<<<<<<<<<<<<
 *             self.compactify()
 *     cpdef bint get_count(self,coordinate_t k0,coordinate_t k1):
 */
  __pyx_t_1 = ((!(__pyx_v_self->is_compact != 0)) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":6168
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 *             self.compactify()             # <<<<<<<<<<<<<<
 *     cpdef bint get_count(self,coordinate_t k0,coordinate_t k1):
 *         cdef c_CItemV2 ci
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV2 *)__pyx_v_self->__pyx_vtab)->compactify(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":6166
 *         c_compactifyV2(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":6169
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef bint get_count(self,coordinate_t k0,coordinate_t k1):             # <<<<<<<<<<<<<<
 *         cdef c_CItemV2 ci
 *         ci.addr[0]=k0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecV2_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, int __pyx_skip_dispatch) {
  struct CountItem<2,void> __pyx_v_ci;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV2_11get_count)) {
      __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_5 = __pyx_t_1; __pyx_t_6 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_7 = 1;
        }
      }
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_6) {
        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_9;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":6171
 *     cpdef bint get_count(self,coordinate_t k0,coordinate_t k1):
 *         cdef c_CItemV2 ci
 *         ci.addr[0]=k0             # <<<<<<<<<<<<<<
 *         ci.addr[1]=k1
 *         return c_get_countV2(&self.vec,ci)
 */
  (__pyx_v_ci.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":6172
 *         cdef c_CItemV2 ci
 *         ci.addr[0]=k0
 *         ci.addr[1]=k1             # <<<<<<<<<<<<<<
 *         return c_get_countV2(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1):
 */
  (__pyx_v_ci.addr[1]) = __pyx_v_k1;

  /* "lurrn/sparsmat.pyx":6173
 *         ci.addr[0]=k0
 *         ci.addr[1]=k1
 *         return c_get_countV2(&self.vec,ci)             # <<<<<<<<<<<<<<
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1):
 *         cdef c_CItemV2 c
 */
  __pyx_r = get_count_set((&__pyx_v_self->vec), __pyx_v_ci);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6169
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef bint get_count(self,coordinate_t k0,coordinate_t k1):             # <<<<<<<<<<<<<<
 *         cdef c_CItemV2 ci
 *         ci.addr[0]=k0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecV2.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_count", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_count", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV2_10get_count(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_5lurrn_8sparsmat_5VecV2_get_count(__pyx_v_self, __pyx_v_k0, __pyx_v_k1, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6174
 *         ci.addr[1]=k1
 *         return c_get_countV2(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1):             # <<<<<<<<<<<<<<
 *         cdef c_CItemV2 c
 *         c.addr[0]=k0
 */

static void __pyx_f_5lurrn_8sparsmat_5VecV2_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1) {
  struct CountItem<2,void> __pyx_v_c;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_add", 0);

  /* "lurrn/sparsmat.pyx":6176
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1):
 *         cdef c_CItemV2 c
 *         c.addr[0]=k0             # <<<<<<<<<<<<<<
 *         c.addr[1]=k1
 *         self.vec.push_back(c)
 */
  (__pyx_v_c.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":6177
 *         cdef c_CItemV2 c
 *         c.addr[0]=k0
 *         c.addr[1]=k1             # <<<<<<<<<<<<<<
 *         self.vec.push_back(c)
 *         self.is_compact=False
 */
  (__pyx_v_c.addr[1]) = __pyx_v_k1;

  /* "lurrn/sparsmat.pyx":6178
 *         c.addr[0]=k0
 *         c.addr[1]=k1
 *         self.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1):
 */
  __pyx_v_self->vec.push_back(__pyx_v_c);

  /* "lurrn/sparsmat.pyx":6179
 *         c.addr[1]=k1
 *         self.vec.push_back(c)
 *         self.is_compact=False             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1):
 *         self.c_add(k0,k1)
 */
  __pyx_v_self->is_compact = 0;

  /* "lurrn/sparsmat.pyx":6174
 *         ci.addr[1]=k1
 *         return c_get_countV2(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1):             # <<<<<<<<<<<<<<
 *         cdef c_CItemV2 c
 *         c.addr[0]=k0
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":6180
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1)
 *     def __add__(VecV2 self, VecV2 other):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6180; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6180; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6180; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6180; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6180; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV2_12add_count(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":6181
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1):
 *         self.c_add(k0,k1)             # <<<<<<<<<<<<<<
 *     def __add__(VecV2 self, VecV2 other):
 *         cdef c_CItemV2 c1, c2
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV2 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_v_k0, __pyx_v_k1);

  /* "lurrn/sparsmat.pyx":6180
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1):             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1)
 *     def __add__(VecV2 self, VecV2 other):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6182
 *     def add_count(self, coordinate_t k0,coordinate_t k1):
 *         self.c_add(k0,k1)
 *     def __add__(VecV2 self, VecV2 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemV2 c1, c2
 *         cdef unsigned int i1, i2
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_VecV2, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_VecV2, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV2_14__add__(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_other) {
  struct CountItem<2,void> __pyx_v_c1;
  struct CountItem<2,void> __pyx_v_c2;
  unsigned int __pyx_v_i1;
  unsigned int __pyx_v_i2;
  int __pyx_v_k;
  int __pyx_v_delta;
  struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":6187
 *         cdef int k, delta
 *         cdef VecV2 result
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         other.ensure_compact()
 *         result=VecV2()
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":6188
 *         cdef VecV2 result
 *         self.ensure_compact()
 *         other.ensure_compact()             # <<<<<<<<<<<<<<
 *         result=VecV2()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV2 *)__pyx_v_other->__pyx_vtab)->ensure_compact(__pyx_v_other);

  /* "lurrn/sparsmat.pyx":6189
 *         self.ensure_compact()
 *         other.ensure_compact()
 *         result=VecV2()             # <<<<<<<<<<<<<<
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6190
 *         other.ensure_compact()
 *         result=VecV2()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))             # <<<<<<<<<<<<<<
 *         i1=0
 *         i2=0
 */
  __pyx_t_2 = __pyx_v_other->vec.size();
  __pyx_t_3 = __pyx_v_self->vec.size();
  if (((__pyx_t_2 > __pyx_t_3) != 0)) {
    __pyx_t_4 = __pyx_t_2;
  } else {
    __pyx_t_4 = __pyx_t_3;
  }
  __pyx_v_result->vec.reserve(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":6191
 *         result=VecV2()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0             # <<<<<<<<<<<<<<
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 */
  __pyx_v_i1 = 0;

  /* "lurrn/sparsmat.pyx":6192
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 *         i2=0             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 */
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":6193
 *         i1=0
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 */
  while (1) {
    __pyx_t_6 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_6 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":6194
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             delta=0
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":6195
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             delta=0
 *             for k from 0<=k<2:
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":6196
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 *             delta=0             # <<<<<<<<<<<<<<
 *             for k from 0<=k<2:
 *                 if c1.addr[k]<c2.addr[k]:
 */
    __pyx_v_delta = 0;

    /* "lurrn/sparsmat.pyx":6197
 *             c2=other.vec.at(i2)
 *             delta=0
 *             for k from 0<=k<2:             # <<<<<<<<<<<<<<
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 */
    for (__pyx_v_k = 0; __pyx_v_k < 2; __pyx_v_k++) {

      /* "lurrn/sparsmat.pyx":6198
 *             delta=0
 *             for k from 0<=k<2:
 *                 if c1.addr[k]<c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=-1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) < (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":6199
 *             for k from 0<=k<2:
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1             # <<<<<<<<<<<<<<
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 */
        __pyx_v_delta = -1;

        /* "lurrn/sparsmat.pyx":6200
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 *                     break             # <<<<<<<<<<<<<<
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 */
        goto __pyx_L8_break;
      }

      /* "lurrn/sparsmat.pyx":6201
 *                     delta=-1
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) > (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":6202
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1             # <<<<<<<<<<<<<<
 *                     break
 *             if delta==0:
 */
        __pyx_v_delta = 1;

        /* "lurrn/sparsmat.pyx":6203
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 *                     break             # <<<<<<<<<<<<<<
 *             if delta==0:
 *                 result.vec.push_back(c1)
 */
        goto __pyx_L8_break;
      }
    }
    __pyx_L8_break:;

    /* "lurrn/sparsmat.pyx":6208
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
    switch (__pyx_v_delta) {

      /* "lurrn/sparsmat.pyx":6204
 *                     delta=1
 *                     break
 *             if delta==0:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      case 0:

      /* "lurrn/sparsmat.pyx":6205
 *                     break
 *             if delta==0:
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *                 i2+=1
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":6206
 *             if delta==0:
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *                 i2+=1
 *             elif delta==-1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);

      /* "lurrn/sparsmat.pyx":6207
 *                 result.vec.push_back(c1)
 *                 i1+=1
 *                 i2+=1             # <<<<<<<<<<<<<<
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;

      /* "lurrn/sparsmat.pyx":6208
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      case -1:

      /* "lurrn/sparsmat.pyx":6209
 *                 i2+=1
 *             elif delta==-1:
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             else:
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":6210
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             else:
 *                 result.vec.push_back(c2)
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      break;
      default:

      /* "lurrn/sparsmat.pyx":6212
 *                 i1+=1
 *             else:
 *                 result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *                 i2+=1
 *         while i1<self.vec.size():
 */
      __pyx_v_result->vec.push_back(__pyx_v_c2);

      /* "lurrn/sparsmat.pyx":6213
 *             else:
 *                 result.vec.push_back(c2)
 *                 i2+=1             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;
    }
  }

  /* "lurrn/sparsmat.pyx":6214
 *                 result.vec.push_back(c2)
 *                 i2+=1
 *         while i1<self.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":6215
 *                 i2+=1
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c1)
 *             i1+=1
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":6216
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *             i1+=1
 *         while i2<other.vec.size():
 */
    __pyx_v_result->vec.push_back(__pyx_v_c1);

    /* "lurrn/sparsmat.pyx":6217
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 *             i1+=1             # <<<<<<<<<<<<<<
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);
  }

  /* "lurrn/sparsmat.pyx":6218
 *             result.vec.push_back(c1)
 *             i1+=1
 *         while i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":6219
 *             i1+=1
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c2)
 *             i2+=1
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":6220
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *             i2+=1
 *         return result
 */
    __pyx_v_result->vec.push_back(__pyx_v_c2);

    /* "lurrn/sparsmat.pyx":6221
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 *             i2+=1             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_v_i2 = (__pyx_v_i2 + 1);
  }

  /* "lurrn/sparsmat.pyx":6222
 *             result.vec.push_back(c2)
 *             i2+=1
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def tofile(self, f):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6182
 *     def add_count(self, coordinate_t k0,coordinate_t k1):
 *         self.c_add(k0,k1)
 *     def __add__(VecV2 self, VecV2 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemV2 c1, c2
 *         cdef unsigned int i1, i2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6224
 *         return result
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_17tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_17tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tofile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV2_16tofile(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_16tofile(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  long __pyx_v_k;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  long __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("tofile", 0);

  /* "lurrn/sparsmat.pyx":6226
 *     def tofile(self, f):
 *         cdef long i, n, k, k_max
 *         n=self.get_size()             # <<<<<<<<<<<<<<
 *         f.write('V2 %d\n'%(n,))
 *         k=0
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":6227
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 *         f.write('V2 %d\n'%(n,))             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_V2_d, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6228
 *         n=self.get_size()
 *         f.write('V2 %d\n'%(n,))
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecV2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemV2))
 */
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":6229
 *         f.write('V2 %d\n'%(n,))
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecV2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemV2))
 *             f.write(s)
 */
  __pyx_t_4 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":6230
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecV2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemV2))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *             k+=CHUNK_SIZE
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), (256 * (sizeof(struct CountItem<2,void>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":6231
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecV2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemV2))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":6232
 *             s=PyString_FromStringAndSize(<char *>c_VecV2_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemV2))
 *             f.write(s)
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecV2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemV2))
 */
    __pyx_v_k = (__pyx_v_k + 256);
  }

  /* "lurrn/sparsmat.pyx":6233
 *             f.write(s)
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecV2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemV2))
 *             f.write(s)
 */
  __pyx_t_7 = ((__pyx_v_k < __pyx_v_n) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":6234
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecV2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemV2))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *     def fromfile(self, f):
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), ((__pyx_v_n - __pyx_v_k) * (sizeof(struct CountItem<2,void>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":6235
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecV2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemV2))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *     def fromfile(self, f):
 *         cdef long i, n
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":6224
 *         return result
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.tofile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6236
 *             s=PyString_FromStringAndSize(<char *>c_VecV2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemV2))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_19fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_19fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fromfile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV2_18fromfile(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_18fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  PyObject *__pyx_v_line = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  long __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  size_t __pyx_t_9;
  char *__pyx_t_10;
  size_t __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromfile", 0);

  /* "lurrn/sparsmat.pyx":6238
 *     def fromfile(self, f):
 *         cdef long i, n
 *         line=f.readline().strip().split()             # <<<<<<<<<<<<<<
 *         assert line[0]=='V2'
 *         n=long(line[1])
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_readline); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_line = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6239
 *         cdef long i, n
 *         line=f.readline().strip().split()
 *         assert line[0]=='V2'             # <<<<<<<<<<<<<<
 *         n=long(line[1])
 *         self.clear()
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6239; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_V2, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_6)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":6240
 *         line=f.readline().strip().split()
 *         assert line[0]=='V2'
 *         n=long(line[1])             # <<<<<<<<<<<<<<
 *         self.clear()
 *         self.vec.resize(n)
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6240; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyLong_Type))), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_7;

  /* "lurrn/sparsmat.pyx":6241
 *         assert line[0]=='V2'
 *         n=long(line[1])
 *         self.clear()             # <<<<<<<<<<<<<<
 *         self.vec.resize(n)
 *         k=0
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clear); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6242
 *         n=long(line[1])
 *         self.clear()
 *         self.vec.resize(n)             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_v_self->vec.resize(__pyx_v_n);

  /* "lurrn/sparsmat.pyx":6243
 *         self.clear()
 *         self.vec.resize(n)
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemV2))
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_k = __pyx_int_0;

  /* "lurrn/sparsmat.pyx":6244
 *         self.vec.resize(n)
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemV2))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemV2)
 */
  __pyx_t_7 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":6245
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemV2))             # <<<<<<<<<<<<<<
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemV2)
 *             memcpy(<void *>c_VecV2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemV2))
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyInt_FromSize_t((256 * (sizeof(struct CountItem<2,void>)))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":6246
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemV2))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemV2)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecV2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemV2))
 *             k+=CHUNK_SIZE
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!((__pyx_t_8 == (256 * (sizeof(struct CountItem<2,void>)))) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":6247
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemV2))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemV2)
 *             memcpy(<void *>c_VecV2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemV2))             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), (256 * (sizeof(struct CountItem<2,void>))));

    /* "lurrn/sparsmat.pyx":6248
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemV2)
 *             memcpy(<void *>c_VecV2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemV2))
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemV2))
 */
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_k, __pyx_int_256); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_1);
    __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":6249
 *             memcpy(<void *>c_VecV2_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemV2))
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=f.read((n-k)*sizeof(c_CItemV2))
 *             assert len(s)==(n-k)*sizeof(c_CItemV2)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":6250
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemV2))             # <<<<<<<<<<<<<<
 *             assert len(s)==(n-k)*sizeof(c_CItemV2)
 *             memcpy(<void *>c_VecV2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemV2))
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_5, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<2,void>))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":6251
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemV2))
 *             assert len(s)==(n-k)*sizeof(c_CItemV2)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecV2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemV2))
 *     cpdef int get_maxcol(self, int k=0):
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<2,void>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_6)) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":6252
 *             s=f.read((n-k)*sizeof(c_CItemV2))
 *             assert len(s)==(n-k)*sizeof(c_CItemV2)
 *             memcpy(<void *>c_VecV2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemV2))             # <<<<<<<<<<<<<<
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<2,void>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), __pyx_t_11);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":6236
 *             s=PyString_FromStringAndSize(<char *>c_VecV2_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemV2))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.fromfile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_line);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6253
 *             assert len(s)==(n-k)*sizeof(c_CItemV2)
 *             memcpy(<void *>c_VecV2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemV2))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<2
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_21get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecV2_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV2_get_maxcol *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_i;
  int __pyx_v_n;
  int __pyx_v_new_val;
  int __pyx_v_col;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_maxcol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV2_21get_maxcol)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":6255
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<2             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         if n==0:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_9 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_9 = ((__pyx_v_k < 2) != 0);
    __pyx_t_8 = __pyx_t_9;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_8)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":6256
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<2
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         if n==0:
 *             return -1
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":6257
 *         assert k>=0 and k<2
 *         n=self.vec.size()
 *         if n==0:             # <<<<<<<<<<<<<<
 *             return -1
 *         if k==0:
 */
  __pyx_t_8 = ((__pyx_v_n == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":6258
 *         n=self.vec.size()
 *         if n==0:
 *             return -1             # <<<<<<<<<<<<<<
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 */
    __pyx_r = -1;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":6259
 *         if n==0:
 *             return -1
 *         if k==0:             # <<<<<<<<<<<<<<
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 */
  __pyx_t_8 = ((__pyx_v_k == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":6260
 *             return -1
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]             # <<<<<<<<<<<<<<
 *         col=-1
 *         n=self.vec.size()
 */
    __pyx_r = (__pyx_v_self->vec.at((__pyx_v_n - 1)).addr[0]);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":6261
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 *         col=-1             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_v_col = -1;

  /* "lurrn/sparsmat.pyx":6262
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":6263
 *         col=-1
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 */
  __pyx_t_7 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":6264
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             if new_val>col:
 *                 col=new_val
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":6265
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:             # <<<<<<<<<<<<<<
 *                 col=new_val
 *         return col
 */
    __pyx_t_8 = ((__pyx_v_new_val > __pyx_v_col) != 0);
    if (__pyx_t_8) {

      /* "lurrn/sparsmat.pyx":6266
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 *                 col=new_val             # <<<<<<<<<<<<<<
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 */
      __pyx_v_col = __pyx_v_new_val;
      goto __pyx_L9;
    }
    __pyx_L9:;
  }

  /* "lurrn/sparsmat.pyx":6267
 *             if new_val>col:
 *                 col=new_val
 *         return col             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 *         cdef int old_val, new_val, i, n, count
 */
  __pyx_r = __pyx_v_col;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6253
 *             assert len(s)==(n-k)*sizeof(c_CItemV2)
 *             memcpy(<void *>c_VecV2_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemV2))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecV2.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_21get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_21get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_maxcol (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_maxcol") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6253; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6253; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_maxcol", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6253; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV2_20get_maxcol(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_20get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecV2_get_maxcol __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = __pyx_vtabptr_5lurrn_8sparsmat_VecV2->get_maxcol(__pyx_v_self, 1, &__pyx_t_2); 
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6268
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_23get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecV2_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV2_get_type_counts *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_new_val;
  int __pyx_v_i;
  int __pyx_v_n;
  PyArrayObject *__pyx_v_result = 0;
  long __pyx_v_n_types;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecV2_get_maxcol __pyx_t_11;
  PyArrayObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV2_23get_type_counts)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":6271
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<2             # <<<<<<<<<<<<<<
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_8 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_k < 2) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_7)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":6272
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<2
 *         if self.vec.size()==0:             # <<<<<<<<<<<<<<
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 */
  __pyx_t_7 = ((__pyx_v_self->vec.size() == 0) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":6273
 *         assert k>=0 and k<2
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_9 = 1;
      }
    }
    __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_2) {
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":6274
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":6275
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1             # <<<<<<<<<<<<<<
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 */
  __pyx_t_11.__pyx_n = 1;
  __pyx_t_11.k = __pyx_v_k;
  __pyx_t_10 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV2 *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0, &__pyx_t_11); 
  __pyx_v_n_types = (__pyx_t_10 + 1);

  /* "lurrn/sparsmat.pyx":6276
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_n_types); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_9 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_6) {
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_12 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
    }
    __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_12 = 0;
  __pyx_v_result = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6277
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":6278
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":6279
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             result[new_val]+=1
 *         return result
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":6280
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1             # <<<<<<<<<<<<<<
 *         return result
 *     cpdef VecV2 remap(self, int k, numpy.ndarray filt):
 */
    __pyx_t_16 = __pyx_v_new_val;
    __pyx_t_17 = -1;
    if (__pyx_t_16 < 0) {
      __pyx_t_16 += __pyx_pybuffernd_result.diminfo[0].shape;
      if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 0;
    } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_17 = 0;
    if (unlikely(__pyx_t_17 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_17);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_result.diminfo[0].strides) += 1;
  }

  /* "lurrn/sparsmat.pyx":6281
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 *         return result             # <<<<<<<<<<<<<<
 *     cpdef VecV2 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyArrayObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6268
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_23get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_23get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6268; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6268; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6268; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV2_22get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_22get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecV2_get_type_counts __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_5lurrn_8sparsmat_VecV2->get_type_counts(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6282
 *             result[new_val]+=1
 *         return result
 *     cpdef VecV2 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_25remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_f_5lurrn_8sparsmat_5VecV2_remap(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_wanted = 0;
  PyArrayObject *__pyx_v_target = 0;
  int __pyx_v_n;
  int __pyx_v_i;
  struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_result = 0;
  struct CountItem<2,void> __pyx_v_c;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_target;
  __Pyx_Buffer __pyx_pybuffer_target;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_wanted;
  __Pyx_Buffer __pyx_pybuffer_wanted;
  struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __pyx_pybuffer_wanted.pybuffer.buf = NULL;
  __pyx_pybuffer_wanted.refcount = 0;
  __pyx_pybuffernd_wanted.data = NULL;
  __pyx_pybuffernd_wanted.rcbuffer = &__pyx_pybuffer_wanted;
  __pyx_pybuffer_target.pybuffer.buf = NULL;
  __pyx_pybuffer_target.refcount = 0;
  __pyx_pybuffernd_target.data = NULL;
  __pyx_pybuffernd_target.rcbuffer = &__pyx_pybuffer_target;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_remap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV2_25remap)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_filt));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_filt));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_filt));
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_VecV2))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":6283
 *         return result
 *     cpdef VecV2 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__81, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_wanted = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_wanted.diminfo[0].strides = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_wanted.diminfo[0].shape = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_8 = 0;
  __pyx_v_wanted = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6284
 *     cpdef VecV2 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_cumsum); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Subtract(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_target = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_target.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_target.diminfo[0].strides = __pyx_pybuffernd_target.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_target.diminfo[0].shape = __pyx_pybuffernd_target.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_9 = 0;
  __pyx_v_target = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6285
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         cdef int n=self.vec.size()
 *         cdef int i
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV2 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":6286
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()             # <<<<<<<<<<<<<<
 *         cdef int i
 *         cdef VecV2 result=VecV2()
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":6288
 *         cdef int n=self.vec.size()
 *         cdef int i
 *         cdef VecV2 result=VecV2()             # <<<<<<<<<<<<<<
 *         cdef c_CItemV2 c
 *         for i from 0<=i<n:
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6290
 *         cdef VecV2 result=VecV2()
 *         cdef c_CItemV2 c
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":6291
 *         cdef c_CItemV2 c
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)             # <<<<<<<<<<<<<<
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 */
    __pyx_v_c = __pyx_v_self->vec.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":6292
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:             # <<<<<<<<<<<<<<
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 */
    __pyx_t_11 = (__pyx_v_c.addr[__pyx_v_k]);
    __pyx_t_12 = -1;
    if (__pyx_t_11 < 0) {
      __pyx_t_11 += __pyx_pybuffernd_wanted.diminfo[0].shape;
      if (unlikely(__pyx_t_11 < 0)) __pyx_t_12 = 0;
    } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_wanted.diminfo[0].shape)) __pyx_t_12 = 0;
    if (unlikely(__pyx_t_12 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_12);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_wanted.diminfo[0].strides)) != 0);
    if (__pyx_t_13) {

      /* "lurrn/sparsmat.pyx":6293
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c)
 *         return result
 */
      __pyx_t_12 = (__pyx_v_c.addr[__pyx_v_k]);
      __pyx_t_14 = -1;
      if (__pyx_t_12 < 0) {
        __pyx_t_12 += __pyx_pybuffernd_target.diminfo[0].shape;
        if (unlikely(__pyx_t_12 < 0)) __pyx_t_14 = 0;
      } else if (unlikely(__pyx_t_12 >= __pyx_pybuffernd_target.diminfo[0].shape)) __pyx_t_14 = 0;
      if (unlikely(__pyx_t_14 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_14);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      (__pyx_v_c.addr[__pyx_v_k]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_target.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_target.diminfo[0].strides));

      /* "lurrn/sparsmat.pyx":6294
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         return result
 *     def append(self,tup):
 */
      __pyx_v_result->vec.push_back(__pyx_v_c);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "lurrn/sparsmat.pyx":6295
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 *         return result             # <<<<<<<<<<<<<<
 *     def append(self,tup):
 *         k0,k1=tup
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6282
 *             result[new_val]+=1
 *         return result
 *     cpdef VecV2 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_wanted);
  __Pyx_XDECREF((PyObject *)__pyx_v_target);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_25remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_25remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6282; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6282; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6282; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_filt = ((PyArrayObject *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6282; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_filt), __pyx_ptype_5numpy_ndarray, 1, "filt", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV2_24remap(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_24remap(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_5VecV2_remap(__pyx_v_self, __pyx_v_k, __pyx_v_filt, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6296
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,k1=tup
 *         self.c_add(k0,k1)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_27append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_27append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("append (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV2_26append(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self), ((PyObject *)__pyx_v_tup));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_26append(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_k1 = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *(*__pyx_t_4)(PyObject *);
  coordinate_t __pyx_t_5;
  coordinate_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("append", 0);

  /* "lurrn/sparsmat.pyx":6297
 *         return result
 *     def append(self,tup):
 *         k0,k1=tup             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1)
 *     def extend(self,tups):
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_tup))) || (PyList_CheckExact(__pyx_v_tup))) {
    PyObject* sequence = __pyx_v_tup;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    #endif
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_4(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_k0 = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_k1 = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6298
 *     def append(self,tup):
 *         k0,k1=tup
 *         self.c_add(k0,k1)             # <<<<<<<<<<<<<<
 *     def extend(self,tups):
 *         for k0,k1 in tups:
 */
  __pyx_t_5 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_5 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k1); if (unlikely((__pyx_t_6 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV2 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_5, __pyx_t_6);

  /* "lurrn/sparsmat.pyx":6296
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,k1=tup
 *         self.c_add(k0,k1)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_k1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6299
 *         k0,k1=tup
 *         self.c_add(k0,k1)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,k1 in tups:
 *             self.c_add(k0,k1)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_29extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_29extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extend (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV2_28extend(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self), ((PyObject *)__pyx_v_tups));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_28extend(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_k1 = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  coordinate_t __pyx_t_9;
  coordinate_t __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("extend", 0);

  /* "lurrn/sparsmat.pyx":6300
 *         self.c_add(k0,k1)
 *     def extend(self,tups):
 *         for k0,k1 in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,k1)
 *     def __iter__(self):
 */
  if (likely(PyList_CheckExact(__pyx_v_tups)) || PyTuple_CheckExact(__pyx_v_tups)) {
    __pyx_t_1 = __pyx_v_tups; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_tups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_k0, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_k1, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "lurrn/sparsmat.pyx":6301
 *     def extend(self,tups):
 *         for k0,k1 in tups:
 *             self.c_add(k0,k1)             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self.item_iter()
 */
    __pyx_t_9 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_9 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k1); if (unlikely((__pyx_t_10 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV2 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_9, __pyx_t_10);

    /* "lurrn/sparsmat.pyx":6300
 *         self.c_add(k0,k1)
 *     def extend(self,tups):
 *         for k0,k1 in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,k1)
 *     def __iter__(self):
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6299
 *         k0,k1=tup
 *         self.c_add(k0,k1)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,k1 in tups:
 *             self.c_add(k0,k1)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.extend", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_k1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6302
 *         for k0,k1 in tups:
 *             self.c_add(k0,k1)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_31__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_31__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV2_30__iter__(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_30__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":6303
 *             self.c_add(k0,k1)
 *     def __iter__(self):
 *         return self.item_iter()             # <<<<<<<<<<<<<<
 *     def __reduce__(self):
 *         return (VecV2,(),(),self.item_iter())
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6302
 *         for k0,k1 in tups:
 *             self.c_add(k0,k1)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6304
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecV2,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_33__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_33__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV2_32__reduce__(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_32__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "lurrn/sparsmat.pyx":6305
 *         return self.item_iter()
 *     def __reduce__(self):
 *         return (VecV2,(),(),self.item_iter())             # <<<<<<<<<<<<<<
 *     def __setstate__(self,state):
 *         pass
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV2)));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV2)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV2)));
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6304
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecV2,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6306
 *     def __reduce__(self):
 *         return (VecV2,(),(),self.item_iter())
 *     def __setstate__(self,state):             # <<<<<<<<<<<<<<
 *         pass
 *     def __repr__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_35__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_35__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV2_34__setstate__(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self), ((PyObject *)__pyx_v_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_34__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6308
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecV2(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_37__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV2_37__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV2_36__repr__(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV2_36__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "lurrn/sparsmat.pyx":6309
 *         pass
 *     def __repr__(self):
 *         return 'VecV2(%s)'%(str(list(self)),)             # <<<<<<<<<<<<<<
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_VecV2_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6308
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecV2(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV2.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6310
 *     def __repr__(self):
 *         return 'VecV2(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

/* Python wrapper */
static void __pyx_pw_5lurrn_8sparsmat_5VecV2_39__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5lurrn_8sparsmat_5VecV2_39__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5lurrn_8sparsmat_5VecV2_38__dealloc__(((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5lurrn_8sparsmat_5VecV2_38__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lurrn/sparsmat.pyx":6312
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()             # <<<<<<<<<<<<<<
 * 
 * cdef class IVecV2_iter:
 */
  __pyx_v_self->vec.~vector();

  /* "lurrn/sparsmat.pyx":6310
 *     def __repr__(self):
 *         return 'VecV2(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":6318
 *     cdef c_VecV2 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_11IVecV2_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_11IVecV2_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_vec = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_vec,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6318; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_vec = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6318; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.IVecV2_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecV2_iter___init__(((struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter *)__pyx_v_self), __pyx_v_vec);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_11IVecV2_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter *__pyx_v_self, PyObject *__pyx_v_vec) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":6319
 *     cdef unsigned int k
 *     def __init__(self,vec):
 *         self.vec=vec             # <<<<<<<<<<<<<<
 *         self.vecC=&self.vec.vec
 *         self.k=0
 */
  if (!(likely(((__pyx_v_vec) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_vec, __pyx_ptype_5lurrn_8sparsmat_VecV2))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_vec;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->vec);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->vec));
  __pyx_v_self->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6320
 *     def __init__(self,vec):
 *         self.vec=vec
 *         self.vecC=&self.vec.vec             # <<<<<<<<<<<<<<
 *         self.k=0
 *     def __iter__(self):
 */
  __pyx_v_self->vecC = (&__pyx_v_self->vec->vec);

  /* "lurrn/sparsmat.pyx":6321
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 *         self.k=0             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self
 */
  __pyx_v_self->k = 0;

  /* "lurrn/sparsmat.pyx":6318
 *     cdef c_VecV2 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecV2_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6322
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecV2_iter_3__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecV2_iter_3__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecV2_iter_2__iter__(((struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecV2_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":6323
 *         self.k=0
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6322
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6324
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecV2_iter_5__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecV2_iter_5__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecV2_iter_4__next__(((struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecV2_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter *__pyx_v_self) {
  struct CountItem<2,void> __pyx_v_res;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "lurrn/sparsmat.pyx":6325
 *         return self
 *     def __next__(self):
 *         if self.k>=self.vecC.size():             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         cdef c_CItemV2 res=self.vecC.at(self.k)
 */
  __pyx_t_1 = ((__pyx_v_self->k >= __pyx_v_self->vecC->size()) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":6326
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         cdef c_CItemV2 res=self.vecC.at(self.k)
 *         self.k+=1
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lurrn/sparsmat.pyx":6327
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 *         cdef c_CItemV2 res=self.vecC.at(self.k)             # <<<<<<<<<<<<<<
 *         self.k+=1
 *         return (res.addr[0],
 */
  __pyx_v_res = __pyx_v_self->vecC->at(__pyx_v_self->k);

  /* "lurrn/sparsmat.pyx":6328
 *             raise StopIteration
 *         cdef c_CItemV2 res=self.vecC.at(self.k)
 *         self.k+=1             # <<<<<<<<<<<<<<
 *         return (res.addr[0],
 *                 res.addr[1])
 */
  __pyx_v_self->k = (__pyx_v_self->k + 1);

  /* "lurrn/sparsmat.pyx":6329
 *         cdef c_CItemV2 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.addr[1])
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_res.addr[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "lurrn/sparsmat.pyx":6330
 *         self.k+=1
 *         return (res.addr[0],
 *                 res.addr[1])             # <<<<<<<<<<<<<<
 * 
 * cdef class LargeVecV2:
 */
  __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_res.addr[1])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "lurrn/sparsmat.pyx":6329
 *         cdef c_CItemV2 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.addr[1])
 * 
 */
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6324
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecV2_iter.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6335
 *     cdef public object compact
 *     cdef public VecV2 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecV2()
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV2_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV2_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV2___init__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV2___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":6336
 *     cdef public VecV2 loose
 *     def __init__(self):
 *         self.compact=[]             # <<<<<<<<<<<<<<
 *         self.loose=VecV2()
 *         self.loose.vec.reserve(100000)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6337
 *     def __init__(self):
 *         self.compact=[]
 *         self.loose=VecV2()             # <<<<<<<<<<<<<<
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6338
 *         self.compact=[]
 *         self.loose=VecV2()
 *         self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 */
  __pyx_v_self->loose->vec.reserve(100000);

  /* "lurrn/sparsmat.pyx":6335
 *     cdef public object compact
 *     cdef public VecV2 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecV2()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV2.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6339
 *         self.loose=VecV2()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ensure_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_2ensure_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV2_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":6340
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *         self.loose=VecV2()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":6341
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *         self.loose=VecV2()
 *         while len(self.compact)>=2:
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":6342
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 *         self.loose=VecV2()             # <<<<<<<<<<<<<<
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6343
 *             self.compact.append(self.loose)
 *         self.loose=VecV2()
 *         while len(self.compact)>=2:             # <<<<<<<<<<<<<<
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1):
 */
  while (1) {
    __pyx_t_2 = __pyx_v_self->compact;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = ((__pyx_t_6 >= 2) != 0);
    if (!__pyx_t_4) break;

    /* "lurrn/sparsmat.pyx":6344
 *         self.loose=VecV2()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1):
 *         self.loose.c_add(k0,k1)
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6344; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6344; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_1, -2, 0, NULL, NULL, &__pyx_slice__82, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":6339
 *         self.loose=VecV2()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV2.ensure_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6345
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0,k1)
 *         if self.loose.get_size(False)>=100000:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6345; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6345; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6345; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6345; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6345; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV2.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_4add_count(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV2_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":6346
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1):
 *         self.loose.c_add(k0,k1)             # <<<<<<<<<<<<<<
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV2 *)__pyx_v_self->loose->__pyx_vtab)->c_add(__pyx_v_self->loose, __pyx_v_k0, __pyx_v_k1);

  /* "lurrn/sparsmat.pyx":6347
 *     def add_count(self, coordinate_t k0,coordinate_t k1):
 *         self.loose.c_add(k0,k1)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__83, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_100000, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {

    /* "lurrn/sparsmat.pyx":6348
 *         self.loose.c_add(k0,k1)
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *             self.loose=VecV2()
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV2 *)__pyx_v_self->loose->__pyx_vtab)->ensure_compact(__pyx_v_self->loose);

    /* "lurrn/sparsmat.pyx":6349
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *             self.loose=VecV2()
 *             self.loose.vec.reserve(100000)
 */
    __pyx_t_4 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lurrn/sparsmat.pyx":6350
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 *             self.loose=VecV2()             # <<<<<<<<<<<<<<
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 */
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->loose);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
    __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":6351
 *             self.compact.append(self.loose)
 *             self.loose=VecV2()
 *             self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 */
    __pyx_v_self->loose->vec.reserve(100000);

    /* "lurrn/sparsmat.pyx":6352
 *             self.loose=VecV2()
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and             # <<<<<<<<<<<<<<
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
    while (1) {
      __pyx_t_1 = __pyx_v_self->compact;
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_6 = ((__pyx_t_5 >= 2) != 0);
      if (__pyx_t_6) {
      } else {
        __pyx_t_3 = __pyx_t_6;
        goto __pyx_L6_bool_binop_done;
      }

      /* "lurrn/sparsmat.pyx":6353
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):             # <<<<<<<<<<<<<<
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 */
      __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6353; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_size); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      if (__pyx_t_2) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6353; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_size); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (__pyx_t_2) {
        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyNumber_Multiply(__pyx_float_0_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyObject_RichCompare(__pyx_t_1, __pyx_t_8, Py_GE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_3 = __pyx_t_6;
      __pyx_L6_bool_binop_done:;
      if (!__pyx_t_3) break;

      /* "lurrn/sparsmat.pyx":6354
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
      __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6354; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6354; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_1 = PyNumber_Add(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_8, -2, 0, NULL, NULL, &__pyx_slice__84, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":6345
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0,k1)
 *         if self.loose.get_size(False)>=100000:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV2.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6355
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_6get_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV2_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_compact", 0);

  /* "lurrn/sparsmat.pyx":6356
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         if len(self.compact)>0:
 *             return self.compact[0]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6357
 *     def get_compact(self):
 *         self.ensure_compact()
 *         if len(self.compact)>0:             # <<<<<<<<<<<<<<
 *             return self.compact[0]
 *         else:
 */
  __pyx_t_1 = __pyx_v_self->compact;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((__pyx_t_4 > 0) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":6358
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 *             return self.compact[0]             # <<<<<<<<<<<<<<
 *         else:
 *             return VecV2()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6358; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":6360
 *             return self.compact[0]
 *         else:
 *             return VecV2()             # <<<<<<<<<<<<<<
 *     def get_size(self, compactify=True):
 *         cdef int n
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":6355
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV2.get_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6361
 *         else:
 *             return VecV2()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6361; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6361; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV2.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_8get_size(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV2_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  int __pyx_v_n;
  PyObject *__pyx_v_c = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":6363
 *     def get_size(self, compactify=True):
 *         cdef int n
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *             if self.compact:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":6364
 *         cdef int n
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *             if self.compact:
 *                 return self.compact[0].get_size()
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":6365
 *         if compactify:
 *             self.ensure_compact()
 *             if self.compact:             # <<<<<<<<<<<<<<
 *                 return self.compact[0].get_size()
 *             else:
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->compact); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":6366
 *             self.ensure_compact()
 *             if self.compact:
 *                 return self.compact[0].get_size()             # <<<<<<<<<<<<<<
 *             else:
 *                 return 0
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6366; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":6368
 *                 return self.compact[0].get_size()
 *             else:
 *                 return 0             # <<<<<<<<<<<<<<
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_int_0);
      __pyx_r = __pyx_int_0;
      goto __pyx_L0;
    }
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":6370
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_v_self->compact)) || PyTuple_CheckExact(__pyx_v_self->compact)) {
      __pyx_t_4 = __pyx_v_self->compact; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_self->compact); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_get_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__85, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":6371
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__86, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":6372
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)
 *             return n             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         self.ensure_compact()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":6361
 *         else:
 *             return VecV2()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV2.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_c);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6373
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_11__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_11__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_10__iter__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV2_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":6374
 *             return n
 *     def __iter__(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         try:
 *             return iter(self.compact[0])
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6375
 *     def __iter__(self):
 *         self.ensure_compact()
 *         try:             # <<<<<<<<<<<<<<
 *             return iter(self.compact[0])
 *         except IndexError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "lurrn/sparsmat.pyx":6376
 *         self.ensure_compact()
 *         try:
 *             return iter(self.compact[0])             # <<<<<<<<<<<<<<
 *         except IndexError:
 *             return iter([])
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6376; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6376; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L7_try_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":6377
 *         try:
 *             return iter(self.compact[0])
 *         except IndexError:             # <<<<<<<<<<<<<<
 *             return iter([])
 * 
 */
    __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_IndexError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV2.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6377; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_3);

      /* "lurrn/sparsmat.pyx":6378
 *             return iter(self.compact[0])
 *         except IndexError:
 *             return iter([])             # <<<<<<<<<<<<<<
 * 
 *     def get_type_counts(self, k=0):
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6378; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6378; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_r = __pyx_t_9;
      __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":6373
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV2.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6380
 *             return iter([])
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_13get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_13get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6380; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6380; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_12get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV2_12get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);

  /* "lurrn/sparsmat.pyx":6381
 * 
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)             # <<<<<<<<<<<<<<
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_k);
    __Pyx_GIVEREF(__pyx_v_k);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6380
 *             return iter([])
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV2.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6382
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_15remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_15remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  PyObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6382; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6382; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = values[0];
    __pyx_v_filt = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6382; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_14remap(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV2_14remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);

  /* "lurrn/sparsmat.pyx":6383
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_remap); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_v_k);
  PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_k);
  __Pyx_GIVEREF(__pyx_v_k);
  __Pyx_INCREF(__pyx_v_filt);
  PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_filt);
  __Pyx_GIVEREF(__pyx_v_filt);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6382
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV2.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6333
 * 
 * cdef class LargeVecV2:
 *     cdef public object compact             # <<<<<<<<<<<<<<
 *     cdef public VecV2 loose
 *     def __init__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_7compact_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_7compact_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_7compact___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV2_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->compact);
  __pyx_r = __pyx_v_self->compact;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV2_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV2_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_7compact_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV2_7compact_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV2_7compact_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_7compact_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6334
 * cdef class LargeVecV2:
 *     cdef public object compact
 *     cdef public VecV2 loose             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *         self.compact=[]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_5loose_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_5loose_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_5loose___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV2_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->loose));
  __pyx_r = ((PyObject *)__pyx_v_self->loose);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV2_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV2_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_5loose_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5lurrn_8sparsmat_VecV2))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV2.loose.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV2_5loose_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV2_5loose_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_5loose_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV2_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6390
 * cdef class VecV3:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_5VecV3_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_5VecV3_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV3___init__(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_5VecV3___init__(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":6391
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     def item_iter(self):
 *         self.ensure_compact()
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":6390
 * cdef class VecV3:
 *     """mutable sparse int matrix based on item vector"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     def item_iter(self):
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6392
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecV3_iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_3item_iter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("item_iter (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV3_2item_iter(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_2item_iter(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("item_iter", 0);

  /* "lurrn/sparsmat.pyx":6393
 *         self.is_compact=True
 *     def item_iter(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return IVecV3_iter(self)
 *     def get_size(self,compactify=True):
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":6394
 *     def item_iter(self):
 *         self.ensure_compact()
 *         return IVecV3_iter(self)             # <<<<<<<<<<<<<<
 *     def get_size(self,compactify=True):
 *         if compactify:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_IVecV3_iter)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6392
 *     def __init__(self):
 *         self.is_compact=True
 *     def item_iter(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         return IVecV3_iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.item_iter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6395
 *         self.ensure_compact()
 *         return IVecV3_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_5get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6395; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6395; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV3_4get_size(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_4get_size(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":6396
 *         return IVecV3_iter(self)
 *     def get_size(self,compactify=True):
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *         return self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":6397
 *     def get_size(self,compactify=True):
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *         return self.vec.size()
 *     def __len__(self):
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":6398
 *         if compactify:
 *             self.ensure_compact()
 *         return self.vec.size()             # <<<<<<<<<<<<<<
 *     def __len__(self):
 *         return self.get_size(True)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_self->vec.size()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6395
 *         self.ensure_compact()
 *         return IVecV3_iter(self)
 *     def get_size(self,compactify=True):             # <<<<<<<<<<<<<<
 *         if compactify:
 *             self.ensure_compact()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6399
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecV3_7__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5lurrn_8sparsmat_5VecV3_7__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV3_6__len__(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_5lurrn_8sparsmat_5VecV3_6__len__(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lurrn/sparsmat.pyx":6400
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__87, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6399
 *             self.ensure_compact()
 *         return self.vec.size()
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.get_size(True)
 *     def clear(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6401
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV3_8clear(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_8clear(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear", 0);

  /* "lurrn/sparsmat.pyx":6402
 *         return self.get_size(True)
 *     def clear(self):
 *         self.vec.resize(0)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void compactify(self):
 */
  __pyx_v_self->vec.resize(0);

  /* "lurrn/sparsmat.pyx":6403
 *     def clear(self):
 *         self.vec.resize(0)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrV3 comp
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":6401
 *     def __len__(self):
 *         return self.get_size(True)
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.vec.resize(0)
 *         self.is_compact=True
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6404
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrV3 comp
 *         c_IVecV3_sort(self.vec.begin(),self.vec.end(),comp)
 */

static void __pyx_f_5lurrn_8sparsmat_5VecV3_compactify(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self) {
  struct smallerAddr<3,void> __pyx_v_comp;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compactify", 0);

  /* "lurrn/sparsmat.pyx":6406
 *     cdef void compactify(self):
 *         cdef c_SmallerAddrV3 comp
 *         c_IVecV3_sort(self.vec.begin(),self.vec.end(),comp)             # <<<<<<<<<<<<<<
 *         c_compactifyV3(&self.vec)
 *         self.is_compact=True
 */
  sort(__pyx_v_self->vec.begin(), __pyx_v_self->vec.end(), __pyx_v_comp);

  /* "lurrn/sparsmat.pyx":6407
 *         cdef c_SmallerAddrV3 comp
 *         c_IVecV3_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyV3(&self.vec)             # <<<<<<<<<<<<<<
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 */
  compactify_set((&__pyx_v_self->vec));

  /* "lurrn/sparsmat.pyx":6408
 *         c_IVecV3_sort(self.vec.begin(),self.vec.end(),comp)
 *         c_compactifyV3(&self.vec)
 *         self.is_compact=True             # <<<<<<<<<<<<<<
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 */
  __pyx_v_self->is_compact = 1;

  /* "lurrn/sparsmat.pyx":6404
 *         self.vec.resize(0)
 *         self.is_compact=True
 *     cdef void compactify(self):             # <<<<<<<<<<<<<<
 *         cdef c_SmallerAddrV3 comp
 *         c_IVecV3_sort(self.vec.begin(),self.vec.end(),comp)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":6409
 *         c_compactifyV3(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

static void __pyx_f_5lurrn_8sparsmat_5VecV3_ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":6410
 *         self.is_compact=True
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:             # <<<<<<<<<<<<<<
 *             self.compactify()
 *     cpdef bint get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):
 */
  __pyx_t_1 = ((!(__pyx_v_self->is_compact != 0)) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":6411
 *     cdef void ensure_compact(self):
 *         if not self.is_compact:
 *             self.compactify()             # <<<<<<<<<<<<<<
 *     cpdef bint get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):
 *         cdef c_CItemV3 ci
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV3 *)__pyx_v_self->__pyx_vtab)->compactify(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":6409
 *         c_compactifyV3(&self.vec)
 *         self.is_compact=True
 *     cdef void ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if not self.is_compact:
 *             self.compactify()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":6412
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef bint get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):             # <<<<<<<<<<<<<<
 *         cdef c_CItemV3 ci
 *         ci.addr[0]=k0
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecV3_get_count(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2, int __pyx_skip_dispatch) {
  struct CountItem<3,void> __pyx_v_ci;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV3_11get_count)) {
      __pyx_t_3 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyInt_From_coordinate_t(__pyx_v_k2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_6 = __pyx_t_1; __pyx_t_7 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
          __pyx_t_8 = 1;
        }
      }
      __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_5 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_10;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":6414
 *     cpdef bint get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):
 *         cdef c_CItemV3 ci
 *         ci.addr[0]=k0             # <<<<<<<<<<<<<<
 *         ci.addr[1]=k1
 *         ci.addr[2]=k2
 */
  (__pyx_v_ci.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":6415
 *         cdef c_CItemV3 ci
 *         ci.addr[0]=k0
 *         ci.addr[1]=k1             # <<<<<<<<<<<<<<
 *         ci.addr[2]=k2
 *         return c_get_countV3(&self.vec,ci)
 */
  (__pyx_v_ci.addr[1]) = __pyx_v_k1;

  /* "lurrn/sparsmat.pyx":6416
 *         ci.addr[0]=k0
 *         ci.addr[1]=k1
 *         ci.addr[2]=k2             # <<<<<<<<<<<<<<
 *         return c_get_countV3(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):
 */
  (__pyx_v_ci.addr[2]) = __pyx_v_k2;

  /* "lurrn/sparsmat.pyx":6417
 *         ci.addr[1]=k1
 *         ci.addr[2]=k2
 *         return c_get_countV3(&self.vec,ci)             # <<<<<<<<<<<<<<
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):
 *         cdef c_CItemV3 c
 */
  __pyx_r = get_count_set((&__pyx_v_self->vec), __pyx_v_ci);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6412
 *         if not self.is_compact:
 *             self.compactify()
 *     cpdef bint get_count(self,coordinate_t k0,coordinate_t k1,coordinate_t k2):             # <<<<<<<<<<<<<<
 *         cdef c_CItemV3 ci
 *         ci.addr[0]=k0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecV3.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_11get_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,&__pyx_n_s_k2,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_count", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6412; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_count", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6412; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6412; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6412; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6412; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k2 = __Pyx_PyInt_As_coordinate_t(values[2]); if (unlikely((__pyx_v_k2 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6412; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_count", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6412; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV3_10get_count(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1, __pyx_v_k2);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_10get_count(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_count", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_5lurrn_8sparsmat_5VecV3_get_count(__pyx_v_self, __pyx_v_k0, __pyx_v_k1, __pyx_v_k2, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.get_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6418
 *         ci.addr[2]=k2
 *         return c_get_countV3(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):             # <<<<<<<<<<<<<<
 *         cdef c_CItemV3 c
 *         c.addr[0]=k0
 */

static void __pyx_f_5lurrn_8sparsmat_5VecV3_c_add(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2) {
  struct CountItem<3,void> __pyx_v_c;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_add", 0);

  /* "lurrn/sparsmat.pyx":6420
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):
 *         cdef c_CItemV3 c
 *         c.addr[0]=k0             # <<<<<<<<<<<<<<
 *         c.addr[1]=k1
 *         c.addr[2]=k2
 */
  (__pyx_v_c.addr[0]) = __pyx_v_k0;

  /* "lurrn/sparsmat.pyx":6421
 *         cdef c_CItemV3 c
 *         c.addr[0]=k0
 *         c.addr[1]=k1             # <<<<<<<<<<<<<<
 *         c.addr[2]=k2
 *         self.vec.push_back(c)
 */
  (__pyx_v_c.addr[1]) = __pyx_v_k1;

  /* "lurrn/sparsmat.pyx":6422
 *         c.addr[0]=k0
 *         c.addr[1]=k1
 *         c.addr[2]=k2             # <<<<<<<<<<<<<<
 *         self.vec.push_back(c)
 *         self.is_compact=False
 */
  (__pyx_v_c.addr[2]) = __pyx_v_k2;

  /* "lurrn/sparsmat.pyx":6423
 *         c.addr[1]=k1
 *         c.addr[2]=k2
 *         self.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):
 */
  __pyx_v_self->vec.push_back(__pyx_v_c);

  /* "lurrn/sparsmat.pyx":6424
 *         c.addr[2]=k2
 *         self.vec.push_back(c)
 *         self.is_compact=False             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):
 *         self.c_add(k0,k1,k2)
 */
  __pyx_v_self->is_compact = 0;

  /* "lurrn/sparsmat.pyx":6418
 *         ci.addr[2]=k2
 *         return c_get_countV3(&self.vec,ci)
 *     cdef void c_add(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):             # <<<<<<<<<<<<<<
 *         cdef c_CItemV3 c
 *         c.addr[0]=k0
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":6425
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1,k2)
 *     def __add__(VecV3 self, VecV3 other):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_13add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,&__pyx_n_s_k2,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6425; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6425; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6425; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6425; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6425; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k2 = __Pyx_PyInt_As_coordinate_t(values[2]); if (unlikely((__pyx_v_k2 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6425; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6425; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV3_12add_count(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1, __pyx_v_k2);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_12add_count(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":6426
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):
 *         self.c_add(k0,k1,k2)             # <<<<<<<<<<<<<<
 *     def __add__(VecV3 self, VecV3 other):
 *         cdef c_CItemV3 c1, c2
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV3 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_v_k0, __pyx_v_k1, __pyx_v_k2);

  /* "lurrn/sparsmat.pyx":6425
 *         self.vec.push_back(c)
 *         self.is_compact=False
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1,k2)
 *     def __add__(VecV3 self, VecV3 other):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6427
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):
 *         self.c_add(k0,k1,k2)
 *     def __add__(VecV3 self, VecV3 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemV3 c1, c2
 *         cdef unsigned int i1, i2
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_15__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5lurrn_8sparsmat_VecV3, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5lurrn_8sparsmat_VecV3, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV3_14__add__(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self), ((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_14__add__(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_other) {
  struct CountItem<3,void> __pyx_v_c1;
  struct CountItem<3,void> __pyx_v_c2;
  unsigned int __pyx_v_i1;
  unsigned int __pyx_v_i2;
  int __pyx_v_k;
  int __pyx_v_delta;
  struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "lurrn/sparsmat.pyx":6432
 *         cdef int k, delta
 *         cdef VecV3 result
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         other.ensure_compact()
 *         result=VecV3()
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":6433
 *         cdef VecV3 result
 *         self.ensure_compact()
 *         other.ensure_compact()             # <<<<<<<<<<<<<<
 *         result=VecV3()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV3 *)__pyx_v_other->__pyx_vtab)->ensure_compact(__pyx_v_other);

  /* "lurrn/sparsmat.pyx":6434
 *         self.ensure_compact()
 *         other.ensure_compact()
 *         result=VecV3()             # <<<<<<<<<<<<<<
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6435
 *         other.ensure_compact()
 *         result=VecV3()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))             # <<<<<<<<<<<<<<
 *         i1=0
 *         i2=0
 */
  __pyx_t_2 = __pyx_v_other->vec.size();
  __pyx_t_3 = __pyx_v_self->vec.size();
  if (((__pyx_t_2 > __pyx_t_3) != 0)) {
    __pyx_t_4 = __pyx_t_2;
  } else {
    __pyx_t_4 = __pyx_t_3;
  }
  __pyx_v_result->vec.reserve(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":6436
 *         result=VecV3()
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0             # <<<<<<<<<<<<<<
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 */
  __pyx_v_i1 = 0;

  /* "lurrn/sparsmat.pyx":6437
 *         result.vec.reserve(max(self.vec.size(),other.vec.size()))
 *         i1=0
 *         i2=0             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 */
  __pyx_v_i2 = 0;

  /* "lurrn/sparsmat.pyx":6438
 *         i1=0
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 */
  while (1) {
    __pyx_t_6 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_6 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":6439
 *         i2=0
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             delta=0
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":6440
 *         while i1<self.vec.size() and i2<other.vec.size():
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             delta=0
 *             for k from 0<=k<3:
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":6441
 *             c1=self.vec.at(i1)
 *             c2=other.vec.at(i2)
 *             delta=0             # <<<<<<<<<<<<<<
 *             for k from 0<=k<3:
 *                 if c1.addr[k]<c2.addr[k]:
 */
    __pyx_v_delta = 0;

    /* "lurrn/sparsmat.pyx":6442
 *             c2=other.vec.at(i2)
 *             delta=0
 *             for k from 0<=k<3:             # <<<<<<<<<<<<<<
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 */
    for (__pyx_v_k = 0; __pyx_v_k < 3; __pyx_v_k++) {

      /* "lurrn/sparsmat.pyx":6443
 *             delta=0
 *             for k from 0<=k<3:
 *                 if c1.addr[k]<c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=-1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) < (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":6444
 *             for k from 0<=k<3:
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1             # <<<<<<<<<<<<<<
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 */
        __pyx_v_delta = -1;

        /* "lurrn/sparsmat.pyx":6445
 *                 if c1.addr[k]<c2.addr[k]:
 *                     delta=-1
 *                     break             # <<<<<<<<<<<<<<
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 */
        goto __pyx_L8_break;
      }

      /* "lurrn/sparsmat.pyx":6446
 *                     delta=-1
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:             # <<<<<<<<<<<<<<
 *                     delta=1
 *                     break
 */
      __pyx_t_5 = (((__pyx_v_c1.addr[__pyx_v_k]) > (__pyx_v_c2.addr[__pyx_v_k])) != 0);
      if (__pyx_t_5) {

        /* "lurrn/sparsmat.pyx":6447
 *                     break
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1             # <<<<<<<<<<<<<<
 *                     break
 *             if delta==0:
 */
        __pyx_v_delta = 1;

        /* "lurrn/sparsmat.pyx":6448
 *                 elif c1.addr[k]>c2.addr[k]:
 *                     delta=1
 *                     break             # <<<<<<<<<<<<<<
 *             if delta==0:
 *                 result.vec.push_back(c1)
 */
        goto __pyx_L8_break;
      }
    }
    __pyx_L8_break:;

    /* "lurrn/sparsmat.pyx":6453
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
    switch (__pyx_v_delta) {

      /* "lurrn/sparsmat.pyx":6449
 *                     delta=1
 *                     break
 *             if delta==0:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      case 0:

      /* "lurrn/sparsmat.pyx":6450
 *                     break
 *             if delta==0:
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *                 i2+=1
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":6451
 *             if delta==0:
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *                 i2+=1
 *             elif delta==-1:
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);

      /* "lurrn/sparsmat.pyx":6452
 *                 result.vec.push_back(c1)
 *                 i1+=1
 *                 i2+=1             # <<<<<<<<<<<<<<
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;

      /* "lurrn/sparsmat.pyx":6453
 *                 i1+=1
 *                 i2+=1
 *             elif delta==-1:             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c1)
 *                 i1+=1
 */
      case -1:

      /* "lurrn/sparsmat.pyx":6454
 *                 i2+=1
 *             elif delta==-1:
 *                 result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *                 i1+=1
 *             else:
 */
      __pyx_v_result->vec.push_back(__pyx_v_c1);

      /* "lurrn/sparsmat.pyx":6455
 *             elif delta==-1:
 *                 result.vec.push_back(c1)
 *                 i1+=1             # <<<<<<<<<<<<<<
 *             else:
 *                 result.vec.push_back(c2)
 */
      __pyx_v_i1 = (__pyx_v_i1 + 1);
      break;
      default:

      /* "lurrn/sparsmat.pyx":6457
 *                 i1+=1
 *             else:
 *                 result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *                 i2+=1
 *         while i1<self.vec.size():
 */
      __pyx_v_result->vec.push_back(__pyx_v_c2);

      /* "lurrn/sparsmat.pyx":6458
 *             else:
 *                 result.vec.push_back(c2)
 *                 i2+=1             # <<<<<<<<<<<<<<
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 */
      __pyx_v_i2 = (__pyx_v_i2 + 1);
      break;
    }
  }

  /* "lurrn/sparsmat.pyx":6459
 *                 result.vec.push_back(c2)
 *                 i2+=1
 *         while i1<self.vec.size():             # <<<<<<<<<<<<<<
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i1 < __pyx_v_self->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":6460
 *                 i2+=1
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c1)
 *             i1+=1
 */
    __pyx_v_c1 = __pyx_v_self->vec.at(__pyx_v_i1);

    /* "lurrn/sparsmat.pyx":6461
 *         while i1<self.vec.size():
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)             # <<<<<<<<<<<<<<
 *             i1+=1
 *         while i2<other.vec.size():
 */
    __pyx_v_result->vec.push_back(__pyx_v_c1);

    /* "lurrn/sparsmat.pyx":6462
 *             c1=self.vec.at(i1)
 *             result.vec.push_back(c1)
 *             i1+=1             # <<<<<<<<<<<<<<
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 */
    __pyx_v_i1 = (__pyx_v_i1 + 1);
  }

  /* "lurrn/sparsmat.pyx":6463
 *             result.vec.push_back(c1)
 *             i1+=1
 *         while i2<other.vec.size():             # <<<<<<<<<<<<<<
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 */
  while (1) {
    __pyx_t_5 = ((__pyx_v_i2 < __pyx_v_other->vec.size()) != 0);
    if (!__pyx_t_5) break;

    /* "lurrn/sparsmat.pyx":6464
 *             i1+=1
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)             # <<<<<<<<<<<<<<
 *             result.vec.push_back(c2)
 *             i2+=1
 */
    __pyx_v_c2 = __pyx_v_other->vec.at(__pyx_v_i2);

    /* "lurrn/sparsmat.pyx":6465
 *         while i2<other.vec.size():
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)             # <<<<<<<<<<<<<<
 *             i2+=1
 *         return result
 */
    __pyx_v_result->vec.push_back(__pyx_v_c2);

    /* "lurrn/sparsmat.pyx":6466
 *             c2=other.vec.at(i2)
 *             result.vec.push_back(c2)
 *             i2+=1             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_v_i2 = (__pyx_v_i2 + 1);
  }

  /* "lurrn/sparsmat.pyx":6467
 *             result.vec.push_back(c2)
 *             i2+=1
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def tofile(self, f):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6427
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):
 *         self.c_add(k0,k1,k2)
 *     def __add__(VecV3 self, VecV3 other):             # <<<<<<<<<<<<<<
 *         cdef c_CItemV3 c1, c2
 *         cdef unsigned int i1, i2
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6469
 *         return result
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_17tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_17tofile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tofile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV3_16tofile(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_16tofile(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  long __pyx_v_k;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  long __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("tofile", 0);

  /* "lurrn/sparsmat.pyx":6471
 *     def tofile(self, f):
 *         cdef long i, n, k, k_max
 *         n=self.get_size()             # <<<<<<<<<<<<<<
 *         f.write('V3 %d\n'%(n,))
 *         k=0
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_4;

  /* "lurrn/sparsmat.pyx":6472
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 *         f.write('V3 %d\n'%(n,))             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_V3_d, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6473
 *         n=self.get_size()
 *         f.write('V3 %d\n'%(n,))
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecV3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemV3))
 */
  __pyx_v_k = 0;

  /* "lurrn/sparsmat.pyx":6474
 *         f.write('V3 %d\n'%(n,))
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecV3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemV3))
 *             f.write(s)
 */
  __pyx_t_4 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":6475
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecV3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemV3))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *             k+=CHUNK_SIZE
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), (256 * (sizeof(struct CountItem<3,void>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":6476
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=PyString_FromStringAndSize(<char *>c_VecV3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemV3))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":6477
 *             s=PyString_FromStringAndSize(<char *>c_VecV3_get_pointer(&self.vec,k), CHUNK_SIZE*sizeof(c_CItemV3))
 *             f.write(s)
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecV3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemV3))
 */
    __pyx_v_k = (__pyx_v_k + 256);
  }

  /* "lurrn/sparsmat.pyx":6478
 *             f.write(s)
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=PyString_FromStringAndSize(<char *>c_VecV3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemV3))
 *             f.write(s)
 */
  __pyx_t_7 = ((__pyx_v_k < __pyx_v_n) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":6479
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecV3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemV3))             # <<<<<<<<<<<<<<
 *             f.write(s)
 *     def fromfile(self, f):
 */
    __pyx_t_1 = PyString_FromStringAndSize(((char *)get_pointer((&__pyx_v_self->vec), __pyx_v_k)), ((__pyx_v_n - __pyx_v_k) * (sizeof(struct CountItem<3,void>)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":6480
 *         if k<n:
 *             s=PyString_FromStringAndSize(<char *>c_VecV3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemV3))
 *             f.write(s)             # <<<<<<<<<<<<<<
 *     def fromfile(self, f):
 *         cdef long i, n
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":6469
 *         return result
 * 
 *     def tofile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n, k, k_max
 *         n=self.get_size()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.tofile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6481
 *             s=PyString_FromStringAndSize(<char *>c_VecV3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemV3))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_19fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_19fromfile(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fromfile (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV3_18fromfile(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self), ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_18fromfile(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, PyObject *__pyx_v_f) {
  CYTHON_UNUSED long __pyx_v_i;
  long __pyx_v_n;
  PyObject *__pyx_v_line = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  long __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  size_t __pyx_t_9;
  char *__pyx_t_10;
  size_t __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromfile", 0);

  /* "lurrn/sparsmat.pyx":6483
 *     def fromfile(self, f):
 *         cdef long i, n
 *         line=f.readline().strip().split()             # <<<<<<<<<<<<<<
 *         assert line[0]=='V3'
 *         n=long(line[1])
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_readline); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_line = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6484
 *         cdef long i, n
 *         line=f.readline().strip().split()
 *         assert line[0]=='V3'             # <<<<<<<<<<<<<<
 *         n=long(line[1])
 *         self.clear()
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6484; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_V3, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_6)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":6485
 *         line=f.readline().strip().split()
 *         assert line[0]=='V3'
 *         n=long(line[1])             # <<<<<<<<<<<<<<
 *         self.clear()
 *         self.vec.resize(n)
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_line, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6485; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyLong_Type))), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_7;

  /* "lurrn/sparsmat.pyx":6486
 *         assert line[0]=='V3'
 *         n=long(line[1])
 *         self.clear()             # <<<<<<<<<<<<<<
 *         self.vec.resize(n)
 *         k=0
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clear); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6487
 *         n=long(line[1])
 *         self.clear()
 *         self.vec.resize(n)             # <<<<<<<<<<<<<<
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 */
  __pyx_v_self->vec.resize(__pyx_v_n);

  /* "lurrn/sparsmat.pyx":6488
 *         self.clear()
 *         self.vec.resize(n)
 *         k=0             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemV3))
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_k = __pyx_int_0;

  /* "lurrn/sparsmat.pyx":6489
 *         self.vec.resize(n)
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemV3))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemV3)
 */
  __pyx_t_7 = __Pyx_div_long(__pyx_v_n, 256);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":6490
 *         k=0
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemV3))             # <<<<<<<<<<<<<<
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemV3)
 *             memcpy(<void *>c_VecV3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemV3))
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyInt_FromSize_t((256 * (sizeof(struct CountItem<3,void>)))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":6491
 *         for i from 0<=i<n/CHUNK_SIZE:
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemV3))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemV3)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecV3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemV3))
 *             k+=CHUNK_SIZE
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!((__pyx_t_8 == (256 * (sizeof(struct CountItem<3,void>)))) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":6492
 *             s=f.read(CHUNK_SIZE*sizeof(c_CItemV3))
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemV3)
 *             memcpy(<void *>c_VecV3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemV3))             # <<<<<<<<<<<<<<
 *             k+=CHUNK_SIZE
 *         if k<n:
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), (256 * (sizeof(struct CountItem<3,void>))));

    /* "lurrn/sparsmat.pyx":6493
 *             assert len(s)==CHUNK_SIZE*sizeof(c_CItemV3)
 *             memcpy(<void *>c_VecV3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemV3))
 *             k+=CHUNK_SIZE             # <<<<<<<<<<<<<<
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemV3))
 */
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_k, __pyx_int_256); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_1);
    __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":6494
 *             memcpy(<void *>c_VecV3_get_pointer(&self.vec,k), <char *>s, CHUNK_SIZE*sizeof(c_CItemV3))
 *             k+=CHUNK_SIZE
 *         if k<n:             # <<<<<<<<<<<<<<
 *             s=f.read((n-k)*sizeof(c_CItemV3))
 *             assert len(s)==(n-k)*sizeof(c_CItemV3)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "lurrn/sparsmat.pyx":6495
 *             k+=CHUNK_SIZE
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemV3))             # <<<<<<<<<<<<<<
 *             assert len(s)==(n-k)*sizeof(c_CItemV3)
 *             memcpy(<void *>c_VecV3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemV3))
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_5, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<3,void>))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "lurrn/sparsmat.pyx":6496
 *         if k<n:
 *             s=f.read((n-k)*sizeof(c_CItemV3))
 *             assert len(s)==(n-k)*sizeof(c_CItemV3)             # <<<<<<<<<<<<<<
 *             memcpy(<void *>c_VecV3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemV3))
 *     cpdef int get_maxcol(self, int k=0):
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<3,void>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_6)) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "lurrn/sparsmat.pyx":6497
 *             s=f.read((n-k)*sizeof(c_CItemV3))
 *             assert len(s)==(n-k)*sizeof(c_CItemV3)
 *             memcpy(<void *>c_VecV3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemV3))             # <<<<<<<<<<<<<<
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 */
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_k); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct CountItem<3,void>))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    memcpy(((void *)get_pointer((&__pyx_v_self->vec), __pyx_t_9)), ((char *)__pyx_t_10), __pyx_t_11);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lurrn/sparsmat.pyx":6481
 *             s=PyString_FromStringAndSize(<char *>c_VecV3_get_pointer(&self.vec,k), (n-k)*sizeof(c_CItemV3))
 *             f.write(s)
 *     def fromfile(self, f):             # <<<<<<<<<<<<<<
 *         cdef long i, n
 *         line=f.readline().strip().split()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.fromfile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_line);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6498
 *             assert len(s)==(n-k)*sizeof(c_CItemV3)
 *             memcpy(<void *>c_VecV3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemV3))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<3
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_21get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5lurrn_8sparsmat_5VecV3_get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV3_get_maxcol *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_i;
  int __pyx_v_n;
  int __pyx_v_new_val;
  int __pyx_v_col;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_maxcol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV3_21get_maxcol)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":6500
 *     cpdef int get_maxcol(self, int k=0):
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<3             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         if n==0:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_9 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_9 = ((__pyx_v_k < 3) != 0);
    __pyx_t_8 = __pyx_t_9;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_8)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6500; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":6501
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<3
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         if n==0:
 *             return -1
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":6502
 *         assert k>=0 and k<3
 *         n=self.vec.size()
 *         if n==0:             # <<<<<<<<<<<<<<
 *             return -1
 *         if k==0:
 */
  __pyx_t_8 = ((__pyx_v_n == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":6503
 *         n=self.vec.size()
 *         if n==0:
 *             return -1             # <<<<<<<<<<<<<<
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 */
    __pyx_r = -1;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":6504
 *         if n==0:
 *             return -1
 *         if k==0:             # <<<<<<<<<<<<<<
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 */
  __pyx_t_8 = ((__pyx_v_k == 0) != 0);
  if (__pyx_t_8) {

    /* "lurrn/sparsmat.pyx":6505
 *             return -1
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]             # <<<<<<<<<<<<<<
 *         col=-1
 *         n=self.vec.size()
 */
    __pyx_r = (__pyx_v_self->vec.at((__pyx_v_n - 1)).addr[0]);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":6506
 *         if k==0:
 *             return self.vec.at(n-1).addr[0]
 *         col=-1             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_v_col = -1;

  /* "lurrn/sparsmat.pyx":6507
 *             return self.vec.at(n-1).addr[0]
 *         col=-1
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":6508
 *         col=-1
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 */
  __pyx_t_7 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":6509
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             if new_val>col:
 *                 col=new_val
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":6510
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:             # <<<<<<<<<<<<<<
 *                 col=new_val
 *         return col
 */
    __pyx_t_8 = ((__pyx_v_new_val > __pyx_v_col) != 0);
    if (__pyx_t_8) {

      /* "lurrn/sparsmat.pyx":6511
 *             new_val=self.vec.at(i).addr[k]
 *             if new_val>col:
 *                 col=new_val             # <<<<<<<<<<<<<<
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 */
      __pyx_v_col = __pyx_v_new_val;
      goto __pyx_L9;
    }
    __pyx_L9:;
  }

  /* "lurrn/sparsmat.pyx":6512
 *             if new_val>col:
 *                 col=new_val
 *         return col             # <<<<<<<<<<<<<<
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):
 *         cdef int old_val, new_val, i, n, count
 */
  __pyx_r = __pyx_v_col;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6498
 *             assert len(s)==(n-k)*sizeof(c_CItemV3)
 *             memcpy(<void *>c_VecV3_get_pointer(&self.vec,k), <char *>s, (n-k)*sizeof(c_CItemV3))
 *     cpdef int get_maxcol(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int i, n, new_val, col
 *         assert k>=0 and k<3
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lurrn.sparsmat.VecV3.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_21get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_21get_maxcol(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_maxcol (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_maxcol") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6498; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6498; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_maxcol", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6498; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV3_20get_maxcol(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_20get_maxcol(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecV3_get_maxcol __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_maxcol", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = __pyx_vtabptr_5lurrn_8sparsmat_VecV3->get_maxcol(__pyx_v_self, 1, &__pyx_t_2); 
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.get_maxcol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6513
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_23get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyArrayObject *__pyx_f_5lurrn_8sparsmat_5VecV3_get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV3_get_type_counts *__pyx_optional_args) {
  int __pyx_v_k = ((int)0);
  int __pyx_v_new_val;
  int __pyx_v_i;
  int __pyx_v_n;
  PyArrayObject *__pyx_v_result = 0;
  long __pyx_v_n_types;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecV3_get_maxcol __pyx_t_11;
  PyArrayObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_k = __pyx_optional_args->k;
    }
  }
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV3_23get_type_counts)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":6516
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<3             # <<<<<<<<<<<<<<
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_8 = ((__pyx_v_k >= 0) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_k < 3) != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_7)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lurrn/sparsmat.pyx":6517
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 *         assert k>=0 and k<3
 *         if self.vec.size()==0:             # <<<<<<<<<<<<<<
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 */
  __pyx_t_7 = ((__pyx_v_self->vec.size() == 0) != 0);
  if (__pyx_t_7) {

    /* "lurrn/sparsmat.pyx":6518
 *         assert k>=0 and k<3
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_9 = 1;
      }
    }
    __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_2) {
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":6519
 *         if self.vec.size()==0:
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":6520
 *             return numpy.zeros(0, numpy.int32)
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1             # <<<<<<<<<<<<<<
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 */
  __pyx_t_11.__pyx_n = 1;
  __pyx_t_11.k = __pyx_v_k;
  __pyx_t_10 = ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV3 *)__pyx_v_self->__pyx_vtab)->get_maxcol(__pyx_v_self, 0, &__pyx_t_11); 
  __pyx_v_n_types = (__pyx_t_10 + 1);

  /* "lurrn/sparsmat.pyx":6521
 *         self.ensure_compact()
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)             # <<<<<<<<<<<<<<
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_n_types); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_9 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_6) {
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
  }
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_12 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
    }
    __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_12 = 0;
  __pyx_v_result = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6522
 *         n_types=self.get_maxcol(k)+1
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()             # <<<<<<<<<<<<<<
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":6523
 *         result=numpy.zeros(n_types,numpy.int32)
 *         n=self.vec.size()
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":6524
 *         n=self.vec.size()
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]             # <<<<<<<<<<<<<<
 *             result[new_val]+=1
 *         return result
 */
    __pyx_v_new_val = (__pyx_v_self->vec.at(__pyx_v_i).addr[__pyx_v_k]);

    /* "lurrn/sparsmat.pyx":6525
 *         for i from 0<=i<n:
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1             # <<<<<<<<<<<<<<
 *         return result
 *     cpdef VecV3 remap(self, int k, numpy.ndarray filt):
 */
    __pyx_t_16 = __pyx_v_new_val;
    __pyx_t_17 = -1;
    if (__pyx_t_16 < 0) {
      __pyx_t_16 += __pyx_pybuffernd_result.diminfo[0].shape;
      if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 0;
    } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_17 = 0;
    if (unlikely(__pyx_t_17 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_17);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_result.diminfo[0].strides) += 1;
  }

  /* "lurrn/sparsmat.pyx":6526
 *             new_val=self.vec.at(i).addr[k]
 *             result[new_val]+=1
 *         return result             # <<<<<<<<<<<<<<
 *     cpdef VecV3 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyArrayObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6513
 *                 col=new_val
 *         return col
 *     cpdef numpy.ndarray get_type_counts(self, int k=0):             # <<<<<<<<<<<<<<
 *         cdef int old_val, new_val, i, n, count
 *         cdef numpy.ndarray[numpy.int32_t, ndim=1] result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_23get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_23get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6513; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6513; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_k = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6513; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV3_22get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_22get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, int __pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_5lurrn_8sparsmat_5VecV3_get_type_counts __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.k = __pyx_v_k;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_5lurrn_8sparsmat_VecV3->get_type_counts(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6527
 *             result[new_val]+=1
 *         return result
 *     cpdef VecV3 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_25remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_f_5lurrn_8sparsmat_5VecV3_remap(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_wanted = 0;
  PyArrayObject *__pyx_v_target = 0;
  int __pyx_v_n;
  int __pyx_v_i;
  struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_result = 0;
  struct CountItem<3,void> __pyx_v_c;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_target;
  __Pyx_Buffer __pyx_pybuffer_target;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_wanted;
  __Pyx_Buffer __pyx_pybuffer_wanted;
  struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __pyx_pybuffer_wanted.pybuffer.buf = NULL;
  __pyx_pybuffer_wanted.refcount = 0;
  __pyx_pybuffernd_wanted.data = NULL;
  __pyx_pybuffernd_wanted.rcbuffer = &__pyx_pybuffer_wanted;
  __pyx_pybuffer_target.pybuffer.buf = NULL;
  __pyx_pybuffer_target.refcount = 0;
  __pyx_pybuffernd_target.data = NULL;
  __pyx_pybuffernd_target.rcbuffer = &__pyx_pybuffer_target;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_remap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV3_25remap)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_filt));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_filt));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_filt));
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5lurrn_8sparsmat_VecV3))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":6528
 *         return result
 *     cpdef VecV3 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__88, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_wanted = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_wanted.diminfo[0].strides = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_wanted.diminfo[0].shape = __pyx_pybuffernd_wanted.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_8 = 0;
  __pyx_v_wanted = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6529
 *     cpdef VecV3 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_filt), __pyx_n_s_cumsum); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Subtract(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_target = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_target.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_target.diminfo[0].strides = __pyx_pybuffernd_target.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_target.diminfo[0].shape = __pyx_pybuffernd_target.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_9 = 0;
  __pyx_v_target = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6530
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         cdef int n=self.vec.size()
 *         cdef int i
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV3 *)__pyx_v_self->__pyx_vtab)->ensure_compact(__pyx_v_self);

  /* "lurrn/sparsmat.pyx":6531
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 *         cdef int n=self.vec.size()             # <<<<<<<<<<<<<<
 *         cdef int i
 *         cdef VecV3 result=VecV3()
 */
  __pyx_v_n = __pyx_v_self->vec.size();

  /* "lurrn/sparsmat.pyx":6533
 *         cdef int n=self.vec.size()
 *         cdef int i
 *         cdef VecV3 result=VecV3()             # <<<<<<<<<<<<<<
 *         cdef c_CItemV3 c
 *         for i from 0<=i<n:
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6535
 *         cdef VecV3 result=VecV3()
 *         cdef c_CItemV3 c
 *         for i from 0<=i<n:             # <<<<<<<<<<<<<<
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 */
  __pyx_t_10 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "lurrn/sparsmat.pyx":6536
 *         cdef c_CItemV3 c
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)             # <<<<<<<<<<<<<<
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 */
    __pyx_v_c = __pyx_v_self->vec.at(__pyx_v_i);

    /* "lurrn/sparsmat.pyx":6537
 *         for i from 0<=i<n:
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:             # <<<<<<<<<<<<<<
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 */
    __pyx_t_11 = (__pyx_v_c.addr[__pyx_v_k]);
    __pyx_t_12 = -1;
    if (__pyx_t_11 < 0) {
      __pyx_t_11 += __pyx_pybuffernd_wanted.diminfo[0].shape;
      if (unlikely(__pyx_t_11 < 0)) __pyx_t_12 = 0;
    } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_wanted.diminfo[0].shape)) __pyx_t_12 = 0;
    if (unlikely(__pyx_t_12 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_12);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_pybuffernd_wanted.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_wanted.diminfo[0].strides)) != 0);
    if (__pyx_t_13) {

      /* "lurrn/sparsmat.pyx":6538
 *             c=self.vec.at(i)
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]             # <<<<<<<<<<<<<<
 *                 result.vec.push_back(c)
 *         return result
 */
      __pyx_t_12 = (__pyx_v_c.addr[__pyx_v_k]);
      __pyx_t_14 = -1;
      if (__pyx_t_12 < 0) {
        __pyx_t_12 += __pyx_pybuffernd_target.diminfo[0].shape;
        if (unlikely(__pyx_t_12 < 0)) __pyx_t_14 = 0;
      } else if (unlikely(__pyx_t_12 >= __pyx_pybuffernd_target.diminfo[0].shape)) __pyx_t_14 = 0;
      if (unlikely(__pyx_t_14 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_14);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      (__pyx_v_c.addr[__pyx_v_k]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_target.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_target.diminfo[0].strides));

      /* "lurrn/sparsmat.pyx":6539
 *             if wanted[c.addr[k]]:
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)             # <<<<<<<<<<<<<<
 *         return result
 *     def append(self,tup):
 */
      __pyx_v_result->vec.push_back(__pyx_v_c);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "lurrn/sparsmat.pyx":6540
 *                 c.addr[k]=target[c.addr[k]]
 *                 result.vec.push_back(c)
 *         return result             # <<<<<<<<<<<<<<
 *     def append(self,tup):
 *         k0,k1,k2=tup
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6527
 *             result[new_val]+=1
 *         return result
 *     cpdef VecV3 remap(self, int k, numpy.ndarray filt):             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wanted.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_wanted);
  __Pyx_XDECREF((PyObject *)__pyx_v_target);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_25remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_25remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6527; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6527; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6527; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_filt = ((PyArrayObject *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6527; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_filt), __pyx_ptype_5numpy_ndarray, 1, "filt", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV3_24remap(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_24remap(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5lurrn_8sparsmat_5VecV3_remap(__pyx_v_self, __pyx_v_k, __pyx_v_filt, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6541
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,k1,k2=tup
 *         self.c_add(k0,k1,k2)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_27append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_27append(PyObject *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("append (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV3_26append(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self), ((PyObject *)__pyx_v_tup));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_26append(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, PyObject *__pyx_v_tup) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_k1 = NULL;
  PyObject *__pyx_v_k2 = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *(*__pyx_t_5)(PyObject *);
  coordinate_t __pyx_t_6;
  coordinate_t __pyx_t_7;
  coordinate_t __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("append", 0);

  /* "lurrn/sparsmat.pyx":6542
 *         return result
 *     def append(self,tup):
 *         k0,k1,k2=tup             # <<<<<<<<<<<<<<
 *         self.c_add(k0,k1,k2)
 *     def extend(self,tups):
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_tup))) || (PyList_CheckExact(__pyx_v_tup))) {
    PyObject* sequence = __pyx_v_tup;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    #endif
  } else {
    Py_ssize_t index = -1;
    __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 2; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_k0 = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_k1 = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_k2 = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "lurrn/sparsmat.pyx":6543
 *     def append(self,tup):
 *         k0,k1,k2=tup
 *         self.c_add(k0,k1,k2)             # <<<<<<<<<<<<<<
 *     def extend(self,tups):
 *         for k0,k1,k2 in tups:
 */
  __pyx_t_6 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_6 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k1); if (unlikely((__pyx_t_7 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k2); if (unlikely((__pyx_t_8 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV3 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_6, __pyx_t_7, __pyx_t_8);

  /* "lurrn/sparsmat.pyx":6541
 *                 result.vec.push_back(c)
 *         return result
 *     def append(self,tup):             # <<<<<<<<<<<<<<
 *         k0,k1,k2=tup
 *         self.c_add(k0,k1,k2)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_k1);
  __Pyx_XDECREF(__pyx_v_k2);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6544
 *         k0,k1,k2=tup
 *         self.c_add(k0,k1,k2)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,k1,k2 in tups:
 *             self.c_add(k0,k1,k2)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_29extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_29extend(PyObject *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extend (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV3_28extend(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self), ((PyObject *)__pyx_v_tups));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_28extend(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, PyObject *__pyx_v_tups) {
  PyObject *__pyx_v_k0 = NULL;
  PyObject *__pyx_v_k1 = NULL;
  PyObject *__pyx_v_k2 = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  coordinate_t __pyx_t_10;
  coordinate_t __pyx_t_11;
  coordinate_t __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("extend", 0);

  /* "lurrn/sparsmat.pyx":6545
 *         self.c_add(k0,k1,k2)
 *     def extend(self,tups):
 *         for k0,k1,k2 in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,k1,k2)
 *     def __iter__(self):
 */
  if (likely(PyList_CheckExact(__pyx_v_tups)) || PyTuple_CheckExact(__pyx_v_tups)) {
    __pyx_t_1 = __pyx_v_tups; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_tups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_8 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      index = 2; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_9 = NULL;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_k0, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_k1, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_k2, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "lurrn/sparsmat.pyx":6546
 *     def extend(self,tups):
 *         for k0,k1,k2 in tups:
 *             self.c_add(k0,k1,k2)             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self.item_iter()
 */
    __pyx_t_10 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k0); if (unlikely((__pyx_t_10 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k1); if (unlikely((__pyx_t_11 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_12 = __Pyx_PyInt_As_coordinate_t(__pyx_v_k2); if (unlikely((__pyx_t_12 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV3 *)__pyx_v_self->__pyx_vtab)->c_add(__pyx_v_self, __pyx_t_10, __pyx_t_11, __pyx_t_12);

    /* "lurrn/sparsmat.pyx":6545
 *         self.c_add(k0,k1,k2)
 *     def extend(self,tups):
 *         for k0,k1,k2 in tups:             # <<<<<<<<<<<<<<
 *             self.c_add(k0,k1,k2)
 *     def __iter__(self):
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6544
 *         k0,k1,k2=tup
 *         self.c_add(k0,k1,k2)
 *     def extend(self,tups):             # <<<<<<<<<<<<<<
 *         for k0,k1,k2 in tups:
 *             self.c_add(k0,k1,k2)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.extend", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k0);
  __Pyx_XDECREF(__pyx_v_k1);
  __Pyx_XDECREF(__pyx_v_k2);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6547
 *         for k0,k1,k2 in tups:
 *             self.c_add(k0,k1,k2)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_31__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_31__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV3_30__iter__(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_30__iter__(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":6548
 *             self.c_add(k0,k1,k2)
 *     def __iter__(self):
 *         return self.item_iter()             # <<<<<<<<<<<<<<
 *     def __reduce__(self):
 *         return (VecV3,(),(),self.item_iter())
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6547
 *         for k0,k1,k2 in tups:
 *             self.c_add(k0,k1,k2)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.item_iter()
 *     def __reduce__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6549
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecV3,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_33__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_33__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV3_32__reduce__(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_32__reduce__(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "lurrn/sparsmat.pyx":6550
 *         return self.item_iter()
 *     def __reduce__(self):
 *         return (VecV3,(),(),self.item_iter())             # <<<<<<<<<<<<<<
 *     def __setstate__(self,state):
 *         pass
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV3)));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV3)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV3)));
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  __Pyx_INCREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6549
 *     def __iter__(self):
 *         return self.item_iter()
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (VecV3,(),(),self.item_iter())
 *     def __setstate__(self,state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6551
 *     def __reduce__(self):
 *         return (VecV3,(),(),self.item_iter())
 *     def __setstate__(self,state):             # <<<<<<<<<<<<<<
 *         pass
 *     def __repr__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_35__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_35__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV3_34__setstate__(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self), ((PyObject *)__pyx_v_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_34__setstate__(CYTHON_UNUSED struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6553
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecV3(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_37__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_5VecV3_37__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_5VecV3_36__repr__(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_5VecV3_36__repr__(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "lurrn/sparsmat.pyx":6554
 *         pass
 *     def __repr__(self):
 *         return 'VecV3(%s)'%(str(list(self)),)             # <<<<<<<<<<<<<<
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_VecV3_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6553
 *     def __setstate__(self,state):
 *         pass
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return 'VecV3(%s)'%(str(list(self)),)
 *     def __dealloc__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lurrn.sparsmat.VecV3.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6555
 *     def __repr__(self):
 *         return 'VecV3(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

/* Python wrapper */
static void __pyx_pw_5lurrn_8sparsmat_5VecV3_39__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5lurrn_8sparsmat_5VecV3_39__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5lurrn_8sparsmat_5VecV3_38__dealloc__(((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5lurrn_8sparsmat_5VecV3_38__dealloc__(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lurrn/sparsmat.pyx":6557
 *     def __dealloc__(self):
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()             # <<<<<<<<<<<<<<
 * 
 * cdef class IVecV3_iter:
 */
  __pyx_v_self->vec.~vector();

  /* "lurrn/sparsmat.pyx":6555
 *     def __repr__(self):
 *         return 'VecV3(%s)'%(str(list(self)),)
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # need to call destructor explicitly
 *         self.vec.cxx_destructor()
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "lurrn/sparsmat.pyx":6563
 *     cdef c_VecV3 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_11IVecV3_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_11IVecV3_iter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_vec = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_vec,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6563; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_vec = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6563; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.IVecV3_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecV3_iter___init__(((struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter *)__pyx_v_self), __pyx_v_vec);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_11IVecV3_iter___init__(struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter *__pyx_v_self, PyObject *__pyx_v_vec) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":6564
 *     cdef unsigned int k
 *     def __init__(self,vec):
 *         self.vec=vec             # <<<<<<<<<<<<<<
 *         self.vecC=&self.vec.vec
 *         self.k=0
 */
  if (!(likely(((__pyx_v_vec) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_vec, __pyx_ptype_5lurrn_8sparsmat_VecV3))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_vec;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->vec);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->vec));
  __pyx_v_self->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6565
 *     def __init__(self,vec):
 *         self.vec=vec
 *         self.vecC=&self.vec.vec             # <<<<<<<<<<<<<<
 *         self.k=0
 *     def __iter__(self):
 */
  __pyx_v_self->vecC = (&__pyx_v_self->vec->vec);

  /* "lurrn/sparsmat.pyx":6566
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 *         self.k=0             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return self
 */
  __pyx_v_self->k = 0;

  /* "lurrn/sparsmat.pyx":6563
 *     cdef c_VecV3 *vecC
 *     cdef unsigned int k
 *     def __init__(self,vec):             # <<<<<<<<<<<<<<
 *         self.vec=vec
 *         self.vecC=&self.vec.vec
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecV3_iter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6567
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecV3_iter_3__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecV3_iter_3__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecV3_iter_2__iter__(((struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecV3_iter_2__iter__(struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":6568
 *         self.k=0
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6567
 *         self.vecC=&self.vec.vec
 *         self.k=0
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 *     def __next__(self):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6569
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecV3_iter_5__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_11IVecV3_iter_5__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_11IVecV3_iter_4__next__(((struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_11IVecV3_iter_4__next__(struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter *__pyx_v_self) {
  struct CountItem<3,void> __pyx_v_res;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "lurrn/sparsmat.pyx":6570
 *         return self
 *     def __next__(self):
 *         if self.k>=self.vecC.size():             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         cdef c_CItemV3 res=self.vecC.at(self.k)
 */
  __pyx_t_1 = ((__pyx_v_self->k >= __pyx_v_self->vecC->size()) != 0);
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":6571
 *     def __next__(self):
 *         if self.k>=self.vecC.size():
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         cdef c_CItemV3 res=self.vecC.at(self.k)
 *         self.k+=1
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lurrn/sparsmat.pyx":6572
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 *         cdef c_CItemV3 res=self.vecC.at(self.k)             # <<<<<<<<<<<<<<
 *         self.k+=1
 *         return (res.addr[0],
 */
  __pyx_v_res = __pyx_v_self->vecC->at(__pyx_v_self->k);

  /* "lurrn/sparsmat.pyx":6573
 *             raise StopIteration
 *         cdef c_CItemV3 res=self.vecC.at(self.k)
 *         self.k+=1             # <<<<<<<<<<<<<<
 *         return (res.addr[0],
 *                 res.addr[1],
 */
  __pyx_v_self->k = (__pyx_v_self->k + 1);

  /* "lurrn/sparsmat.pyx":6574
 *         cdef c_CItemV3 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.addr[1],
 *                 res.addr[2])
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_res.addr[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "lurrn/sparsmat.pyx":6575
 *         self.k+=1
 *         return (res.addr[0],
 *                 res.addr[1],             # <<<<<<<<<<<<<<
 *                 res.addr[2])
 * 
 */
  __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_res.addr[1])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "lurrn/sparsmat.pyx":6576
 *         return (res.addr[0],
 *                 res.addr[1],
 *                 res.addr[2])             # <<<<<<<<<<<<<<
 * 
 * cdef class LargeVecV3:
 */
  __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_res.addr[2])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "lurrn/sparsmat.pyx":6574
 *         cdef c_CItemV3 res=self.vecC.at(self.k)
 *         self.k+=1
 *         return (res.addr[0],             # <<<<<<<<<<<<<<
 *                 res.addr[1],
 *                 res.addr[2])
 */
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6569
 *     def __iter__(self):
 *         return self
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self.k>=self.vecC.size():
 *             raise StopIteration
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lurrn.sparsmat.IVecV3_iter.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6581
 *     cdef public object compact
 *     cdef public VecV3 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecV3()
 */

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV3_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV3_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV3___init__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV3___init__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lurrn/sparsmat.pyx":6582
 *     cdef public VecV3 loose
 *     def __init__(self):
 *         self.compact=[]             # <<<<<<<<<<<<<<
 *         self.loose=VecV3()
 *         self.loose.vec.reserve(100000)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6583
 *     def __init__(self):
 *         self.compact=[]
 *         self.loose=VecV3()             # <<<<<<<<<<<<<<
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6584
 *         self.compact=[]
 *         self.loose=VecV3()
 *         self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 */
  __pyx_v_self->loose->vec.reserve(100000);

  /* "lurrn/sparsmat.pyx":6581
 *     cdef public object compact
 *     cdef public VecV3 loose
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.compact=[]
 *         self.loose=VecV3()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV3.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6585
 *         self.loose=VecV3()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_3ensure_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ensure_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_2ensure_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV3_2ensure_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ensure_compact", 0);

  /* "lurrn/sparsmat.pyx":6586
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *         self.loose=VecV3()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "lurrn/sparsmat.pyx":6587
 *     def ensure_compact(self):
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *         self.loose=VecV3()
 *         while len(self.compact)>=2:
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":6588
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 *         self.loose=VecV3()             # <<<<<<<<<<<<<<
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6589
 *             self.compact.append(self.loose)
 *         self.loose=VecV3()
 *         while len(self.compact)>=2:             # <<<<<<<<<<<<<<
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):
 */
  while (1) {
    __pyx_t_2 = __pyx_v_self->compact;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = ((__pyx_t_6 >= 2) != 0);
    if (!__pyx_t_4) break;

    /* "lurrn/sparsmat.pyx":6590
 *         self.loose=VecV3()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):
 *         self.loose.c_add(k0,k1,k2)
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6590; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6590; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_1, -2, 0, NULL, NULL, &__pyx_slice__89, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "lurrn/sparsmat.pyx":6585
 *         self.loose=VecV3()
 *         self.loose.vec.reserve(100000)
 *     def ensure_compact(self):             # <<<<<<<<<<<<<<
 *         if self.loose.get_size()>0:
 *             self.compact.append(self.loose)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV3.ensure_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6591
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0,k1,k2)
 *         if self.loose.get_size(False)>=100000:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_5add_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  coordinate_t __pyx_v_k0;
  coordinate_t __pyx_v_k1;
  coordinate_t __pyx_v_k2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_count (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k0,&__pyx_n_s_k1,&__pyx_n_s_k2,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6591; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_count", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6591; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6591; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_k0 = __Pyx_PyInt_As_coordinate_t(values[0]); if (unlikely((__pyx_v_k0 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6591; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k1 = __Pyx_PyInt_As_coordinate_t(values[1]); if (unlikely((__pyx_v_k1 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6591; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k2 = __Pyx_PyInt_As_coordinate_t(values[2]); if (unlikely((__pyx_v_k2 == (coordinate_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6591; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_count", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6591; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV3.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_4add_count(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *)__pyx_v_self), __pyx_v_k0, __pyx_v_k1, __pyx_v_k2);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV3_4add_count(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self, coordinate_t __pyx_v_k0, coordinate_t __pyx_v_k1, coordinate_t __pyx_v_k2) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_count", 0);

  /* "lurrn/sparsmat.pyx":6592
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):
 *         self.loose.c_add(k0,k1,k2)             # <<<<<<<<<<<<<<
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV3 *)__pyx_v_self->loose->__pyx_vtab)->c_add(__pyx_v_self->loose, __pyx_v_k0, __pyx_v_k1, __pyx_v_k2);

  /* "lurrn/sparsmat.pyx":6593
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):
 *         self.loose.c_add(k0,k1,k2)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__90, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_100000, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {

    /* "lurrn/sparsmat.pyx":6594
 *         self.loose.c_add(k0,k1,k2)
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()             # <<<<<<<<<<<<<<
 *             self.compact.append(self.loose)
 *             self.loose=VecV3()
 */
    ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV3 *)__pyx_v_self->loose->__pyx_vtab)->ensure_compact(__pyx_v_self->loose);

    /* "lurrn/sparsmat.pyx":6595
 *         if self.loose.get_size(False)>=100000:
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)             # <<<<<<<<<<<<<<
 *             self.loose=VecV3()
 *             self.loose.vec.reserve(100000)
 */
    __pyx_t_4 = __Pyx_PyObject_Append(__pyx_v_self->compact, ((PyObject *)__pyx_v_self->loose)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lurrn/sparsmat.pyx":6596
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 *             self.loose=VecV3()             # <<<<<<<<<<<<<<
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 */
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->loose);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
    __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":6597
 *             self.compact.append(self.loose)
 *             self.loose=VecV3()
 *             self.loose.vec.reserve(100000)             # <<<<<<<<<<<<<<
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 */
    __pyx_v_self->loose->vec.reserve(100000);

    /* "lurrn/sparsmat.pyx":6598
 *             self.loose=VecV3()
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and             # <<<<<<<<<<<<<<
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 */
    while (1) {
      __pyx_t_1 = __pyx_v_self->compact;
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_6 = ((__pyx_t_5 >= 2) != 0);
      if (__pyx_t_6) {
      } else {
        __pyx_t_3 = __pyx_t_6;
        goto __pyx_L6_bool_binop_done;
      }

      /* "lurrn/sparsmat.pyx":6599
 *             self.loose.vec.reserve(100000)
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):             # <<<<<<<<<<<<<<
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 */
      __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6599; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_size); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      if (__pyx_t_2) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6599; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_size); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (__pyx_t_2) {
        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyNumber_Multiply(__pyx_float_0_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyObject_RichCompare(__pyx_t_1, __pyx_t_8, Py_GE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_3 = __pyx_t_6;
      __pyx_L6_bool_binop_done:;
      if (!__pyx_t_3) break;

      /* "lurrn/sparsmat.pyx":6600
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
      __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_self->compact, -2, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6600; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_self->compact, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6600; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_1 = PyNumber_Add(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      if (__Pyx_PyObject_SetSlice(__pyx_v_self->compact, __pyx_t_8, -2, 0, NULL, NULL, &__pyx_slice__91, 1, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lurrn/sparsmat.pyx":6591
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):             # <<<<<<<<<<<<<<
 *         self.loose.c_add(k0,k1,k2)
 *         if self.loose.get_size(False)>=100000:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV3.add_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6601
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_7get_compact(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_compact (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_6get_compact(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV3_6get_compact(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_compact", 0);

  /* "lurrn/sparsmat.pyx":6602
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         if len(self.compact)>0:
 *             return self.compact[0]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6603
 *     def get_compact(self):
 *         self.ensure_compact()
 *         if len(self.compact)>0:             # <<<<<<<<<<<<<<
 *             return self.compact[0]
 *         else:
 */
  __pyx_t_1 = __pyx_v_self->compact;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((__pyx_t_4 > 0) != 0);
  if (__pyx_t_5) {

    /* "lurrn/sparsmat.pyx":6604
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 *             return self.compact[0]             # <<<<<<<<<<<<<<
 *         else:
 *             return VecV3()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6604; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":6606
 *             return self.compact[0]
 *         else:
 *             return VecV3()             # <<<<<<<<<<<<<<
 *     def get_size(self, compactify=True):
 *         cdef int n
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecV3)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":6601
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]
 *     def get_compact(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         if len(self.compact)>0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV3.get_compact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6607
 *         else:
 *             return VecV3()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_9get_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compactify = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compactify,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compactify);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6607; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compactify = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_size", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6607; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV3.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_8get_size(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *)__pyx_v_self), __pyx_v_compactify);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV3_8get_size(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self, PyObject *__pyx_v_compactify) {
  int __pyx_v_n;
  PyObject *__pyx_v_c = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_size", 0);

  /* "lurrn/sparsmat.pyx":6609
 *     def get_size(self, compactify=True):
 *         cdef int n
 *         if compactify:             # <<<<<<<<<<<<<<
 *             self.ensure_compact()
 *             if self.compact:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compactify); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "lurrn/sparsmat.pyx":6610
 *         cdef int n
 *         if compactify:
 *             self.ensure_compact()             # <<<<<<<<<<<<<<
 *             if self.compact:
 *                 return self.compact[0].get_size()
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":6611
 *         if compactify:
 *             self.ensure_compact()
 *             if self.compact:             # <<<<<<<<<<<<<<
 *                 return self.compact[0].get_size()
 *             else:
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->compact); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_1) {

      /* "lurrn/sparsmat.pyx":6612
 *             self.ensure_compact()
 *             if self.compact:
 *                 return self.compact[0].get_size()             # <<<<<<<<<<<<<<
 *             else:
 *                 return 0
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6612; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    /*else*/ {

      /* "lurrn/sparsmat.pyx":6614
 *                 return self.compact[0].get_size()
 *             else:
 *                 return 0             # <<<<<<<<<<<<<<
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_int_0);
      __pyx_r = __pyx_int_0;
      goto __pyx_L0;
    }
  }
  /*else*/ {

    /* "lurrn/sparsmat.pyx":6616
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_v_self->compact)) || PyTuple_CheckExact(__pyx_v_self->compact)) {
      __pyx_t_4 = __pyx_v_self->compact; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_self->compact); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_get_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__92, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":6617
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->loose), __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__93, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_n = __pyx_t_8;

    /* "lurrn/sparsmat.pyx":6618
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)
 *             return n             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         self.ensure_compact()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":6607
 *         else:
 *             return VecV3()
 *     def get_size(self, compactify=True):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         if compactify:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV3.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_c);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6619
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_11__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_11__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_10__iter__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV3_10__iter__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lurrn/sparsmat.pyx":6620
 *             return n
 *     def __iter__(self):
 *         self.ensure_compact()             # <<<<<<<<<<<<<<
 *         try:
 *             return iter(self.compact[0])
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ensure_compact); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6621
 *     def __iter__(self):
 *         self.ensure_compact()
 *         try:             # <<<<<<<<<<<<<<
 *             return iter(self.compact[0])
 *         except IndexError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "lurrn/sparsmat.pyx":6622
 *         self.ensure_compact()
 *         try:
 *             return iter(self.compact[0])             # <<<<<<<<<<<<<<
 *         except IndexError:
 *             return iter([])
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->compact, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6622; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6622; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L7_try_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":6623
 *         try:
 *             return iter(self.compact[0])
 *         except IndexError:             # <<<<<<<<<<<<<<
 *             return iter([])
 * 
 */
    __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_IndexError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV3.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6623; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_3);

      /* "lurrn/sparsmat.pyx":6624
 *             return iter(self.compact[0])
 *         except IndexError:
 *             return iter([])             # <<<<<<<<<<<<<<
 * 
 *     def get_type_counts(self, k=0):
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6624; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6624; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_r = __pyx_t_9;
      __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
  }

  /* "lurrn/sparsmat.pyx":6619
 *             n+=self.loose.get_size(False)
 *             return n
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.ensure_compact()
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV3.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6626
 *             return iter([])
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_13get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_13get_type_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_type_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_type_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6626; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_type_counts", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6626; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_12get_type_counts(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *)__pyx_v_self), __pyx_v_k);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV3_12get_type_counts(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self, PyObject *__pyx_v_k) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type_counts", 0);

  /* "lurrn/sparsmat.pyx":6627
 * 
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)             # <<<<<<<<<<<<<<
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_type_counts); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_k);
    __Pyx_GIVEREF(__pyx_v_k);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6626
 *             return iter([])
 * 
 *     def get_type_counts(self, k=0):             # <<<<<<<<<<<<<<
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV3.get_type_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6628
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_15remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_15remap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_k = 0;
  PyObject *__pyx_v_filt = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_filt,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6628; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6628; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_k = values[0];
    __pyx_v_filt = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6628; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_14remap(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *)__pyx_v_self), __pyx_v_k, __pyx_v_filt);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV3_14remap(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self, PyObject *__pyx_v_k, PyObject *__pyx_v_filt) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remap", 0);

  /* "lurrn/sparsmat.pyx":6629
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):
 *         return self.get_compact().remap(k,filt)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_compact); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_remap); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (__pyx_t_2) {
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_v_k);
  PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_k);
  __Pyx_GIVEREF(__pyx_v_k);
  __Pyx_INCREF(__pyx_v_filt);
  PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_filt);
  __Pyx_GIVEREF(__pyx_v_filt);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lurrn/sparsmat.pyx":6628
 *     def get_type_counts(self, k=0):
 *         return self.get_compact().get_type_counts(k)
 *     def remap(self, k, filt):             # <<<<<<<<<<<<<<
 *         return self.get_compact().remap(k,filt)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV3.remap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6579
 * 
 * cdef class LargeVecV3:
 *     cdef public object compact             # <<<<<<<<<<<<<<
 *     cdef public VecV3 loose
 *     def __init__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_7compact_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_7compact_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_7compact___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV3_7compact___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->compact);
  __pyx_r = __pyx_v_self->compact;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV3_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV3_7compact_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_7compact_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_7compact_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV3_7compact_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV3_7compact_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_7compact_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_7compact_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->compact);
  __Pyx_DECREF(__pyx_v_self->compact);
  __pyx_v_self->compact = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6580
 * cdef class LargeVecV3:
 *     cdef public object compact
 *     cdef public VecV3 loose             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *         self.compact=[]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_5loose_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_5loose_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_5loose___get__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_10LargeVecV3_5loose___get__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->loose));
  __pyx_r = ((PyObject *)__pyx_v_self->loose);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV3_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV3_5loose_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_5loose_2__set__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_5loose_2__set__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5lurrn_8sparsmat_VecV3))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lurrn.sparsmat.LargeVecV3.loose.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV3_5loose_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5lurrn_8sparsmat_10LargeVecV3_5loose_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_5loose_4__del__(((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5lurrn_8sparsmat_10LargeVecV3_5loose_4__del__(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->loose);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->loose));
  __pyx_v_self->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lurrn/sparsmat.pyx":6633
 * 
 * 
 * def run_test():             # <<<<<<<<<<<<<<
 *     cdef VecI2 counts
 *     counts=VecI2()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5lurrn_8sparsmat_5run_test(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_5lurrn_8sparsmat_5run_test = {"run_test", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5run_test, METH_NOARGS, 0};
static PyObject *__pyx_pw_5lurrn_8sparsmat_5run_test(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("run_test (wrapper)", 0);
  __pyx_r = __pyx_pf_5lurrn_8sparsmat_4run_test(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5lurrn_8sparsmat_4run_test(CYTHON_UNUSED PyObject *__pyx_self) {
  struct __pyx_obj_5lurrn_8sparsmat_VecI2 *__pyx_v_counts = 0;
  PyObject *__pyx_v_xs = NULL;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_mat = 0;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *__pyx_v_mat2 = NULL;
  PyObject *__pyx_v_mat3 = NULL;
  PyObject *__pyx_v_mat4 = NULL;
  PyObject *__pyx_v_mat5 = NULL;
  PyObject *__pyx_v_mat6 = NULL;
  PyObject *__pyx_v_sv = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("run_test", 0);

  /* "lurrn/sparsmat.pyx":6635
 * def run_test():
 *     cdef VecI2 counts
 *     counts=VecI2()             # <<<<<<<<<<<<<<
 *     counts.c_add(0,1,12)
 *     counts.c_add(0,13,1312)
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_VecI2)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_counts = ((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6636
 *     cdef VecI2 counts
 *     counts=VecI2()
 *     counts.c_add(0,1,12)             # <<<<<<<<<<<<<<
 *     counts.c_add(0,13,1312)
 *     counts.c_add(1,0,8)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_counts->__pyx_vtab)->c_add(__pyx_v_counts, 0, 1, 12);

  /* "lurrn/sparsmat.pyx":6637
 *     counts=VecI2()
 *     counts.c_add(0,1,12)
 *     counts.c_add(0,13,1312)             # <<<<<<<<<<<<<<
 *     counts.c_add(1,0,8)
 *     counts.c_add(0,0,23)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_counts->__pyx_vtab)->c_add(__pyx_v_counts, 0, 13, 1312);

  /* "lurrn/sparsmat.pyx":6638
 *     counts.c_add(0,1,12)
 *     counts.c_add(0,13,1312)
 *     counts.c_add(1,0,8)             # <<<<<<<<<<<<<<
 *     counts.c_add(0,0,23)
 *     counts.c_add(0,1,12)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_counts->__pyx_vtab)->c_add(__pyx_v_counts, 1, 0, 8);

  /* "lurrn/sparsmat.pyx":6639
 *     counts.c_add(0,13,1312)
 *     counts.c_add(1,0,8)
 *     counts.c_add(0,0,23)             # <<<<<<<<<<<<<<
 *     counts.c_add(0,1,12)
 *     counts.c_add(1,0,8)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_counts->__pyx_vtab)->c_add(__pyx_v_counts, 0, 0, 23);

  /* "lurrn/sparsmat.pyx":6640
 *     counts.c_add(1,0,8)
 *     counts.c_add(0,0,23)
 *     counts.c_add(0,1,12)             # <<<<<<<<<<<<<<
 *     counts.c_add(1,0,8)
 *     for xs in counts.item_iter():
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_counts->__pyx_vtab)->c_add(__pyx_v_counts, 0, 1, 12);

  /* "lurrn/sparsmat.pyx":6641
 *     counts.c_add(0,0,23)
 *     counts.c_add(0,1,12)
 *     counts.c_add(1,0,8)             # <<<<<<<<<<<<<<
 *     for xs in counts.item_iter():
 *         print ' '.join([str(x) for x in xs])
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_counts->__pyx_vtab)->c_add(__pyx_v_counts, 1, 0, 8);

  /* "lurrn/sparsmat.pyx":6642
 *     counts.c_add(0,1,12)
 *     counts.c_add(1,0,8)
 *     for xs in counts.item_iter():             # <<<<<<<<<<<<<<
 *         print ' '.join([str(x) for x in xs])
 *     cdef CSRMatrixI mat
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_counts), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_xs, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":6643
 *     counts.c_add(1,0,8)
 *     for xs in counts.item_iter():
 *         print ' '.join([str(x) for x in xs])             # <<<<<<<<<<<<<<
 *     cdef CSRMatrixI mat
 *     mat=counts.to_csr()
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (likely(PyList_CheckExact(__pyx_v_xs)) || PyTuple_CheckExact(__pyx_v_xs)) {
      __pyx_t_3 = __pyx_v_xs; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_xs); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_7)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_8 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_8 = __pyx_t_7(__pyx_t_3);
        if (unlikely(!__pyx_t_8)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_8);
      }
      __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      __pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_9))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyString_Join(__pyx_kp_s__94, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__Pyx_PrintOne(0, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "lurrn/sparsmat.pyx":6642
 *     counts.c_add(0,1,12)
 *     counts.c_add(1,0,8)
 *     for xs in counts.item_iter():             # <<<<<<<<<<<<<<
 *         print ' '.join([str(x) for x in xs])
 *     cdef CSRMatrixI mat
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6645
 *         print ' '.join([str(x) for x in xs])
 *     cdef CSRMatrixI mat
 *     mat=counts.to_csr()             # <<<<<<<<<<<<<<
 *     mat.print_csr()
 *     print "mat[0,1]==%d"%(mat.get_count(0,1))
 */
  __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_counts->__pyx_vtab)->to_csr(__pyx_v_counts, 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_mat = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6646
 *     cdef CSRMatrixI mat
 *     mat=counts.to_csr()
 *     mat.print_csr()             # <<<<<<<<<<<<<<
 *     print "mat[0,1]==%d"%(mat.get_count(0,1))
 *     counts.clear()
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_mat), __pyx_n_s_print_csr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_1) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6647
 *     mat=counts.to_csr()
 *     mat.print_csr()
 *     print "mat[0,1]==%d"%(mat.get_count(0,1))             # <<<<<<<<<<<<<<
 *     counts.clear()
 *     counts.c_add(2,1,12)
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(((struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixI *)__pyx_v_mat->__pyx_vtab)->get_count(__pyx_v_mat, 0, 1, 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_mat_0_1_d, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_PrintOne(0, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "lurrn/sparsmat.pyx":6648
 *     mat.print_csr()
 *     print "mat[0,1]==%d"%(mat.get_count(0,1))
 *     counts.clear()             # <<<<<<<<<<<<<<
 *     counts.c_add(2,1,12)
 *     counts.c_add(1,13,1312)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_counts), __pyx_n_s_clear); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_1) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "lurrn/sparsmat.pyx":6649
 *     print "mat[0,1]==%d"%(mat.get_count(0,1))
 *     counts.clear()
 *     counts.c_add(2,1,12)             # <<<<<<<<<<<<<<
 *     counts.c_add(1,13,1312)
 *     counts.c_add(0,12,2412)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_counts->__pyx_vtab)->c_add(__pyx_v_counts, 2, 1, 12);

  /* "lurrn/sparsmat.pyx":6650
 *     counts.clear()
 *     counts.c_add(2,1,12)
 *     counts.c_add(1,13,1312)             # <<<<<<<<<<<<<<
 *     counts.c_add(0,12,2412)
 *     counts.c_add(1,0,8)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_counts->__pyx_vtab)->c_add(__pyx_v_counts, 1, 13, 1312);

  /* "lurrn/sparsmat.pyx":6651
 *     counts.c_add(2,1,12)
 *     counts.c_add(1,13,1312)
 *     counts.c_add(0,12,2412)             # <<<<<<<<<<<<<<
 *     counts.c_add(1,0,8)
 *     counts.c_add(0,2,23)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_counts->__pyx_vtab)->c_add(__pyx_v_counts, 0, 12, 2412);

  /* "lurrn/sparsmat.pyx":6652
 *     counts.c_add(1,13,1312)
 *     counts.c_add(0,12,2412)
 *     counts.c_add(1,0,8)             # <<<<<<<<<<<<<<
 *     counts.c_add(0,2,23)
 *     counts.c_add(0,1,12)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_counts->__pyx_vtab)->c_add(__pyx_v_counts, 1, 0, 8);

  /* "lurrn/sparsmat.pyx":6653
 *     counts.c_add(0,12,2412)
 *     counts.c_add(1,0,8)
 *     counts.c_add(0,2,23)             # <<<<<<<<<<<<<<
 *     counts.c_add(0,1,12)
 *     counts.c_add(1,0,8)
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_counts->__pyx_vtab)->c_add(__pyx_v_counts, 0, 2, 23);

  /* "lurrn/sparsmat.pyx":6654
 *     counts.c_add(1,0,8)
 *     counts.c_add(0,2,23)
 *     counts.c_add(0,1,12)             # <<<<<<<<<<<<<<
 *     counts.c_add(1,0,8)
 *     for xs in counts.item_iter():
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_counts->__pyx_vtab)->c_add(__pyx_v_counts, 0, 1, 12);

  /* "lurrn/sparsmat.pyx":6655
 *     counts.c_add(0,2,23)
 *     counts.c_add(0,1,12)
 *     counts.c_add(1,0,8)             # <<<<<<<<<<<<<<
 *     for xs in counts.item_iter():
 *         print ' '.join([str(x) for x in xs])
 */
  ((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_counts->__pyx_vtab)->c_add(__pyx_v_counts, 1, 0, 8);

  /* "lurrn/sparsmat.pyx":6656
 *     counts.c_add(0,1,12)
 *     counts.c_add(1,0,8)
 *     for xs in counts.item_iter():             # <<<<<<<<<<<<<<
 *         print ' '.join([str(x) for x in xs])
 *     mat2=counts.to_csr()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_counts), __pyx_n_s_item_iter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_1) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_xs, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "lurrn/sparsmat.pyx":6657
 *     counts.c_add(1,0,8)
 *     for xs in counts.item_iter():
 *         print ' '.join([str(x) for x in xs])             # <<<<<<<<<<<<<<
 *     mat2=counts.to_csr()
 *     mat2.print_csr()
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (likely(PyList_CheckExact(__pyx_v_xs)) || PyTuple_CheckExact(__pyx_v_xs)) {
      __pyx_t_1 = __pyx_v_xs; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_xs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_7)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_9); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_9); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_9 = __pyx_t_7(__pyx_t_1);
        if (unlikely(!__pyx_t_9)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_9);
      }
      __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_8))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__94, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__Pyx_PrintOne(0, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "lurrn/sparsmat.pyx":6656
 *     counts.c_add(0,1,12)
 *     counts.c_add(1,0,8)
 *     for xs in counts.item_iter():             # <<<<<<<<<<<<<<
 *         print ' '.join([str(x) for x in xs])
 *     mat2=counts.to_csr()
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6658
 *     for xs in counts.item_iter():
 *         print ' '.join([str(x) for x in xs])
 *     mat2=counts.to_csr()             # <<<<<<<<<<<<<<
 *     mat2.print_csr()
 *     mat3=mat+mat2
 */
  __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 *)__pyx_v_counts->__pyx_vtab)->to_csr(__pyx_v_counts, 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_mat2 = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6659
 *         print ' '.join([str(x) for x in xs])
 *     mat2=counts.to_csr()
 *     mat2.print_csr()             # <<<<<<<<<<<<<<
 *     mat3=mat+mat2
 *     mat3.print_csr()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_mat2), __pyx_n_s_print_csr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6660
 *     mat2=counts.to_csr()
 *     mat2.print_csr()
 *     mat3=mat+mat2             # <<<<<<<<<<<<<<
 *     mat3.print_csr()
 *     mat3.write_binary(file('/tmp/mat3','w'))
 */
  __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_v_mat), ((PyObject *)__pyx_v_mat2)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_mat3 = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6661
 *     mat2.print_csr()
 *     mat3=mat+mat2
 *     mat3.print_csr()             # <<<<<<<<<<<<<<
 *     mat3.write_binary(file('/tmp/mat3','w'))
 *     mat4=mmapCSR(file('/tmp/mat3'))
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_mat3, __pyx_n_s_print_csr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6662
 *     mat3=mat+mat2
 *     mat3.print_csr()
 *     mat3.write_binary(file('/tmp/mat3','w'))             # <<<<<<<<<<<<<<
 *     mat4=mmapCSR(file('/tmp/mat3'))
 *     mat4.print_csr()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_mat3, __pyx_n_s_write_binary); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_file, __pyx_tuple__95, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); __pyx_t_8 = NULL;
    PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6663
 *     mat3.print_csr()
 *     mat3.write_binary(file('/tmp/mat3','w'))
 *     mat4=mmapCSR(file('/tmp/mat3'))             # <<<<<<<<<<<<<<
 *     mat4.print_csr()
 *     mat4=None
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_mmapCSR); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_file, __pyx_tuple__96, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
    PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_mat4 = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6664
 *     mat3.write_binary(file('/tmp/mat3','w'))
 *     mat4=mmapCSR(file('/tmp/mat3'))
 *     mat4.print_csr()             # <<<<<<<<<<<<<<
 *     mat4=None
 *     mat5=mat3.transpose()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_mat4, __pyx_n_s_print_csr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_8) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6665
 *     mat4=mmapCSR(file('/tmp/mat3'))
 *     mat4.print_csr()
 *     mat4=None             # <<<<<<<<<<<<<<
 *     mat5=mat3.transpose()
 *     mat5.print_csr()
 */
  __Pyx_INCREF(Py_None);
  __Pyx_DECREF_SET(__pyx_v_mat4, Py_None);

  /* "lurrn/sparsmat.pyx":6666
 *     mat4.print_csr()
 *     mat4=None
 *     mat5=mat3.transpose()             # <<<<<<<<<<<<<<
 *     mat5.print_csr()
 *     mat6=mat5.transpose()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_mat3, __pyx_n_s_transpose); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_8) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_mat5 = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6667
 *     mat4=None
 *     mat5=mat3.transpose()
 *     mat5.print_csr()             # <<<<<<<<<<<<<<
 *     mat6=mat5.transpose()
 *     mat6.print_csr()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_mat5, __pyx_n_s_print_csr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_8) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6668
 *     mat5=mat3.transpose()
 *     mat5.print_csr()
 *     mat6=mat5.transpose()             # <<<<<<<<<<<<<<
 *     mat6.print_csr()
 *     for xs in mat6.item_iter():
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_mat5, __pyx_n_s_transpose); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_8) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_mat6 = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6669
 *     mat5.print_csr()
 *     mat6=mat5.transpose()
 *     mat6.print_csr()             # <<<<<<<<<<<<<<
 *     for xs in mat6.item_iter():
 *         print ' '.join([str(x) for x in xs])
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_mat6, __pyx_n_s_print_csr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_8) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lurrn/sparsmat.pyx":6670
 *     mat6=mat5.transpose()
 *     mat6.print_csr()
 *     for xs in mat6.item_iter():             # <<<<<<<<<<<<<<
 *         print ' '.join([str(x) for x in xs])
 *     for sv in mat6:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_mat6, __pyx_n_s_item_iter); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_8) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_xs, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "lurrn/sparsmat.pyx":6671
 *     mat6.print_csr()
 *     for xs in mat6.item_iter():
 *         print ' '.join([str(x) for x in xs])             # <<<<<<<<<<<<<<
 *     for sv in mat6:
 *         print sv
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_v_xs)) || PyTuple_CheckExact(__pyx_v_xs)) {
      __pyx_t_8 = __pyx_v_xs; __Pyx_INCREF(__pyx_t_8); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_xs); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_7 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_7)) {
        if (likely(PyList_CheckExact(__pyx_t_8))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_8)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_6); __Pyx_INCREF(__pyx_t_9); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_6); __Pyx_INCREF(__pyx_t_9); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_9 = __pyx_t_7(__pyx_t_8);
        if (unlikely(!__pyx_t_9)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_9);
      }
      __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_3))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyString_Join(__pyx_kp_s__94, __pyx_t_2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__Pyx_PrintOne(0, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "lurrn/sparsmat.pyx":6670
 *     mat6=mat5.transpose()
 *     mat6.print_csr()
 *     for xs in mat6.item_iter():             # <<<<<<<<<<<<<<
 *         print ' '.join([str(x) for x in xs])
 *     for sv in mat6:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6672
 *     for xs in mat6.item_iter():
 *         print ' '.join([str(x) for x in xs])
 *     for sv in mat6:             # <<<<<<<<<<<<<<
 *         print sv
 */
  if (likely(PyList_CheckExact(__pyx_v_mat6)) || PyTuple_CheckExact(__pyx_v_mat6)) {
    __pyx_t_1 = __pyx_v_mat6; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_mat6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_8 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_8); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_8); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_8 = __pyx_t_5(__pyx_t_1);
      if (unlikely(!__pyx_t_8)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_8);
    }
    __Pyx_XDECREF_SET(__pyx_v_sv, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "lurrn/sparsmat.pyx":6673
 *         print ' '.join([str(x) for x in xs])
 *     for sv in mat6:
 *         print sv             # <<<<<<<<<<<<<<
 */
    if (__Pyx_PrintOne(0, __pyx_v_sv) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lurrn/sparsmat.pyx":6672
 *     for xs in mat6.item_iter():
 *         print ' '.join([str(x) for x in xs])
 *     for sv in mat6:             # <<<<<<<<<<<<<<
 *         print sv
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6633
 * 
 * 
 * def run_test():             # <<<<<<<<<<<<<<
 *     cdef VecI2 counts
 *     counts=VecI2()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lurrn.sparsmat.run_test", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_counts);
  __Pyx_XDECREF(__pyx_v_xs);
  __Pyx_XDECREF((PyObject *)__pyx_v_mat);
  __Pyx_XDECREF((PyObject *)__pyx_v_mat2);
  __Pyx_XDECREF(__pyx_v_mat3);
  __Pyx_XDECREF(__pyx_v_mat4);
  __Pyx_XDECREF(__pyx_v_mat5);
  __Pyx_XDECREF(__pyx_v_mat6);
  __Pyx_XDECREF(__pyx_v_sv);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":194
 *         # experimental exception made for __getbuffer__ and __releasebuffer__
 *         # -- the details of this may change.
 *         def __getbuffer__(ndarray self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fullfill the PEP.
 */

/* Python wrapper */
static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_v_copy_shape;
  int __pyx_v_i;
  int __pyx_v_ndim;
  int __pyx_v_endian_detector;
  int __pyx_v_little_endian;
  int __pyx_v_t;
  char *__pyx_v_f;
  PyArray_Descr *__pyx_v_descr = 0;
  int __pyx_v_offset;
  int __pyx_v_hasfields;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  char *__pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getbuffer__", 0);
  if (__pyx_v_info != NULL) {
    __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(__pyx_v_info->obj);
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":200
 *             # of flags
 * 
 *             if info == NULL: return             # <<<<<<<<<<<<<<
 * 
 *             cdef int copy_shape, i, ndim
 */
  __pyx_t_1 = ((__pyx_v_info == NULL) != 0);
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":203
 * 
 *             cdef int copy_shape, i, ndim
 *             cdef int endian_detector = 1             # <<<<<<<<<<<<<<
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 * 
 */
  __pyx_v_endian_detector = 1;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":204
 *             cdef int copy_shape, i, ndim
 *             cdef int endian_detector = 1
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
 * 
 *             ndim = PyArray_NDIM(self)
 */
  __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":206
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 * 
 *             ndim = PyArray_NDIM(self)             # <<<<<<<<<<<<<<
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  __pyx_v_ndim = PyArray_NDIM(__pyx_v_self);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":208
 *             ndim = PyArray_NDIM(self)
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 copy_shape = 1
 *             else:
 */
  __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
  if (__pyx_t_1) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":209
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 copy_shape = 1             # <<<<<<<<<<<<<<
 *             else:
 *                 copy_shape = 0
 */
    __pyx_v_copy_shape = 1;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":211
 *                 copy_shape = 1
 *             else:
 *                 copy_shape = 0             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 */
    __pyx_v_copy_shape = 0;
  }
  __pyx_L4:;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":213
 *                 copy_shape = 0
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")
 */
  __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L6_bool_binop_done;
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":214
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):             # <<<<<<<<<<<<<<
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 */
  __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_1) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":215
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__97, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":217
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 */
  __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L9_bool_binop_done;
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":218
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):             # <<<<<<<<<<<<<<
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 * 
 */
  __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L9_bool_binop_done:;
  if (__pyx_t_1) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":219
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")             # <<<<<<<<<<<<<<
 * 
 *             info.buf = PyArray_DATA(self)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__98, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":221
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 * 
 *             info.buf = PyArray_DATA(self)             # <<<<<<<<<<<<<<
 *             info.ndim = ndim
 *             if copy_shape:
 */
  __pyx_v_info->buf = PyArray_DATA(__pyx_v_self);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":222
 * 
 *             info.buf = PyArray_DATA(self)
 *             info.ndim = ndim             # <<<<<<<<<<<<<<
 *             if copy_shape:
 *                 # Allocate new buffer for strides and shape info.
 */
  __pyx_v_info->ndim = __pyx_v_ndim;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":223
 *             info.buf = PyArray_DATA(self)
 *             info.ndim = ndim
 *             if copy_shape:             # <<<<<<<<<<<<<<
 *                 # Allocate new buffer for strides and shape info.
 *                 # This is allocated as one block, strides first.
 */
  __pyx_t_1 = (__pyx_v_copy_shape != 0);
  if (__pyx_t_1) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":226
 *                 # Allocate new buffer for strides and shape info.
 *                 # This is allocated as one block, strides first.
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)             # <<<<<<<<<<<<<<
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):
 */
    __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2)));

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":227
 *                 # This is allocated as one block, strides first.
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)
 *                 info.shape = info.strides + ndim             # <<<<<<<<<<<<<<
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 */
    __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim);

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":228
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):             # <<<<<<<<<<<<<<
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 */
    __pyx_t_4 = __pyx_v_ndim;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_v_i = __pyx_t_5;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":229
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]             # <<<<<<<<<<<<<<
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 *             else:
 */
      (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]);

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":230
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 *                     info.shape[i] = PyArray_DIMS(self)[i]             # <<<<<<<<<<<<<<
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 */
      (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]);
    }
    goto __pyx_L11;
  }
  /*else*/ {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":232
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)             # <<<<<<<<<<<<<<
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL
 */
    __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self));

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":233
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)             # <<<<<<<<<<<<<<
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)
 */
    __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self));
  }
  __pyx_L11:;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":234
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
 *             info.itemsize = PyArray_ITEMSIZE(self)
 *             info.readonly = not PyArray_ISWRITEABLE(self)
 */
  __pyx_v_info->suboffsets = NULL;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":235
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)             # <<<<<<<<<<<<<<
 *             info.readonly = not PyArray_ISWRITEABLE(self)
 * 
 */
  __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":236
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)
 *             info.readonly = not PyArray_ISWRITEABLE(self)             # <<<<<<<<<<<<<<
 * 
 *             cdef int t
 */
  __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0));

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":239
 * 
 *             cdef int t
 *             cdef char* f = NULL             # <<<<<<<<<<<<<<
 *             cdef dtype descr = self.descr
 *             cdef list stack
 */
  __pyx_v_f = NULL;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":240
 *             cdef int t
 *             cdef char* f = NULL
 *             cdef dtype descr = self.descr             # <<<<<<<<<<<<<<
 *             cdef list stack
 *             cdef int offset
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_self->descr);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":244
 *             cdef int offset
 * 
 *             cdef bint hasfields = PyDataType_HASFIELDS(descr)             # <<<<<<<<<<<<<<
 * 
 *             if not hasfields and not copy_shape:
 */
  __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":246
 *             cdef bint hasfields = PyDataType_HASFIELDS(descr)
 * 
 *             if not hasfields and not copy_shape:             # <<<<<<<<<<<<<<
 *                 # do not call releasebuffer
 *                 info.obj = None
 */
  __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L15_bool_binop_done;
  }
  __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L15_bool_binop_done:;
  if (__pyx_t_1) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":248
 *             if not hasfields and not copy_shape:
 *                 # do not call releasebuffer
 *                 info.obj = None             # <<<<<<<<<<<<<<
 *             else:
 *                 # need to call releasebuffer
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj);
    __pyx_v_info->obj = Py_None;
    goto __pyx_L14;
  }
  /*else*/ {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":251
 *             else:
 *                 # need to call releasebuffer
 *                 info.obj = self             # <<<<<<<<<<<<<<
 * 
 *             if not hasfields:
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj);
    __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
  }
  __pyx_L14:;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":253
 *                 info.obj = self
 * 
 *             if not hasfields:             # <<<<<<<<<<<<<<
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or
 */
  __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0);
  if (__pyx_t_1) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":254
 * 
 *             if not hasfields:
 *                 t = descr.type_num             # <<<<<<<<<<<<<<
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):
 */
    __pyx_t_4 = __pyx_v_descr->type_num;
    __pyx_v_t = __pyx_t_4;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":255
 *             if not hasfields:
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or             # <<<<<<<<<<<<<<
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 */
    __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0);
    if (!__pyx_t_2) {
      goto __pyx_L20_next_or;
    } else {
    }
    __pyx_t_2 = (__pyx_v_little_endian != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L19_bool_binop_done;
    }
    __pyx_L20_next_or:;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":256
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):             # <<<<<<<<<<<<<<
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"
 */
    __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L19_bool_binop_done;
    }
    __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L19_bool_binop_done:;
    if (__pyx_t_1) {

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":257
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__99, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":274
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 *                 elif t == NPY_OBJECT:      f = "O"             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 */
    switch (__pyx_v_t) {

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":258
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"
 */
      case NPY_BYTE:
      __pyx_v_f = __pyx_k_b;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":259
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"
 */
      case NPY_UBYTE:
      __pyx_v_f = __pyx_k_B;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":260
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"
 */
      case NPY_SHORT:
      __pyx_v_f = __pyx_k_h;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":261
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"
 */
      case NPY_USHORT:
      __pyx_v_f = __pyx_k_H;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":262
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"
 */
      case NPY_INT:
      __pyx_v_f = __pyx_k_i;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":263
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"
 */
      case NPY_UINT:
      __pyx_v_f = __pyx_k_I;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":264
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"
 */
      case NPY_LONG:
      __pyx_v_f = __pyx_k_l;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":265
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 */
      case NPY_ULONG:
      __pyx_v_f = __pyx_k_L;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":266
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"
 */
      case NPY_LONGLONG:
      __pyx_v_f = __pyx_k_q;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":267
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"
 */
      case NPY_ULONGLONG:
      __pyx_v_f = __pyx_k_Q;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":268
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 */
      case NPY_FLOAT:
      __pyx_v_f = __pyx_k_f;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":269
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 */
      case NPY_DOUBLE:
      __pyx_v_f = __pyx_k_d;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":270
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 */
      case NPY_LONGDOUBLE:
      __pyx_v_f = __pyx_k_g;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":271
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 */
      case NPY_CFLOAT:
      __pyx_v_f = __pyx_k_Zf;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":272
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 *                 elif t == NPY_OBJECT:      f = "O"
 */
      case NPY_CDOUBLE:
      __pyx_v_f = __pyx_k_Zd;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":273
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_OBJECT:      f = "O"
 *                 else:
 */
      case NPY_CLONGDOUBLE:
      __pyx_v_f = __pyx_k_Zg;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":274
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 *                 elif t == NPY_OBJECT:      f = "O"             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 */
      case NPY_OBJECT:
      __pyx_v_f = __pyx_k_O;
      break;
      default:

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":276
 *                 elif t == NPY_OBJECT:      f = "O"
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
 *                 info.format = f
 *                 return
 */
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      break;
    }

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":277
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *                 info.format = f             # <<<<<<<<<<<<<<
 *                 return
 *             else:
 */
    __pyx_v_info->format = __pyx_v_f;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":278
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *                 info.format = f
 *                 return             # <<<<<<<<<<<<<<
 *             else:
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 */
    __pyx_r = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":280
 *                 return
 *             else:
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)             # <<<<<<<<<<<<<<
 *                 info.format[0] = c'^' # Native data types, manual alignment
 *                 offset = 0
 */
    __pyx_v_info->format = ((char *)malloc(255));

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":281
 *             else:
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 *                 info.format[0] = c'^' # Native data types, manual alignment             # <<<<<<<<<<<<<<
 *                 offset = 0
 *                 f = _util_dtypestring(descr, info.format + 1,
 */
    (__pyx_v_info->format[0]) = '^';

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":282
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 *                 info.format[0] = c'^' # Native data types, manual alignment
 *                 offset = 0             # <<<<<<<<<<<<<<
 *                 f = _util_dtypestring(descr, info.format + 1,
 *                                       info.format + _buffer_format_string_len,
 */
    __pyx_v_offset = 0;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":283
 *                 info.format[0] = c'^' # Native data types, manual alignment
 *                 offset = 0
 *                 f = _util_dtypestring(descr, info.format + 1,             # <<<<<<<<<<<<<<
 *                                       info.format + _buffer_format_string_len,
 *                                       &offset)
 */
    __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_f = __pyx_t_7;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":286
 *                                       info.format + _buffer_format_string_len,
 *                                       &offset)
 *                 f[0] = c'\0' # Terminate format string             # <<<<<<<<<<<<<<
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 */
    (__pyx_v_f[0]) = '\x00';
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":194
 *         # experimental exception made for __getbuffer__ and __releasebuffer__
 *         # -- the details of this may change.
 *         def __getbuffer__(ndarray self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fullfill the PEP.
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) {
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL;
  }
  goto __pyx_L2;
  __pyx_L0:;
  if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) {
    __Pyx_GOTREF(Py_None);
    __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL;
  }
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_descr);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":288
 *                 f[0] = c'\0' # Terminate format string
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 */

/* Python wrapper */
static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/
static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0);
  __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__releasebuffer__", 0);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":289
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):             # <<<<<<<<<<<<<<
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0);
  if (__pyx_t_1) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":290
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)             # <<<<<<<<<<<<<<
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 stdlib.free(info.strides)
 */
    free(__pyx_v_info->format);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":291
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 stdlib.free(info.strides)
 *                 # info.shape was stored after info.strides in the same block
 */
  __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
  if (__pyx_t_1) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":292
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 stdlib.free(info.strides)             # <<<<<<<<<<<<<<
 *                 # info.shape was stored after info.strides in the same block
 * 
 */
    free(__pyx_v_info->strides);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":288
 *                 f[0] = c'\0' # Terminate format string
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":768
 * ctypedef npy_cdouble     complex_t
 * 
 * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":769
 * 
 * cdef inline object PyArray_MultiIterNew1(a):
 *     return PyArray_MultiIterNew(1, <void*>a)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":768
 * ctypedef npy_cdouble     complex_t
 * 
 * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":771
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":772
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":771
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":774
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":775
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":774
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":777
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":778
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":777
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":780
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":781
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)             # <<<<<<<<<<<<<<
 * 
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":780
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":783
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:             # <<<<<<<<<<<<<<
 *     # Recursive utility function used in __getbuffer__ to get format
 *     # string. The new location in the format string is returned.
 */

static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) {
  PyArray_Descr *__pyx_v_child = 0;
  int __pyx_v_endian_detector;
  int __pyx_v_little_endian;
  PyObject *__pyx_v_fields = 0;
  PyObject *__pyx_v_childname = NULL;
  PyObject *__pyx_v_new_offset = NULL;
  PyObject *__pyx_v_t = NULL;
  char *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  long __pyx_t_8;
  char *__pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_util_dtypestring", 0);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":790
 *     cdef int delta_offset
 *     cdef tuple i
 *     cdef int endian_detector = 1             # <<<<<<<<<<<<<<
 *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 *     cdef tuple fields
 */
  __pyx_v_endian_detector = 1;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":791
 *     cdef tuple i
 *     cdef int endian_detector = 1
 *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
 *     cdef tuple fields
 * 
 */
  __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":794
 *     cdef tuple fields
 * 
 *     for childname in descr.names:             # <<<<<<<<<<<<<<
 *         fields = descr.fields[childname]
 *         child, new_offset = fields
 */
  if (unlikely(__pyx_v_descr->names == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":795
 * 
 *     for childname in descr.names:
 *         fields = descr.fields[childname]             # <<<<<<<<<<<<<<
 *         child, new_offset = fields
 * 
 */
    __pyx_t_3 = PyObject_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":796
 *     for childname in descr.names:
 *         fields = descr.fields[childname]
 *         child, new_offset = fields             # <<<<<<<<<<<<<<
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:
 */
    if (likely(__pyx_v_fields != Py_None)) {
      PyObject* sequence = __pyx_v_fields;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      #endif
    } else {
      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3));
    __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":798
 *         child, new_offset = fields
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 */
    __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0);
    if (__pyx_t_6) {

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":799
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")             # <<<<<<<<<<<<<<
 * 
 *         if ((child.byteorder == c'>' and little_endian) or
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__100, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":801
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 *         if ((child.byteorder == c'>' and little_endian) or             # <<<<<<<<<<<<<<
 *             (child.byteorder == c'<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")
 */
    __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0);
    if (!__pyx_t_7) {
      goto __pyx_L8_next_or;
    } else {
    }
    __pyx_t_7 = (__pyx_v_little_endian != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_L8_next_or:;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":802
 * 
 *         if ((child.byteorder == c'>' and little_endian) or
 *             (child.byteorder == c'<' and not little_endian)):             # <<<<<<<<<<<<<<
 *             raise ValueError(u"Non-native byte order not supported")
 *             # One could encode it in the format string and have Cython
 */
    __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0);
    __pyx_t_6 = __pyx_t_7;
    __pyx_L7_bool_binop_done:;
    if (__pyx_t_6) {

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":803
 *         if ((child.byteorder == c'>' and little_endian) or
 *             (child.byteorder == c'<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *             # One could encode it in the format string and have Cython
 *             # complain instead, BUT: < and > in format strings also imply
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__101, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":813
 * 
 *         # Output padding bytes
 *         while offset[0] < new_offset:             # <<<<<<<<<<<<<<
 *             f[0] = 120 # "x"; pad byte
 *             f += 1
 */
    while (1) {
      __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!__pyx_t_6) break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":814
 *         # Output padding bytes
 *         while offset[0] < new_offset:
 *             f[0] = 120 # "x"; pad byte             # <<<<<<<<<<<<<<
 *             f += 1
 *             offset[0] += 1
 */
      (__pyx_v_f[0]) = 120;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":815
 *         while offset[0] < new_offset:
 *             f[0] = 120 # "x"; pad byte
 *             f += 1             # <<<<<<<<<<<<<<
 *             offset[0] += 1
 * 
 */
      __pyx_v_f = (__pyx_v_f + 1);

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":816
 *             f[0] = 120 # "x"; pad byte
 *             f += 1
 *             offset[0] += 1             # <<<<<<<<<<<<<<
 * 
 *         offset[0] += child.itemsize
 */
      __pyx_t_8 = 0;
      (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1);
    }

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":818
 *             offset[0] += 1
 * 
 *         offset[0] += child.itemsize             # <<<<<<<<<<<<<<
 * 
 *         if not PyDataType_HASFIELDS(child):
 */
    __pyx_t_8 = 0;
    (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize);

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":820
 *         offset[0] += child.itemsize
 * 
 *         if not PyDataType_HASFIELDS(child):             # <<<<<<<<<<<<<<
 *             t = child.type_num
 *             if end - f < 5:
 */
    __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0);
    if (__pyx_t_6) {

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":821
 * 
 *         if not PyDataType_HASFIELDS(child):
 *             t = child.type_num             # <<<<<<<<<<<<<<
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")
 */
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":822
 *         if not PyDataType_HASFIELDS(child):
 *             t = child.type_num
 *             if end - f < 5:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(u"Format string allocated too short.")
 * 
 */
      __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0);
      if (__pyx_t_6) {

        /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":823
 *             t = child.type_num
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")             # <<<<<<<<<<<<<<
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 */
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__102, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":826
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"             # <<<<<<<<<<<<<<
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 */
      __pyx_t_4 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 98;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":827
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"             # <<<<<<<<<<<<<<
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 66;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":828
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"             # <<<<<<<<<<<<<<
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 */
      __pyx_t_4 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 104;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":829
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"             # <<<<<<<<<<<<<<
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 72;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":830
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"             # <<<<<<<<<<<<<<
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 */
      __pyx_t_4 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 105;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":831
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 73;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":832
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"             # <<<<<<<<<<<<<<
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 */
      __pyx_t_4 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 108;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":833
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 76;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":834
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"             # <<<<<<<<<<<<<<
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 */
      __pyx_t_4 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 113;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":835
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"             # <<<<<<<<<<<<<<
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 81;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":836
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"             # <<<<<<<<<<<<<<
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 */
      __pyx_t_4 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 102;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":837
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 */
      __pyx_t_3 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 100;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":838
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"             # <<<<<<<<<<<<<<
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 */
      __pyx_t_4 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 103;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":839
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf             # <<<<<<<<<<<<<<
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 */
      __pyx_t_3 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 102;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":840
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd             # <<<<<<<<<<<<<<
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 */
      __pyx_t_4 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 100;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":841
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg             # <<<<<<<<<<<<<<
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 *             else:
 */
      __pyx_t_3 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 103;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":842
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 */
      __pyx_t_4 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 79;
        goto __pyx_L15;
      }
      /*else*/ {

        /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":844
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
 *             f += 1
 *         else:
 */
        __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L15:;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":845
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *             f += 1             # <<<<<<<<<<<<<<
 *         else:
 *             # Cython ignores struct boundary information ("T{...}"),
 */
      __pyx_v_f = (__pyx_v_f + 1);
      goto __pyx_L13;
    }
    /*else*/ {

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":849
 *             # Cython ignores struct boundary information ("T{...}"),
 *             # so don't output it
 *             f = _util_dtypestring(child, f, end, offset)             # <<<<<<<<<<<<<<
 *     return f
 * 
 */
      __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_f = __pyx_t_9;
    }
    __pyx_L13:;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":794
 *     cdef tuple fields
 * 
 *     for childname in descr.names:             # <<<<<<<<<<<<<<
 *         fields = descr.fields[childname]
 *         child, new_offset = fields
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":850
 *             # so don't output it
 *             f = _util_dtypestring(child, f, end, offset)
 *     return f             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_f;
  goto __pyx_L0;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":783
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:             # <<<<<<<<<<<<<<
 *     # Recursive utility function used in __getbuffer__ to get format
 *     # string. The new location in the format string is returned.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_child);
  __Pyx_XDECREF(__pyx_v_fields);
  __Pyx_XDECREF(__pyx_v_childname);
  __Pyx_XDECREF(__pyx_v_new_offset);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":966
 * 
 * 
 * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
 *      cdef PyObject* baseptr
 *      if base is None:
 */

static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
  PyObject *__pyx_v_baseptr;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("set_array_base", 0);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":968
 * cdef inline void set_array_base(ndarray arr, object base):
 *      cdef PyObject* baseptr
 *      if base is None:             # <<<<<<<<<<<<<<
 *          baseptr = NULL
 *      else:
 */
  __pyx_t_1 = (__pyx_v_base == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":969
 *      cdef PyObject* baseptr
 *      if base is None:
 *          baseptr = NULL             # <<<<<<<<<<<<<<
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!
 */
    __pyx_v_baseptr = NULL;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":971
 *          baseptr = NULL
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!             # <<<<<<<<<<<<<<
 *          baseptr = <PyObject*>base
 *      Py_XDECREF(arr.base)
 */
    Py_INCREF(__pyx_v_base);

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":972
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!
 *          baseptr = <PyObject*>base             # <<<<<<<<<<<<<<
 *      Py_XDECREF(arr.base)
 *      arr.base = baseptr
 */
    __pyx_v_baseptr = ((PyObject *)__pyx_v_base);
  }
  __pyx_L3:;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":973
 *          Py_INCREF(base) # important to do this before decref below!
 *          baseptr = <PyObject*>base
 *      Py_XDECREF(arr.base)             # <<<<<<<<<<<<<<
 *      arr.base = baseptr
 * 
 */
  Py_XDECREF(__pyx_v_arr->base);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":974
 *          baseptr = <PyObject*>base
 *      Py_XDECREF(arr.base)
 *      arr.base = baseptr             # <<<<<<<<<<<<<<
 * 
 * cdef inline object get_array_base(ndarray arr):
 */
  __pyx_v_arr->base = __pyx_v_baseptr;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":966
 * 
 * 
 * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
 *      cdef PyObject* baseptr
 *      if base is None:
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":976
 *      arr.base = baseptr
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     if arr.base is NULL:
 *         return None
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("get_array_base", 0);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":977
 * 
 * cdef inline object get_array_base(ndarray arr):
 *     if arr.base is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0);
  if (__pyx_t_1) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":978
 * cdef inline object get_array_base(ndarray arr):
 *     if arr.base is NULL:
 *         return None             # <<<<<<<<<<<<<<
 *     else:
 *         return <object>arr.base
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":980
 *         return None
 *     else:
 *         return <object>arr.base             # <<<<<<<<<<<<<<
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_arr->base));
    __pyx_r = ((PyObject *)__pyx_v_arr->base);
    goto __pyx_L0;
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":976
 *      arr.base = baseptr
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     if arr.base is NULL:
 *         return None
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":116
 *         cdef bint dtype_is_object
 * 
 *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
 *                   mode="c", bint allocate_buffer=True):
 * 
 */

/* Python wrapper */
static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_shape = 0;
  Py_ssize_t __pyx_v_itemsize;
  PyObject *__pyx_v_format = 0;
  PyObject *__pyx_v_mode = 0;
  int __pyx_v_allocate_buffer;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,&__pyx_n_s_itemsize,&__pyx_n_s_format,&__pyx_n_s_mode,&__pyx_n_s_allocate_buffer,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[3] = ((PyObject *)__pyx_n_s_c);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_itemsize)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mode);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_allocate_buffer);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_shape = ((PyObject*)values[0]);
    __pyx_v_itemsize = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_itemsize == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_format = values[2];
    __pyx_v_mode = values[3];
    if (values[4]) {
      __pyx_v_allocate_buffer = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_allocate_buffer == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {

      /* "View.MemoryView":117
 * 
 *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,
 *                   mode="c", bint allocate_buffer=True):             # <<<<<<<<<<<<<<
 * 
 *         cdef int idx
 */
      __pyx_v_allocate_buffer = ((int)1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(((PyObject *)__pyx_v_format) == Py_None)) {
    PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "format"); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_r = __pyx_array_MemoryView_5array___cinit__(((struct __pyx_array_obj *)__pyx_v_self), __pyx_v_shape, __pyx_v_itemsize, __pyx_v_format, __pyx_v_mode, __pyx_v_allocate_buffer);

  /* "View.MemoryView":116
 *         cdef bint dtype_is_object
 * 
 *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
 *                   mode="c", bint allocate_buffer=True):
 * 
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_array_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer) {
  int __pyx_v_idx;
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_dim;
  PyObject **__pyx_v_p;
  char __pyx_v_order;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  char *__pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);
  __Pyx_INCREF(__pyx_v_format);

  /* "View.MemoryView":123
 *         cdef PyObject **p
 * 
 *         self.ndim = <int> len(shape)             # <<<<<<<<<<<<<<
 *         self.itemsize = itemsize
 * 
 */
  if (unlikely(__pyx_v_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->ndim = ((int)__pyx_t_1);

  /* "View.MemoryView":124
 * 
 *         self.ndim = <int> len(shape)
 *         self.itemsize = itemsize             # <<<<<<<<<<<<<<
 * 
 *         if not self.ndim:
 */
  __pyx_v_self->itemsize = __pyx_v_itemsize;

  /* "View.MemoryView":126
 *         self.itemsize = itemsize
 * 
 *         if not self.ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError("Empty shape tuple for cython.array")
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_self->ndim != 0)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":127
 * 
 *         if not self.ndim:
 *             raise ValueError("Empty shape tuple for cython.array")             # <<<<<<<<<<<<<<
 * 
 *         if itemsize <= 0:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__103, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "View.MemoryView":129
 *             raise ValueError("Empty shape tuple for cython.array")
 * 
 *         if itemsize <= 0:             # <<<<<<<<<<<<<<
 *             raise ValueError("itemsize <= 0 for cython.array")
 * 
 */
  __pyx_t_2 = ((__pyx_v_itemsize <= 0) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":130
 * 
 *         if itemsize <= 0:
 *             raise ValueError("itemsize <= 0 for cython.array")             # <<<<<<<<<<<<<<
 * 
 *         if isinstance(format, unicode):
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__104, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "View.MemoryView":132
 *             raise ValueError("itemsize <= 0 for cython.array")
 * 
 *         if isinstance(format, unicode):             # <<<<<<<<<<<<<<
 *             format = (<unicode>format).encode('ASCII')
 *         self._format = format  # keep a reference to the byte string
 */
  __pyx_t_2 = PyUnicode_Check(__pyx_v_format); 
  __pyx_t_4 = (__pyx_t_2 != 0);
  if (__pyx_t_4) {

    /* "View.MemoryView":133
 * 
 *         if isinstance(format, unicode):
 *             format = (<unicode>format).encode('ASCII')             # <<<<<<<<<<<<<<
 *         self._format = format  # keep a reference to the byte string
 *         self.format = self._format
 */
    if (unlikely(__pyx_v_format == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "encode");
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_3 = PyUnicode_AsASCIIString(((PyObject*)__pyx_v_format)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "View.MemoryView":134
 *         if isinstance(format, unicode):
 *             format = (<unicode>format).encode('ASCII')
 *         self._format = format  # keep a reference to the byte string             # <<<<<<<<<<<<<<
 *         self.format = self._format
 * 
 */
  if (!(likely(PyBytes_CheckExact(__pyx_v_format))||((__pyx_v_format) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_format)->tp_name), 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __pyx_v_format;
  __Pyx_INCREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->_format);
  __Pyx_DECREF(__pyx_v_self->_format);
  __pyx_v_self->_format = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "View.MemoryView":135
 *             format = (<unicode>format).encode('ASCII')
 *         self._format = format  # keep a reference to the byte string
 *         self.format = self._format             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_AsString(__pyx_v_self->_format); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->format = __pyx_t_5;

  /* "View.MemoryView":138
 * 
 * 
 *         self._shape = <Py_ssize_t *> PyMem_Malloc(sizeof(Py_ssize_t)*self.ndim*2)             # <<<<<<<<<<<<<<
 *         self._strides = self._shape + self.ndim
 * 
 */
  __pyx_v_self->_shape = ((Py_ssize_t *)PyMem_Malloc((((sizeof(Py_ssize_t)) * __pyx_v_self->ndim) * 2)));

  /* "View.MemoryView":139
 * 
 *         self._shape = <Py_ssize_t *> PyMem_Malloc(sizeof(Py_ssize_t)*self.ndim*2)
 *         self._strides = self._shape + self.ndim             # <<<<<<<<<<<<<<
 * 
 *         if not self._shape:
 */
  __pyx_v_self->_strides = (__pyx_v_self->_shape + __pyx_v_self->ndim);

  /* "View.MemoryView":141
 *         self._strides = self._shape + self.ndim
 * 
 *         if not self._shape:             # <<<<<<<<<<<<<<
 *             raise MemoryError("unable to allocate shape and strides.")
 * 
 */
  __pyx_t_4 = ((!(__pyx_v_self->_shape != 0)) != 0);
  if (__pyx_t_4) {

    /* "View.MemoryView":142
 * 
 *         if not self._shape:
 *             raise MemoryError("unable to allocate shape and strides.")             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__105, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "View.MemoryView":145
 * 
 * 
 *         for idx, dim in enumerate(shape):             # <<<<<<<<<<<<<<
 *             if dim <= 0:
 *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
 */
  __pyx_t_6 = 0;
  __pyx_t_3 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_7); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_7 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_dim = __pyx_t_8;
    __pyx_v_idx = __pyx_t_6;
    __pyx_t_6 = (__pyx_t_6 + 1);

    /* "View.MemoryView":146
 * 
 *         for idx, dim in enumerate(shape):
 *             if dim <= 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
 *             self._shape[idx] = dim
 */
    __pyx_t_4 = ((__pyx_v_dim <= 0) != 0);
    if (__pyx_t_4) {

      /* "View.MemoryView":147
 *         for idx, dim in enumerate(shape):
 *             if dim <= 0:
 *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))             # <<<<<<<<<<<<<<
 *             self._shape[idx] = dim
 * 
 */
      __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_9);
      __pyx_t_7 = 0;
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_t_10); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "View.MemoryView":148
 *             if dim <= 0:
 *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
 *             self._shape[idx] = dim             # <<<<<<<<<<<<<<
 * 
 *         cdef char order
 */
    (__pyx_v_self->_shape[__pyx_v_idx]) = __pyx_v_dim;

    /* "View.MemoryView":145
 * 
 * 
 *         for idx, dim in enumerate(shape):             # <<<<<<<<<<<<<<
 *             if dim <= 0:
 *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "View.MemoryView":151
 * 
 *         cdef char order
 *         if mode == 'fortran':             # <<<<<<<<<<<<<<
 *             order = b'F'
 *             self.mode = u'fortran'
 */
  __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_fortran, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_4) {

    /* "View.MemoryView":152
 *         cdef char order
 *         if mode == 'fortran':
 *             order = b'F'             # <<<<<<<<<<<<<<
 *             self.mode = u'fortran'
 *         elif mode == 'c':
 */
    __pyx_v_order = 'F';

    /* "View.MemoryView":153
 *         if mode == 'fortran':
 *             order = b'F'
 *             self.mode = u'fortran'             # <<<<<<<<<<<<<<
 *         elif mode == 'c':
 *             order = b'C'
 */
    __Pyx_INCREF(__pyx_n_u_fortran);
    __Pyx_GIVEREF(__pyx_n_u_fortran);
    __Pyx_GOTREF(__pyx_v_self->mode);
    __Pyx_DECREF(__pyx_v_self->mode);
    __pyx_v_self->mode = __pyx_n_u_fortran;
    goto __pyx_L10;
  }

  /* "View.MemoryView":154
 *             order = b'F'
 *             self.mode = u'fortran'
 *         elif mode == 'c':             # <<<<<<<<<<<<<<
 *             order = b'C'
 *             self.mode = u'c'
 */
  __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_4) {

    /* "View.MemoryView":155
 *             self.mode = u'fortran'
 *         elif mode == 'c':
 *             order = b'C'             # <<<<<<<<<<<<<<
 *             self.mode = u'c'
 *         else:
 */
    __pyx_v_order = 'C';

    /* "View.MemoryView":156
 *         elif mode == 'c':
 *             order = b'C'
 *             self.mode = u'c'             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
 */
    __Pyx_INCREF(__pyx_n_u_c);
    __Pyx_GIVEREF(__pyx_n_u_c);
    __Pyx_GOTREF(__pyx_v_self->mode);
    __Pyx_DECREF(__pyx_v_self->mode);
    __pyx_v_self->mode = __pyx_n_u_c;
    goto __pyx_L10;
  }
  /*else*/ {

    /* "View.MemoryView":158
 *             self.mode = u'c'
 *         else:
 *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)             # <<<<<<<<<<<<<<
 * 
 *         self.len = fill_contig_strides_array(self._shape, self._strides,
 */
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_v_mode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L10:;

  /* "View.MemoryView":160
 *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
 * 
 *         self.len = fill_contig_strides_array(self._shape, self._strides,             # <<<<<<<<<<<<<<
 *                                              itemsize, self.ndim, order)
 * 
 */
  __pyx_v_self->len = __pyx_fill_contig_strides_array(__pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_itemsize, __pyx_v_self->ndim, __pyx_v_order);

  /* "View.MemoryView":163
 *                                              itemsize, self.ndim, order)
 * 
 *         self.free_data = allocate_buffer             # <<<<<<<<<<<<<<
 *         self.dtype_is_object = format == b'O'
 *         if allocate_buffer:
 */
  __pyx_v_self->free_data = __pyx_v_allocate_buffer;

  /* "View.MemoryView":164
 * 
 *         self.free_data = allocate_buffer
 *         self.dtype_is_object = format == b'O'             # <<<<<<<<<<<<<<
 *         if allocate_buffer:
 * 
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_format, __pyx_n_b_O, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_self->dtype_is_object = __pyx_t_4;

  /* "View.MemoryView":165
 *         self.free_data = allocate_buffer
 *         self.dtype_is_object = format == b'O'
 *         if allocate_buffer:             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = (__pyx_v_allocate_buffer != 0);
  if (__pyx_t_4) {

    /* "View.MemoryView":168
 * 
 * 
 *             self.data = <char *>malloc(self.len)             # <<<<<<<<<<<<<<
 *             if not self.data:
 *                 raise MemoryError("unable to allocate array data.")
 */
    __pyx_v_self->data = ((char *)malloc(__pyx_v_self->len));

    /* "View.MemoryView":169
 * 
 *             self.data = <char *>malloc(self.len)
 *             if not self.data:             # <<<<<<<<<<<<<<
 *                 raise MemoryError("unable to allocate array data.")
 * 
 */
    __pyx_t_4 = ((!(__pyx_v_self->data != 0)) != 0);
    if (__pyx_t_4) {

      /* "View.MemoryView":170
 *             self.data = <char *>malloc(self.len)
 *             if not self.data:
 *                 raise MemoryError("unable to allocate array data.")             # <<<<<<<<<<<<<<
 * 
 *             if self.dtype_is_object:
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__106, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "View.MemoryView":172
 *                 raise MemoryError("unable to allocate array data.")
 * 
 *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
 *                 p = <PyObject **> self.data
 *                 for i in range(self.len / itemsize):
 */
    __pyx_t_4 = (__pyx_v_self->dtype_is_object != 0);
    if (__pyx_t_4) {

      /* "View.MemoryView":173
 * 
 *             if self.dtype_is_object:
 *                 p = <PyObject **> self.data             # <<<<<<<<<<<<<<
 *                 for i in range(self.len / itemsize):
 *                     p[i] = Py_None
 */
      __pyx_v_p = ((PyObject **)__pyx_v_self->data);

      /* "View.MemoryView":174
 *             if self.dtype_is_object:
 *                 p = <PyObject **> self.data
 *                 for i in range(self.len / itemsize):             # <<<<<<<<<<<<<<
 *                     p[i] = Py_None
 *                     Py_INCREF(Py_None)
 */
      if (unlikely(__pyx_v_itemsize == 0)) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
        #ifdef WITH_THREAD
        PyGILState_Release(__pyx_gilstate_save);
        #endif
        {__pyx_filename = __pyx_f[2]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      else if (sizeof(Py_ssize_t) == sizeof(long) && unlikely(__pyx_v_itemsize == -1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_self->len))) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
        #ifdef WITH_THREAD
        PyGILState_Release(__pyx_gilstate_save);
        #endif
        {__pyx_filename = __pyx_f[2]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_1 = __Pyx_div_Py_ssize_t(__pyx_v_self->len, __pyx_v_itemsize);
      for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_1; __pyx_t_8+=1) {
        __pyx_v_i = __pyx_t_8;

        /* "View.MemoryView":175
 *                 p = <PyObject **> self.data
 *                 for i in range(self.len / itemsize):
 *                     p[i] = Py_None             # <<<<<<<<<<<<<<
 *                     Py_INCREF(Py_None)
 * 
 */
        (__pyx_v_p[__pyx_v_i]) = Py_None;

        /* "View.MemoryView":176
 *                 for i in range(self.len / itemsize):
 *                     p[i] = Py_None
 *                     Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
 * 
 *     @cname('getbuffer')
 */
        Py_INCREF(Py_None);
      }
      goto __pyx_L13;
    }
    __pyx_L13:;
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "View.MemoryView":116
 *         cdef bint dtype_is_object
 * 
 *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
 *                   mode="c", bint allocate_buffer=True):
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_format);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":179
 * 
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
 *         cdef int bufmode = -1
 *         if self.mode == u"c":
 */

/* Python wrapper */
static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
  __pyx_r = __pyx_array_getbuffer_MemoryView_5array_2__getbuffer__(((struct __pyx_array_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_array_getbuffer_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_v_bufmode;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  char *__pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t *__pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getbuffer__", 0);
  if (__pyx_v_info != NULL) {
    __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(__pyx_v_info->obj);
  }

  /* "View.MemoryView":180
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):
 *         cdef int bufmode = -1             # <<<<<<<<<<<<<<
 *         if self.mode == u"c":
 *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 */
  __pyx_v_bufmode = -1;

  /* "View.MemoryView":181
 *     def __getbuffer__(self, Py_buffer *info, int flags):
 *         cdef int bufmode = -1
 *         if self.mode == u"c":             # <<<<<<<<<<<<<<
 *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         elif self.mode == u"fortran":
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":182
 *         cdef int bufmode = -1
 *         if self.mode == u"c":
 *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS             # <<<<<<<<<<<<<<
 *         elif self.mode == u"fortran":
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 */
    __pyx_v_bufmode = (PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);
    goto __pyx_L3;
  }

  /* "View.MemoryView":183
 *         if self.mode == u"c":
 *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         elif self.mode == u"fortran":             # <<<<<<<<<<<<<<
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         if not (flags & bufmode):
 */
  __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_fortran, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":184
 *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         elif self.mode == u"fortran":
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS             # <<<<<<<<<<<<<<
 *         if not (flags & bufmode):
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")
 */
    __pyx_v_bufmode = (PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "View.MemoryView":185
 *         elif self.mode == u"fortran":
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         if not (flags & bufmode):             # <<<<<<<<<<<<<<
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")
 *         info.buf = self.data
 */
  __pyx_t_1 = ((!((__pyx_v_flags & __pyx_v_bufmode) != 0)) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":186
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         if not (flags & bufmode):
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")             # <<<<<<<<<<<<<<
 *         info.buf = self.data
 *         info.len = self.len
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__107, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "View.MemoryView":187
 *         if not (flags & bufmode):
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")
 *         info.buf = self.data             # <<<<<<<<<<<<<<
 *         info.len = self.len
 *         info.ndim = self.ndim
 */
  __pyx_t_4 = __pyx_v_self->data;
  __pyx_v_info->buf = __pyx_t_4;

  /* "View.MemoryView":188
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")
 *         info.buf = self.data
 *         info.len = self.len             # <<<<<<<<<<<<<<
 *         info.ndim = self.ndim
 *         info.shape = self._shape
 */
  __pyx_t_5 = __pyx_v_self->len;
  __pyx_v_info->len = __pyx_t_5;

  /* "View.MemoryView":189
 *         info.buf = self.data
 *         info.len = self.len
 *         info.ndim = self.ndim             # <<<<<<<<<<<<<<
 *         info.shape = self._shape
 *         info.strides = self._strides
 */
  __pyx_t_6 = __pyx_v_self->ndim;
  __pyx_v_info->ndim = __pyx_t_6;

  /* "View.MemoryView":190
 *         info.len = self.len
 *         info.ndim = self.ndim
 *         info.shape = self._shape             # <<<<<<<<<<<<<<
 *         info.strides = self._strides
 *         info.suboffsets = NULL
 */
  __pyx_t_7 = __pyx_v_self->_shape;
  __pyx_v_info->shape = __pyx_t_7;

  /* "View.MemoryView":191
 *         info.ndim = self.ndim
 *         info.shape = self._shape
 *         info.strides = self._strides             # <<<<<<<<<<<<<<
 *         info.suboffsets = NULL
 *         info.itemsize = self.itemsize
 */
  __pyx_t_7 = __pyx_v_self->_strides;
  __pyx_v_info->strides = __pyx_t_7;

  /* "View.MemoryView":192
 *         info.shape = self._shape
 *         info.strides = self._strides
 *         info.suboffsets = NULL             # <<<<<<<<<<<<<<
 *         info.itemsize = self.itemsize
 *         info.readonly = 0
 */
  __pyx_v_info->suboffsets = NULL;

  /* "View.MemoryView":193
 *         info.strides = self._strides
 *         info.suboffsets = NULL
 *         info.itemsize = self.itemsize             # <<<<<<<<<<<<<<
 *         info.readonly = 0
 * 
 */
  __pyx_t_5 = __pyx_v_self->itemsize;
  __pyx_v_info->itemsize = __pyx_t_5;

  /* "View.MemoryView":194
 *         info.suboffsets = NULL
 *         info.itemsize = self.itemsize
 *         info.readonly = 0             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_FORMAT:
 */
  __pyx_v_info->readonly = 0;

  /* "View.MemoryView":196
 *         info.readonly = 0
 * 
 *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
 *             info.format = self.format
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":197
 * 
 *         if flags & PyBUF_FORMAT:
 *             info.format = self.format             # <<<<<<<<<<<<<<
 *         else:
 *             info.format = NULL
 */
    __pyx_t_4 = __pyx_v_self->format;
    __pyx_v_info->format = __pyx_t_4;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "View.MemoryView":199
 *             info.format = self.format
 *         else:
 *             info.format = NULL             # <<<<<<<<<<<<<<
 * 
 *         info.obj = self
 */
    __pyx_v_info->format = NULL;
  }
  __pyx_L5:;

  /* "View.MemoryView":201
 *             info.format = NULL
 * 
 *         info.obj = self             # <<<<<<<<<<<<<<
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __Pyx_GOTREF(__pyx_v_info->obj);
  __Pyx_DECREF(__pyx_v_info->obj);
  __pyx_v_info->obj = ((PyObject *)__pyx_v_self);

  /* "View.MemoryView":179
 * 
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
 *         cdef int bufmode = -1
 *         if self.mode == u"c":
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.array.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) {
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL;
  }
  goto __pyx_L2;
  __pyx_L0:;
  if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) {
    __Pyx_GOTREF(Py_None);
    __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL;
  }
  __pyx_L2:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":205
 *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
 * 
 *     def __dealloc__(array self):             # <<<<<<<<<<<<<<
 *         if self.callback_free_data != NULL:
 *             self.callback_free_data(self.data)
 */

/* Python wrapper */
static void __pyx_array___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_array___dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_array_MemoryView_5array_4__dealloc__(((struct __pyx_array_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_array_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "View.MemoryView":206
 * 
 *     def __dealloc__(array self):
 *         if self.callback_free_data != NULL:             # <<<<<<<<<<<<<<
 *             self.callback_free_data(self.data)
 *         elif self.free_data:
 */
  __pyx_t_1 = ((__pyx_v_self->callback_free_data != NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":207
 *     def __dealloc__(array self):
 *         if self.callback_free_data != NULL:
 *             self.callback_free_data(self.data)             # <<<<<<<<<<<<<<
 *         elif self.free_data:
 *             if self.dtype_is_object:
 */
    __pyx_v_self->callback_free_data(__pyx_v_self->data);
    goto __pyx_L3;
  }

  /* "View.MemoryView":208
 *         if self.callback_free_data != NULL:
 *             self.callback_free_data(self.data)
 *         elif self.free_data:             # <<<<<<<<<<<<<<
 *             if self.dtype_is_object:
 *                 refcount_objects_in_slice(self.data, self._shape,
 */
  __pyx_t_1 = (__pyx_v_self->free_data != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":209
 *             self.callback_free_data(self.data)
 *         elif self.free_data:
 *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
 *                 refcount_objects_in_slice(self.data, self._shape,
 *                                           self._strides, self.ndim, False)
 */
    __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":210
 *         elif self.free_data:
 *             if self.dtype_is_object:
 *                 refcount_objects_in_slice(self.data, self._shape,             # <<<<<<<<<<<<<<
 *                                           self._strides, self.ndim, False)
 *             free(self.data)
 */
      __pyx_memoryview_refcount_objects_in_slice(__pyx_v_self->data, __pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_self->ndim, 0);
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "View.MemoryView":212
 *                 refcount_objects_in_slice(self.data, self._shape,
 *                                           self._strides, self.ndim, False)
 *             free(self.data)             # <<<<<<<<<<<<<<
 *         PyMem_Free(self._shape)
 * 
 */
    free(__pyx_v_self->data);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "View.MemoryView":213
 *                                           self._strides, self.ndim, False)
 *             free(self.data)
 *         PyMem_Free(self._shape)             # <<<<<<<<<<<<<<
 * 
 *     property memview:
 */
  PyMem_Free(__pyx_v_self->_shape);

  /* "View.MemoryView":205
 *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
 * 
 *     def __dealloc__(array self):             # <<<<<<<<<<<<<<
 *         if self.callback_free_data != NULL:
 *             self.callback_free_data(self.data)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "View.MemoryView":217
 *     property memview:
 *         @cname('get_memview')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 * 
 *             flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
 */

/* Python wrapper */
static PyObject *get_memview(PyObject *__pyx_v_self); /*proto*/
static PyObject *get_memview(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = get_memview_MemoryView_5array_7memview___get__(((struct __pyx_array_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *get_memview_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self) {
  int __pyx_v_flags;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":219
 *         def __get__(self):
 * 
 *             flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE             # <<<<<<<<<<<<<<
 *             return  memoryview(self, flags, self.dtype_is_object)
 * 
 */
  __pyx_v_flags = ((PyBUF_ANY_CONTIGUOUS | PyBUF_FORMAT) | PyBUF_WRITABLE);

  /* "View.MemoryView":220
 * 
 *             flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
 *             return  memoryview(self, flags, self.dtype_is_object)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_memoryview_type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":217
 *     property memview:
 *         @cname('get_memview')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 * 
 *             flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.array.memview.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":223
 * 
 * 
 *     def __getattr__(self, attr):             # <<<<<<<<<<<<<<
 *         return getattr(self.memview, attr)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr); /*proto*/
static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0);
  __pyx_r = __pyx_array_MemoryView_5array_6__getattr__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_attr));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_array_MemoryView_5array_6__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getattr__", 0);

  /* "View.MemoryView":224
 * 
 *     def __getattr__(self, attr):
 *         return getattr(self.memview, attr)             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, item):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetAttr(__pyx_t_1, __pyx_v_attr); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":223
 * 
 * 
 *     def __getattr__(self, attr):             # <<<<<<<<<<<<<<
 *         return getattr(self.memview, attr)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.array.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":226
 *         return getattr(self.memview, attr)
 * 
 *     def __getitem__(self, item):             # <<<<<<<<<<<<<<
 *         return self.memview[item]
 * 
 */

/* Python wrapper */
static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_array_MemoryView_5array_8__getitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_array_MemoryView_5array_8__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "View.MemoryView":227
 * 
 *     def __getitem__(self, item):
 *         return self.memview[item]             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(self, item, value):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_item); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":226
 *         return getattr(self.memview, attr)
 * 
 *     def __getitem__(self, item):             # <<<<<<<<<<<<<<
 *         return self.memview[item]
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.array.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":229
 *         return self.memview[item]
 * 
 *     def __setitem__(self, item, value):             # <<<<<<<<<<<<<<
 *         self.memview[item] = value
 * 
 */

/* Python wrapper */
static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /*proto*/
static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
  __pyx_r = __pyx_array_MemoryView_5array_10__setitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_array_MemoryView_5array_10__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setitem__", 0);

  /* "View.MemoryView":230
 * 
 *     def __setitem__(self, item, value):
 *         self.memview[item] = value             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_item, __pyx_v_value) < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "View.MemoryView":229
 *         return self.memview[item]
 * 
 *     def __setitem__(self, item, value):             # <<<<<<<<<<<<<<
 *         self.memview[item] = value
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.array.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":234
 * 
 * @cname("__pyx_array_new")
 * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format,             # <<<<<<<<<<<<<<
 *                           char *mode, char *buf):
 *     cdef array result
 */

static struct __pyx_array_obj *__pyx_array_new(PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, char *__pyx_v_format, char *__pyx_v_mode, char *__pyx_v_buf) {
  struct __pyx_array_obj *__pyx_v_result = 0;
  struct __pyx_array_obj *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("array_cwrapper", 0);

  /* "View.MemoryView":238
 *     cdef array result
 * 
 *     if buf == NULL:             # <<<<<<<<<<<<<<
 *         result = array(shape, itemsize, format, mode.decode('ASCII'))
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_buf == NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":239
 * 
 *     if buf == NULL:
 *         result = array(shape, itemsize, format, mode.decode('ASCII'))             # <<<<<<<<<<<<<<
 *     else:
 *         result = array(shape, itemsize, format, mode.decode('ASCII'),
 */
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_shape);
    __Pyx_GIVEREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_array_type)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_4);
    __pyx_t_4 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "View.MemoryView":241
 *         result = array(shape, itemsize, format, mode.decode('ASCII'))
 *     else:
 *         result = array(shape, itemsize, format, mode.decode('ASCII'),             # <<<<<<<<<<<<<<
 *                        allocate_buffer=False)
 *         result.data = buf
 */
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape);
    __Pyx_GIVEREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);

    /* "View.MemoryView":242
 *     else:
 *         result = array(shape, itemsize, format, mode.decode('ASCII'),
 *                        allocate_buffer=False)             # <<<<<<<<<<<<<<
 *         result.data = buf
 * 
 */
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allocate_buffer, Py_False) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "View.MemoryView":241
 *         result = array(shape, itemsize, format, mode.decode('ASCII'))
 *     else:
 *         result = array(shape, itemsize, format, mode.decode('ASCII'),             # <<<<<<<<<<<<<<
 *                        allocate_buffer=False)
 *         result.data = buf
 */
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_array_type)), __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "View.MemoryView":243
 *         result = array(shape, itemsize, format, mode.decode('ASCII'),
 *                        allocate_buffer=False)
 *         result.data = buf             # <<<<<<<<<<<<<<
 * 
 *     return result
 */
    __pyx_v_result->data = __pyx_v_buf;
  }
  __pyx_L3:;

  /* "View.MemoryView":245
 *         result.data = buf
 * 
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "View.MemoryView":234
 * 
 * @cname("__pyx_array_new")
 * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format,             # <<<<<<<<<<<<<<
 *                           char *mode, char *buf):
 *     cdef array result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView.array_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":271
 * cdef class Enum(object):
 *     cdef object name
 *     def __init__(self, name):             # <<<<<<<<<<<<<<
 *         self.name = name
 *     def __repr__(self):
 */

/* Python wrapper */
static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_name = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("View.MemoryView.Enum.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_MemviewEnum_MemoryView_4Enum___init__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), __pyx_v_name);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_MemviewEnum_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "View.MemoryView":272
 *     cdef object name
 *     def __init__(self, name):
 *         self.name = name             # <<<<<<<<<<<<<<
 *     def __repr__(self):
 *         return self.name
 */
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  __Pyx_GOTREF(__pyx_v_self->name);
  __Pyx_DECREF(__pyx_v_self->name);
  __pyx_v_self->name = __pyx_v_name;

  /* "View.MemoryView":271
 * cdef class Enum(object):
 *     cdef object name
 *     def __init__(self, name):             # <<<<<<<<<<<<<<
 *         self.name = name
 *     def __repr__(self):
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":273
 *     def __init__(self, name):
 *         self.name = name
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return self.name
 * 
 */

/* Python wrapper */
static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_MemviewEnum_MemoryView_4Enum_2__repr__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_MemviewEnum_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "View.MemoryView":274
 *         self.name = name
 *     def __repr__(self):
 *         return self.name             # <<<<<<<<<<<<<<
 * 
 * cdef generic = Enum("<strided and direct or indirect>")
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->name);
  __pyx_r = __pyx_v_self->name;
  goto __pyx_L0;

  /* "View.MemoryView":273
 *     def __init__(self, name):
 *         self.name = name
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return self.name
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":288
 * 
 * @cname('__pyx_align_pointer')
 * cdef void *align_pointer(void *memory, size_t alignment) nogil:             # <<<<<<<<<<<<<<
 *     "Align pointer memory on a given boundary"
 *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
 */

static void *__pyx_align_pointer(void *__pyx_v_memory, size_t __pyx_v_alignment) {
  Py_intptr_t __pyx_v_aligned_p;
  size_t __pyx_v_offset;
  void *__pyx_r;
  int __pyx_t_1;

  /* "View.MemoryView":290
 * cdef void *align_pointer(void *memory, size_t alignment) nogil:
 *     "Align pointer memory on a given boundary"
 *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory             # <<<<<<<<<<<<<<
 *     cdef size_t offset
 * 
 */
  __pyx_v_aligned_p = ((Py_intptr_t)__pyx_v_memory);

  /* "View.MemoryView":294
 * 
 *     with cython.cdivision(True):
 *         offset = aligned_p % alignment             # <<<<<<<<<<<<<<
 * 
 *     if offset > 0:
 */
  __pyx_v_offset = (__pyx_v_aligned_p % __pyx_v_alignment);

  /* "View.MemoryView":296
 *         offset = aligned_p % alignment
 * 
 *     if offset > 0:             # <<<<<<<<<<<<<<
 *         aligned_p += alignment - offset
 * 
 */
  __pyx_t_1 = ((__pyx_v_offset > 0) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":297
 * 
 *     if offset > 0:
 *         aligned_p += alignment - offset             # <<<<<<<<<<<<<<
 * 
 *     return <void *> aligned_p
 */
    __pyx_v_aligned_p = (__pyx_v_aligned_p + (__pyx_v_alignment - __pyx_v_offset));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "View.MemoryView":299
 *         aligned_p += alignment - offset
 * 
 *     return <void *> aligned_p             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview')
 */
  __pyx_r = ((void *)__pyx_v_aligned_p);
  goto __pyx_L0;

  /* "View.MemoryView":288
 * 
 * @cname('__pyx_align_pointer')
 * cdef void *align_pointer(void *memory, size_t alignment) nogil:             # <<<<<<<<<<<<<<
 *     "Align pointer memory on a given boundary"
 *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":317
 *     cdef __Pyx_TypeInfo *typeinfo
 * 
 *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):             # <<<<<<<<<<<<<<
 *         self.obj = obj
 *         self.flags = flags
 */

/* Python wrapper */
static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_obj = 0;
  int __pyx_v_flags;
  int __pyx_v_dtype_is_object;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_flags,&__pyx_n_s_dtype_is_object,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_obj)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype_is_object);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_obj = values[0];
    __pyx_v_flags = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[2]) {
      __pyx_v_dtype_is_object = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_dtype_is_object == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_dtype_is_object = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_memoryview_MemoryView_10memoryview___cinit__(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_obj, __pyx_v_flags, __pyx_v_dtype_is_object);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_memoryview_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "View.MemoryView":318
 * 
 *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
 *         self.obj = obj             # <<<<<<<<<<<<<<
 *         self.flags = flags
 *         if type(self) is memoryview or obj is not None:
 */
  __Pyx_INCREF(__pyx_v_obj);
  __Pyx_GIVEREF(__pyx_v_obj);
  __Pyx_GOTREF(__pyx_v_self->obj);
  __Pyx_DECREF(__pyx_v_self->obj);
  __pyx_v_self->obj = __pyx_v_obj;

  /* "View.MemoryView":319
 *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
 *         self.obj = obj
 *         self.flags = flags             # <<<<<<<<<<<<<<
 *         if type(self) is memoryview or obj is not None:
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 */
  __pyx_v_self->flags = __pyx_v_flags;

  /* "View.MemoryView":320
 *         self.obj = obj
 *         self.flags = flags
 *         if type(self) is memoryview or obj is not None:             # <<<<<<<<<<<<<<
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 *             if <PyObject *> self.view.obj == NULL:
 */
  __pyx_t_2 = (((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))) == ((PyObject *)((PyObject *)__pyx_memoryview_type)));
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = (__pyx_v_obj != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "View.MemoryView":321
 *         self.flags = flags
 *         if type(self) is memoryview or obj is not None:
 *             __Pyx_GetBuffer(obj, &self.view, flags)             # <<<<<<<<<<<<<<
 *             if <PyObject *> self.view.obj == NULL:
 *                 (<__pyx_buffer *> &self.view).obj = Py_None
 */
    __pyx_t_4 = __Pyx_GetBuffer(__pyx_v_obj, (&__pyx_v_self->view), __pyx_v_flags); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "View.MemoryView":322
 *         if type(self) is memoryview or obj is not None:
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 *             if <PyObject *> self.view.obj == NULL:             # <<<<<<<<<<<<<<
 *                 (<__pyx_buffer *> &self.view).obj = Py_None
 *                 Py_INCREF(Py_None)
 */
    __pyx_t_1 = ((((PyObject *)__pyx_v_self->view.obj) == NULL) != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":323
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 *             if <PyObject *> self.view.obj == NULL:
 *                 (<__pyx_buffer *> &self.view).obj = Py_None             # <<<<<<<<<<<<<<
 *                 Py_INCREF(Py_None)
 * 
 */
      ((Py_buffer *)(&__pyx_v_self->view))->obj = Py_None;

      /* "View.MemoryView":324
 *             if <PyObject *> self.view.obj == NULL:
 *                 (<__pyx_buffer *> &self.view).obj = Py_None
 *                 Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
 * 
 *         self.lock = PyThread_allocate_lock()
 */
      Py_INCREF(Py_None);
      goto __pyx_L6;
    }
    __pyx_L6:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "View.MemoryView":326
 *                 Py_INCREF(Py_None)
 * 
 *         self.lock = PyThread_allocate_lock()             # <<<<<<<<<<<<<<
 *         if self.lock == NULL:
 *             raise MemoryError
 */
  __pyx_v_self->lock = PyThread_allocate_lock();

  /* "View.MemoryView":327
 * 
 *         self.lock = PyThread_allocate_lock()
 *         if self.lock == NULL:             # <<<<<<<<<<<<<<
 *             raise MemoryError
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":328
 *         self.lock = PyThread_allocate_lock()
 *         if self.lock == NULL:
 *             raise MemoryError             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_FORMAT:
 */
    PyErr_NoMemory(); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "View.MemoryView":330
 *             raise MemoryError
 * 
 *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
 *             self.dtype_is_object = self.view.format == b'O'
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":331
 * 
 *         if flags & PyBUF_FORMAT:
 *             self.dtype_is_object = self.view.format == b'O'             # <<<<<<<<<<<<<<
 *         else:
 *             self.dtype_is_object = dtype_is_object
 */
    __pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_5, __pyx_n_b_O, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_self->dtype_is_object = __pyx_t_1;
    goto __pyx_L8;
  }
  /*else*/ {

    /* "View.MemoryView":333
 *             self.dtype_is_object = self.view.format == b'O'
 *         else:
 *             self.dtype_is_object = dtype_is_object             # <<<<<<<<<<<<<<
 * 
 *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
 */
    __pyx_v_self->dtype_is_object = __pyx_v_dtype_is_object;
  }
  __pyx_L8:;

  /* "View.MemoryView":335
 *             self.dtype_is_object = dtype_is_object
 * 
 *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(             # <<<<<<<<<<<<<<
 *                   <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
 *         self.typeinfo = NULL
 */
  __pyx_v_self->acquisition_count_aligned_p = ((__pyx_atomic_int *)__pyx_align_pointer(((void *)(&(__pyx_v_self->acquisition_count[0]))), (sizeof(__pyx_atomic_int))));

  /* "View.MemoryView":337
 *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
 *                   <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
 *         self.typeinfo = NULL             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(memoryview self):
 */
  __pyx_v_self->typeinfo = NULL;

  /* "View.MemoryView":317
 *     cdef __Pyx_TypeInfo *typeinfo
 * 
 *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):             # <<<<<<<<<<<<<<
 *         self.obj = obj
 *         self.flags = flags
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":339
 *         self.typeinfo = NULL
 * 
 *     def __dealloc__(memoryview self):             # <<<<<<<<<<<<<<
 *         if self.obj is not None:
 *             __Pyx_ReleaseBuffer(&self.view)
 */

/* Python wrapper */
static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_memoryview_MemoryView_10memoryview_2__dealloc__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_memoryview_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "View.MemoryView":340
 * 
 *     def __dealloc__(memoryview self):
 *         if self.obj is not None:             # <<<<<<<<<<<<<<
 *             __Pyx_ReleaseBuffer(&self.view)
 * 
 */
  __pyx_t_1 = (__pyx_v_self->obj != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":341
 *     def __dealloc__(memoryview self):
 *         if self.obj is not None:
 *             __Pyx_ReleaseBuffer(&self.view)             # <<<<<<<<<<<<<<
 * 
 *         if self.lock != NULL:
 */
    __Pyx_ReleaseBuffer((&__pyx_v_self->view));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "View.MemoryView":343
 *             __Pyx_ReleaseBuffer(&self.view)
 * 
 *         if self.lock != NULL:             # <<<<<<<<<<<<<<
 *             PyThread_free_lock(self.lock)
 * 
 */
  __pyx_t_2 = ((__pyx_v_self->lock != NULL) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":344
 * 
 *         if self.lock != NULL:
 *             PyThread_free_lock(self.lock)             # <<<<<<<<<<<<<<
 * 
 *     cdef char *get_item_pointer(memoryview self, object index) except NULL:
 */
    PyThread_free_lock(__pyx_v_self->lock);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "View.MemoryView":339
 *         self.typeinfo = NULL
 * 
 *     def __dealloc__(memoryview self):             # <<<<<<<<<<<<<<
 *         if self.obj is not None:
 *             __Pyx_ReleaseBuffer(&self.view)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "View.MemoryView":346
 *             PyThread_free_lock(self.lock)
 * 
 *     cdef char *get_item_pointer(memoryview self, object index) except NULL:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t dim
 *         cdef char *itemp = <char *> self.view.buf
 */

static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
  Py_ssize_t __pyx_v_dim;
  char *__pyx_v_itemp;
  PyObject *__pyx_v_idx = NULL;
  char *__pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  char *__pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_item_pointer", 0);

  /* "View.MemoryView":348
 *     cdef char *get_item_pointer(memoryview self, object index) except NULL:
 *         cdef Py_ssize_t dim
 *         cdef char *itemp = <char *> self.view.buf             # <<<<<<<<<<<<<<
 * 
 *         for dim, idx in enumerate(index):
 */
  __pyx_v_itemp = ((char *)__pyx_v_self->view.buf);

  /* "View.MemoryView":350
 *         cdef char *itemp = <char *> self.view.buf
 * 
 *         for dim, idx in enumerate(index):             # <<<<<<<<<<<<<<
 *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
 * 
 */
  __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_v_index)) || PyTuple_CheckExact(__pyx_v_index)) {
    __pyx_t_2 = __pyx_v_index; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_index); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_5)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_v_dim = __pyx_t_1;
    __pyx_t_1 = (__pyx_t_1 + 1);

    /* "View.MemoryView":351
 * 
 *         for dim, idx in enumerate(index):
 *             itemp = pybuffer_index(&self.view, itemp, idx, dim)             # <<<<<<<<<<<<<<
 * 
 *         return itemp
 */
    __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_idx); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __pyx_pybuffer_index((&__pyx_v_self->view), __pyx_v_itemp, __pyx_t_6, __pyx_v_dim); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_itemp = __pyx_t_7;

    /* "View.MemoryView":350
 *         cdef char *itemp = <char *> self.view.buf
 * 
 *         for dim, idx in enumerate(index):             # <<<<<<<<<<<<<<
 *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "View.MemoryView":353
 *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
 * 
 *         return itemp             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_itemp;
  goto __pyx_L0;

  /* "View.MemoryView":346
 *             PyThread_free_lock(self.lock)
 * 
 *     cdef char *get_item_pointer(memoryview self, object index) except NULL:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t dim
 *         cdef char *itemp = <char *> self.view.buf
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView.memoryview.get_item_pointer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_idx);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":356
 * 
 * 
 *     def __getitem__(memoryview self, object index):             # <<<<<<<<<<<<<<
 *         if index is Ellipsis:
 *             return self
 */

/* Python wrapper */
static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/
static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview_MemoryView_10memoryview_4__getitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
  PyObject *__pyx_v_have_slices = NULL;
  PyObject *__pyx_v_indices = NULL;
  char *__pyx_v_itemp;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  char *__pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "View.MemoryView":357
 * 
 *     def __getitem__(memoryview self, object index):
 *         if index is Ellipsis:             # <<<<<<<<<<<<<<
 *             return self
 * 
 */
  __pyx_t_1 = (__pyx_v_index == __pyx_builtin_Ellipsis);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":358
 *     def __getitem__(memoryview self, object index):
 *         if index is Ellipsis:
 *             return self             # <<<<<<<<<<<<<<
 * 
 *         have_slices, indices = _unellipsify(index, self.view.ndim)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = ((PyObject *)__pyx_v_self);
    goto __pyx_L0;
  }

  /* "View.MemoryView":360
 *             return self
 * 
 *         have_slices, indices = _unellipsify(index, self.view.ndim)             # <<<<<<<<<<<<<<
 * 
 *         cdef char *itemp
 */
  __pyx_t_3 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (likely(__pyx_t_3 != Py_None)) {
    PyObject* sequence = __pyx_t_3;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_have_slices = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_v_indices = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "View.MemoryView":363
 * 
 *         cdef char *itemp
 *         if have_slices:             # <<<<<<<<<<<<<<
 *             return memview_slice(self, indices)
 *         else:
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_2) {

    /* "View.MemoryView":364
 *         cdef char *itemp
 *         if have_slices:
 *             return memview_slice(self, indices)             # <<<<<<<<<<<<<<
 *         else:
 *             itemp = self.get_item_pointer(indices)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = ((PyObject *)__pyx_memview_slice(__pyx_v_self, __pyx_v_indices)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "View.MemoryView":366
 *             return memview_slice(self, indices)
 *         else:
 *             itemp = self.get_item_pointer(indices)             # <<<<<<<<<<<<<<
 *             return self.convert_item_to_object(itemp)
 * 
 */
    __pyx_t_6 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_indices); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_itemp = __pyx_t_6;

    /* "View.MemoryView":367
 *         else:
 *             itemp = self.get_item_pointer(indices)
 *             return self.convert_item_to_object(itemp)             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(memoryview self, object index, object value):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->convert_item_to_object(__pyx_v_self, __pyx_v_itemp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "View.MemoryView":356
 * 
 * 
 *     def __getitem__(memoryview self, object index):             # <<<<<<<<<<<<<<
 *         if index is Ellipsis:
 *             return self
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView.memoryview.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_have_slices);
  __Pyx_XDECREF(__pyx_v_indices);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":369
 *             return self.convert_item_to_object(itemp)
 * 
 *     def __setitem__(memoryview self, object index, object value):             # <<<<<<<<<<<<<<
 *         have_slices, index = _unellipsify(index, self.view.ndim)
 * 
 */

/* Python wrapper */
static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /*proto*/
static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview_MemoryView_10memoryview_6__setitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_memoryview_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
  PyObject *__pyx_v_have_slices = NULL;
  PyObject *__pyx_v_obj = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setitem__", 0);
  __Pyx_INCREF(__pyx_v_index);

  /* "View.MemoryView":370
 * 
 *     def __setitem__(memoryview self, object index, object value):
 *         have_slices, index = _unellipsify(index, self.view.ndim)             # <<<<<<<<<<<<<<
 * 
 *         if have_slices:
 */
  __pyx_t_1 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(__pyx_t_1 != Py_None)) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_have_slices = __pyx_t_2;
  __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_index, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "View.MemoryView":372
 *         have_slices, index = _unellipsify(index, self.view.ndim)
 * 
 *         if have_slices:             # <<<<<<<<<<<<<<
 *             obj = self.is_slice(value)
 *             if obj:
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_4) {

    /* "View.MemoryView":373
 * 
 *         if have_slices:
 *             obj = self.is_slice(value)             # <<<<<<<<<<<<<<
 *             if obj:
 *                 self.setitem_slice_assignment(self[index], obj)
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->is_slice(__pyx_v_self, __pyx_v_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_obj = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "View.MemoryView":374
 *         if have_slices:
 *             obj = self.is_slice(value)
 *             if obj:             # <<<<<<<<<<<<<<
 *                 self.setitem_slice_assignment(self[index], obj)
 *             else:
 */
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_obj); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_4) {

      /* "View.MemoryView":375
 *             obj = self.is_slice(value)
 *             if obj:
 *                 self.setitem_slice_assignment(self[index], obj)             # <<<<<<<<<<<<<<
 *             else:
 *                 self.setitem_slice_assign_scalar(self[index], value)
 */
      __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assignment(__pyx_v_self, __pyx_t_1, __pyx_v_obj); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "View.MemoryView":377
 *                 self.setitem_slice_assignment(self[index], obj)
 *             else:
 *                 self.setitem_slice_assign_scalar(self[index], value)             # <<<<<<<<<<<<<<
 *         else:
 *             self.setitem_indexed(index, value)
 */
      __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assign_scalar(__pyx_v_self, ((struct __pyx_memoryview_obj *)__pyx_t_3), __pyx_v_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "View.MemoryView":379
 *                 self.setitem_slice_assign_scalar(self[index], value)
 *         else:
 *             self.setitem_indexed(index, value)             # <<<<<<<<<<<<<<
 * 
 *     cdef is_slice(self, obj):
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_indexed(__pyx_v_self, __pyx_v_index, __pyx_v_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "View.MemoryView":369
 *             return self.convert_item_to_object(itemp)
 * 
 *     def __setitem__(memoryview self, object index, object value):             # <<<<<<<<<<<<<<
 *         have_slices, index = _unellipsify(index, self.view.ndim)
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.memoryview.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_have_slices);
  __Pyx_XDECREF(__pyx_v_obj);
  __Pyx_XDECREF(__pyx_v_index);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":381
 *             self.setitem_indexed(index, value)
 * 
 *     cdef is_slice(self, obj):             # <<<<<<<<<<<<<<
 *         if not isinstance(obj, memoryview):
 *             try:
 */

static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_slice", 0);
  __Pyx_INCREF(__pyx_v_obj);

  /* "View.MemoryView":382
 * 
 *     cdef is_slice(self, obj):
 *         if not isinstance(obj, memoryview):             # <<<<<<<<<<<<<<
 *             try:
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, ((PyObject *)__pyx_memoryview_type)); 
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":383
 *     cdef is_slice(self, obj):
 *         if not isinstance(obj, memoryview):
 *             try:             # <<<<<<<<<<<<<<
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
 *                                  self.dtype_is_object)
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_5);
      /*try:*/ {

        /* "View.MemoryView":384
 *         if not isinstance(obj, memoryview):
 *             try:
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,             # <<<<<<<<<<<<<<
 *                                  self.dtype_is_object)
 *             except TypeError:
 */
        __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_self->flags | PyBUF_ANY_CONTIGUOUS)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_6);

        /* "View.MemoryView":385
 *             try:
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
 *                                  self.dtype_is_object)             # <<<<<<<<<<<<<<
 *             except TypeError:
 *                 return None
 */
        __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_7);

        /* "View.MemoryView":384
 *         if not isinstance(obj, memoryview):
 *             try:
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,             # <<<<<<<<<<<<<<
 *                                  self.dtype_is_object)
 *             except TypeError:
 */
        __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_INCREF(__pyx_v_obj);
        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_obj);
        __Pyx_GIVEREF(__pyx_v_obj);
        PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_7);
        __pyx_t_6 = 0;
        __pyx_t_7 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_memoryview_type)), __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_7);
        __pyx_t_7 = 0;
      }
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L11_try_end;
      __pyx_L4_error:;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "View.MemoryView":386
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
 *                                  self.dtype_is_object)
 *             except TypeError:             # <<<<<<<<<<<<<<
 *                 return None
 * 
 */
      __pyx_t_9 = PyErr_ExceptionMatches(__pyx_builtin_TypeError);
      if (__pyx_t_9) {
        __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GOTREF(__pyx_t_6);

        /* "View.MemoryView":387
 *                                  self.dtype_is_object)
 *             except TypeError:
 *                 return None             # <<<<<<<<<<<<<<
 * 
 *         return obj
 */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_None);
        __pyx_r = Py_None;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L7_except_return;
      }
      goto __pyx_L6_except_error;
      __pyx_L6_except_error:;
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      goto __pyx_L1_error;
      __pyx_L7_except_return:;
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      goto __pyx_L0;
      __pyx_L11_try_end:;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "View.MemoryView":389
 *                 return None
 * 
 *         return obj             # <<<<<<<<<<<<<<
 * 
 *     cdef setitem_slice_assignment(self, dst, src):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_obj);
  __pyx_r = __pyx_v_obj;
  goto __pyx_L0;

  /* "View.MemoryView":381
 *             self.setitem_indexed(index, value)
 * 
 *     cdef is_slice(self, obj):             # <<<<<<<<<<<<<<
 *         if not isinstance(obj, memoryview):
 *             try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_obj);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":391
 *         return obj
 * 
 *     cdef setitem_slice_assignment(self, dst, src):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice dst_slice
 *         cdef __Pyx_memviewslice src_slice
 */

static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src) {
  __Pyx_memviewslice __pyx_v_dst_slice;
  __Pyx_memviewslice __pyx_v_src_slice;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("setitem_slice_assignment", 0);

  /* "View.MemoryView":395
 *         cdef __Pyx_memviewslice src_slice
 * 
 *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],             # <<<<<<<<<<<<<<
 *                                  get_slice_from_memview(dst, &dst_slice)[0],
 *                                  src.ndim, dst.ndim, self.dtype_is_object)
 */
  if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_memoryview_type))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "View.MemoryView":396
 * 
 *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
 *                                  get_slice_from_memview(dst, &dst_slice)[0],             # <<<<<<<<<<<<<<
 *                                  src.ndim, dst.ndim, self.dtype_is_object)
 * 
 */
  if (!(likely(((__pyx_v_dst) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_dst, __pyx_memoryview_type))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "View.MemoryView":397
 *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
 *                                  get_slice_from_memview(dst, &dst_slice)[0],
 *                                  src.ndim, dst.ndim, self.dtype_is_object)             # <<<<<<<<<<<<<<
 * 
 *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dst, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "View.MemoryView":395
 *         cdef __Pyx_memviewslice src_slice
 * 
 *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],             # <<<<<<<<<<<<<<
 *                                  get_slice_from_memview(dst, &dst_slice)[0],
 *                                  src.ndim, dst.ndim, self.dtype_is_object)
 */
  __pyx_t_4 = __pyx_memoryview_copy_contents((__pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_src), (&__pyx_v_src_slice))[0]), (__pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_dst), (&__pyx_v_dst_slice))[0]), __pyx_t_2, __pyx_t_3, __pyx_v_self->dtype_is_object); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "View.MemoryView":391
 *         return obj
 * 
 *     cdef setitem_slice_assignment(self, dst, src):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice dst_slice
 *         cdef __Pyx_memviewslice src_slice
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assignment", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":399
 *                                  src.ndim, dst.ndim, self.dtype_is_object)
 * 
 *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):             # <<<<<<<<<<<<<<
 *         cdef int array[128]
 *         cdef void *tmp = NULL
 */

static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value) {
  int __pyx_v_array[128];
  void *__pyx_v_tmp;
  void *__pyx_v_item;
  __Pyx_memviewslice *__pyx_v_dst_slice;
  __Pyx_memviewslice __pyx_v_tmp_slice;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  char const *__pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("setitem_slice_assign_scalar", 0);

  /* "View.MemoryView":401
 *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):
 *         cdef int array[128]
 *         cdef void *tmp = NULL             # <<<<<<<<<<<<<<
 *         cdef void *item
 * 
 */
  __pyx_v_tmp = NULL;

  /* "View.MemoryView":406
 *         cdef __Pyx_memviewslice *dst_slice
 *         cdef __Pyx_memviewslice tmp_slice
 *         dst_slice = get_slice_from_memview(dst, &tmp_slice)             # <<<<<<<<<<<<<<
 * 
 *         if <size_t>self.view.itemsize > sizeof(array):
 */
  __pyx_v_dst_slice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_dst, (&__pyx_v_tmp_slice));

  /* "View.MemoryView":408
 *         dst_slice = get_slice_from_memview(dst, &tmp_slice)
 * 
 *         if <size_t>self.view.itemsize > sizeof(array):             # <<<<<<<<<<<<<<
 *             tmp = PyMem_Malloc(self.view.itemsize)
 *             if tmp == NULL:
 */
  __pyx_t_1 = ((((size_t)__pyx_v_self->view.itemsize) > (sizeof(__pyx_v_array))) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":409
 * 
 *         if <size_t>self.view.itemsize > sizeof(array):
 *             tmp = PyMem_Malloc(self.view.itemsize)             # <<<<<<<<<<<<<<
 *             if tmp == NULL:
 *                 raise MemoryError
 */
    __pyx_v_tmp = PyMem_Malloc(__pyx_v_self->view.itemsize);

    /* "View.MemoryView":410
 *         if <size_t>self.view.itemsize > sizeof(array):
 *             tmp = PyMem_Malloc(self.view.itemsize)
 *             if tmp == NULL:             # <<<<<<<<<<<<<<
 *                 raise MemoryError
 *             item = tmp
 */
    __pyx_t_1 = ((__pyx_v_tmp == NULL) != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":411
 *             tmp = PyMem_Malloc(self.view.itemsize)
 *             if tmp == NULL:
 *                 raise MemoryError             # <<<<<<<<<<<<<<
 *             item = tmp
 *         else:
 */
      PyErr_NoMemory(); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "View.MemoryView":412
 *             if tmp == NULL:
 *                 raise MemoryError
 *             item = tmp             # <<<<<<<<<<<<<<
 *         else:
 *             item = <void *> array
 */
    __pyx_v_item = __pyx_v_tmp;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "View.MemoryView":414
 *             item = tmp
 *         else:
 *             item = <void *> array             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
    __pyx_v_item = ((void *)__pyx_v_array);
  }
  __pyx_L3:;

  /* "View.MemoryView":416
 *             item = <void *> array
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if self.dtype_is_object:
 *                 (<PyObject **> item)[0] = <PyObject *> value
 */
  /*try:*/ {

    /* "View.MemoryView":417
 * 
 *         try:
 *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
 *                 (<PyObject **> item)[0] = <PyObject *> value
 *             else:
 */
    __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":418
 *         try:
 *             if self.dtype_is_object:
 *                 (<PyObject **> item)[0] = <PyObject *> value             # <<<<<<<<<<<<<<
 *             else:
 *                 self.assign_item_from_object(<char *> item, value)
 */
      (((PyObject **)__pyx_v_item)[0]) = ((PyObject *)__pyx_v_value);
      goto __pyx_L8;
    }
    /*else*/ {

      /* "View.MemoryView":420
 *                 (<PyObject **> item)[0] = <PyObject *> value
 *             else:
 *                 self.assign_item_from_object(<char *> item, value)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, ((char *)__pyx_v_item), __pyx_v_value); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __pyx_L8:;

    /* "View.MemoryView":424
 * 
 * 
 *             if self.view.suboffsets != NULL:             # <<<<<<<<<<<<<<
 *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
 *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
 */
    __pyx_t_1 = ((__pyx_v_self->view.suboffsets != NULL) != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":425
 * 
 *             if self.view.suboffsets != NULL:
 *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)             # <<<<<<<<<<<<<<
 *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
 *                                 item, self.dtype_is_object)
 */
      __pyx_t_2 = assert_direct_dimensions(__pyx_v_self->view.suboffsets, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "View.MemoryView":426
 *             if self.view.suboffsets != NULL:
 *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
 *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,             # <<<<<<<<<<<<<<
 *                                 item, self.dtype_is_object)
 *         finally:
 */
    __pyx_memoryview_slice_assign_scalar(__pyx_v_dst_slice, __pyx_v_dst->view.ndim, __pyx_v_self->view.itemsize, __pyx_v_item, __pyx_v_self->dtype_is_object);
  }

  /* "View.MemoryView":429
 *                                 item, self.dtype_is_object)
 *         finally:
 *             PyMem_Free(tmp)             # <<<<<<<<<<<<<<
 * 
 *     cdef setitem_indexed(self, index, value):
 */
  /*finally:*/ {
    /*normal exit:*/{
      PyMem_Free(__pyx_v_tmp);
      goto __pyx_L7;
    }
    /*exception exit:*/{
      __pyx_L6_error:;
      __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0)) __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __pyx_t_3 = __pyx_lineno; __pyx_t_4 = __pyx_clineno; __pyx_t_5 = __pyx_filename;
      {
        PyMem_Free(__pyx_v_tmp);
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
      __pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_4; __pyx_filename = __pyx_t_5;
      goto __pyx_L1_error;
    }
    __pyx_L7:;
  }

  /* "View.MemoryView":399
 *                                  src.ndim, dst.ndim, self.dtype_is_object)
 * 
 *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):             # <<<<<<<<<<<<<<
 *         cdef int array[128]
 *         cdef void *tmp = NULL
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assign_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":431
 *             PyMem_Free(tmp)
 * 
 *     cdef setitem_indexed(self, index, value):             # <<<<<<<<<<<<<<
 *         cdef char *itemp = self.get_item_pointer(index)
 *         self.assign_item_from_object(itemp, value)
 */

static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
  char *__pyx_v_itemp;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  char *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("setitem_indexed", 0);

  /* "View.MemoryView":432
 * 
 *     cdef setitem_indexed(self, index, value):
 *         cdef char *itemp = self.get_item_pointer(index)             # <<<<<<<<<<<<<<
 *         self.assign_item_from_object(itemp, value)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_index); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_itemp = __pyx_t_1;

  /* "View.MemoryView":433
 *     cdef setitem_indexed(self, index, value):
 *         cdef char *itemp = self.get_item_pointer(index)
 *         self.assign_item_from_object(itemp, value)             # <<<<<<<<<<<<<<
 * 
 *     cdef convert_item_to_object(self, char *itemp):
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "View.MemoryView":431
 *             PyMem_Free(tmp)
 * 
 *     cdef setitem_indexed(self, index, value):             # <<<<<<<<<<<<<<
 *         cdef char *itemp = self.get_item_pointer(index)
 *         self.assign_item_from_object(itemp, value)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_indexed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":435
 *         self.assign_item_from_object(itemp, value)
 * 
 *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
 *         """Only used if instantiated manually by the user, or if Cython doesn't
 *         know how to convert the type"""
 */

static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp) {
  PyObject *__pyx_v_struct = NULL;
  PyObject *__pyx_v_bytesitem = 0;
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  size_t __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("convert_item_to_object", 0);

  /* "View.MemoryView":438
 *         """Only used if instantiated manually by the user, or if Cython doesn't
 *         know how to convert the type"""
 *         import struct             # <<<<<<<<<<<<<<
 *         cdef bytes bytesitem
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_struct = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "View.MemoryView":441
 *         cdef bytes bytesitem
 * 
 *         bytesitem = itemp[:self.view.itemsize]             # <<<<<<<<<<<<<<
 *         try:
 *             result = struct.unpack(self.view.format, bytesitem)
 */
  __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_itemp + 0, __pyx_v_self->view.itemsize - 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_bytesitem = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":442
 * 
 *         bytesitem = itemp[:self.view.itemsize]
 *         try:             # <<<<<<<<<<<<<<
 *             result = struct.unpack(self.view.format, bytesitem)
 *         except struct.error:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    /*try:*/ {

      /* "View.MemoryView":443
 *         bytesitem = itemp[:self.view.itemsize]
 *         try:
 *             result = struct.unpack(self.view.format, bytesitem)             # <<<<<<<<<<<<<<
 *         except struct.error:
 *             raise ValueError("Unable to convert item to object")
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_unpack); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_8 = 1;
        }
      }
      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = NULL;
      }
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_bytesitem);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem);
      __Pyx_GIVEREF(__pyx_v_bytesitem);
      __pyx_t_6 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_result = __pyx_t_1;
      __pyx_t_1 = 0;
    }
    /*else:*/ {

      /* "View.MemoryView":447
 *             raise ValueError("Unable to convert item to object")
 *         else:
 *             if len(self.view.format) == 1:             # <<<<<<<<<<<<<<
 *                 return result[0]
 *             return result
 */
      __pyx_t_10 = strlen(__pyx_v_self->view.format); 
      __pyx_t_11 = ((__pyx_t_10 == 1) != 0);
      if (__pyx_t_11) {

        /* "View.MemoryView":448
 *         else:
 *             if len(self.view.format) == 1:
 *                 return result[0]             # <<<<<<<<<<<<<<
 *             return result
 * 
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_result, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;};
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_r = __pyx_t_1;
        __pyx_t_1 = 0;
        goto __pyx_L6_except_return;
      }

      /* "View.MemoryView":449
 *             if len(self.view.format) == 1:
 *                 return result[0]
 *             return result             # <<<<<<<<<<<<<<
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_result);
      __pyx_r = __pyx_v_result;
      goto __pyx_L6_except_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "View.MemoryView":444
 *         try:
 *             result = struct.unpack(self.view.format, bytesitem)
 *         except struct.error:             # <<<<<<<<<<<<<<
 *             raise ValueError("Unable to convert item to object")
 *         else:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_12 = PyErr_ExceptionMatches(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_12) {
      __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_9);

      /* "View.MemoryView":445
 *             result = struct.unpack(self.view.format, bytesitem)
 *         except struct.error:
 *             raise ValueError("Unable to convert item to object")             # <<<<<<<<<<<<<<
 *         else:
 *             if len(self.view.format) == 1:
 */
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__108, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
    goto __pyx_L0;
  }

  /* "View.MemoryView":435
 *         self.assign_item_from_object(itemp, value)
 * 
 *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
 *         """Only used if instantiated manually by the user, or if Cython doesn't
 *         know how to convert the type"""
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_struct);
  __Pyx_XDECREF(__pyx_v_bytesitem);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":451
 *             return result
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
 *         """Only used if instantiated manually by the user, or if Cython doesn't
 *         know how to convert the type"""
 */

static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
  PyObject *__pyx_v_struct = NULL;
  char __pyx_v_c;
  PyObject *__pyx_v_bytesvalue = 0;
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  char *__pyx_t_10;
  char *__pyx_t_11;
  char *__pyx_t_12;
  char *__pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("assign_item_from_object", 0);

  /* "View.MemoryView":454
 *         """Only used if instantiated manually by the user, or if Cython doesn't
 *         know how to convert the type"""
 *         import struct             # <<<<<<<<<<<<<<
 *         cdef char c
 *         cdef bytes bytesvalue
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_struct = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "View.MemoryView":459
 *         cdef Py_ssize_t i
 * 
 *         if isinstance(value, tuple):             # <<<<<<<<<<<<<<
 *             bytesvalue = struct.pack(self.view.format, *value)
 *         else:
 */
  __pyx_t_2 = PyTuple_Check(__pyx_v_value); 
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "View.MemoryView":460
 * 
 *         if isinstance(value, tuple):
 *             bytesvalue = struct.pack(self.view.format, *value)             # <<<<<<<<<<<<<<
 *         else:
 *             bytesvalue = struct.pack(self.view.format, value)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "View.MemoryView":462
 *             bytesvalue = struct.pack(self.view.format, *value)
 *         else:
 *             bytesvalue = struct.pack(self.view.format, value)             # <<<<<<<<<<<<<<
 * 
 *         for i, c in enumerate(bytesvalue):
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_7 = 1;
      }
    }
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_5) {
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
    }
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_value);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value);
    __Pyx_GIVEREF(__pyx_v_value);
    __pyx_t_1 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
  }
  __pyx_L3:;

  /* "View.MemoryView":464
 *             bytesvalue = struct.pack(self.view.format, value)
 * 
 *         for i, c in enumerate(bytesvalue):             # <<<<<<<<<<<<<<
 *             itemp[i] = c
 * 
 */
  __pyx_t_7 = 0;
  if (unlikely(__pyx_v_bytesvalue == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable");
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_INCREF(__pyx_v_bytesvalue);
  __pyx_t_9 = __pyx_v_bytesvalue;
  __pyx_t_11 = PyBytes_AS_STRING(__pyx_t_9);
  __pyx_t_12 = (__pyx_t_11 + PyBytes_GET_SIZE(__pyx_t_9));
  for (__pyx_t_13 = __pyx_t_11; __pyx_t_13 < __pyx_t_12; __pyx_t_13++) {
    __pyx_t_10 = __pyx_t_13;
    __pyx_v_c = (__pyx_t_10[0]);

    /* "View.MemoryView":465
 * 
 *         for i, c in enumerate(bytesvalue):
 *             itemp[i] = c             # <<<<<<<<<<<<<<
 * 
 *     @cname('getbuffer')
 */
    __pyx_v_i = __pyx_t_7;

    /* "View.MemoryView":464
 *             bytesvalue = struct.pack(self.view.format, value)
 * 
 *         for i, c in enumerate(bytesvalue):             # <<<<<<<<<<<<<<
 *             itemp[i] = c
 * 
 */
    __pyx_t_7 = (__pyx_t_7 + 1);

    /* "View.MemoryView":465
 * 
 *         for i, c in enumerate(bytesvalue):
 *             itemp[i] = c             # <<<<<<<<<<<<<<
 * 
 *     @cname('getbuffer')
 */
    (__pyx_v_itemp[__pyx_v_i]) = __pyx_v_c;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "View.MemoryView":451
 *             return result
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
 *         """Only used if instantiated manually by the user, or if Cython doesn't
 *         know how to convert the type"""
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("View.MemoryView.memoryview.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_struct);
  __Pyx_XDECREF(__pyx_v_bytesvalue);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":468
 * 
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
 *         if flags & PyBUF_STRIDES:
 *             info.shape = self.view.shape
 */

/* Python wrapper */
static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview_getbuffer_MemoryView_10memoryview_8__getbuffer__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_memoryview_getbuffer_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  Py_ssize_t *__pyx_t_2;
  char *__pyx_t_3;
  void *__pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("__getbuffer__", 0);
  if (__pyx_v_info != NULL) {
    __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(__pyx_v_info->obj);
  }

  /* "View.MemoryView":469
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):
 *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
 *             info.shape = self.view.shape
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":470
 *     def __getbuffer__(self, Py_buffer *info, int flags):
 *         if flags & PyBUF_STRIDES:
 *             info.shape = self.view.shape             # <<<<<<<<<<<<<<
 *         else:
 *             info.shape = NULL
 */
    __pyx_t_2 = __pyx_v_self->view.shape;
    __pyx_v_info->shape = __pyx_t_2;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "View.MemoryView":472
 *             info.shape = self.view.shape
 *         else:
 *             info.shape = NULL             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_STRIDES:
 */
    __pyx_v_info->shape = NULL;
  }
  __pyx_L3:;

  /* "View.MemoryView":474
 *             info.shape = NULL
 * 
 *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
 *             info.strides = self.view.strides
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":475
 * 
 *         if flags & PyBUF_STRIDES:
 *             info.strides = self.view.strides             # <<<<<<<<<<<<<<
 *         else:
 *             info.strides = NULL
 */
    __pyx_t_2 = __pyx_v_self->view.strides;
    __pyx_v_info->strides = __pyx_t_2;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "View.MemoryView":477
 *             info.strides = self.view.strides
 *         else:
 *             info.strides = NULL             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_INDIRECT:
 */
    __pyx_v_info->strides = NULL;
  }
  __pyx_L4:;

  /* "View.MemoryView":479
 *             info.strides = NULL
 * 
 *         if flags & PyBUF_INDIRECT:             # <<<<<<<<<<<<<<
 *             info.suboffsets = self.view.suboffsets
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_INDIRECT) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":480
 * 
 *         if flags & PyBUF_INDIRECT:
 *             info.suboffsets = self.view.suboffsets             # <<<<<<<<<<<<<<
 *         else:
 *             info.suboffsets = NULL
 */
    __pyx_t_2 = __pyx_v_self->view.suboffsets;
    __pyx_v_info->suboffsets = __pyx_t_2;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "View.MemoryView":482
 *             info.suboffsets = self.view.suboffsets
 *         else:
 *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_FORMAT:
 */
    __pyx_v_info->suboffsets = NULL;
  }
  __pyx_L5:;

  /* "View.MemoryView":484
 *             info.suboffsets = NULL
 * 
 *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
 *             info.format = self.view.format
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":485
 * 
 *         if flags & PyBUF_FORMAT:
 *             info.format = self.view.format             # <<<<<<<<<<<<<<
 *         else:
 *             info.format = NULL
 */
    __pyx_t_3 = __pyx_v_self->view.format;
    __pyx_v_info->format = __pyx_t_3;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "View.MemoryView":487
 *             info.format = self.view.format
 *         else:
 *             info.format = NULL             # <<<<<<<<<<<<<<
 * 
 *         info.buf = self.view.buf
 */
    __pyx_v_info->format = NULL;
  }
  __pyx_L6:;

  /* "View.MemoryView":489
 *             info.format = NULL
 * 
 *         info.buf = self.view.buf             # <<<<<<<<<<<<<<
 *         info.ndim = self.view.ndim
 *         info.itemsize = self.view.itemsize
 */
  __pyx_t_4 = __pyx_v_self->view.buf;
  __pyx_v_info->buf = __pyx_t_4;

  /* "View.MemoryView":490
 * 
 *         info.buf = self.view.buf
 *         info.ndim = self.view.ndim             # <<<<<<<<<<<<<<
 *         info.itemsize = self.view.itemsize
 *         info.len = self.view.len
 */
  __pyx_t_5 = __pyx_v_self->view.ndim;
  __pyx_v_info->ndim = __pyx_t_5;

  /* "View.MemoryView":491
 *         info.buf = self.view.buf
 *         info.ndim = self.view.ndim
 *         info.itemsize = self.view.itemsize             # <<<<<<<<<<<<<<
 *         info.len = self.view.len
 *         info.readonly = 0
 */
  __pyx_t_6 = __pyx_v_self->view.itemsize;
  __pyx_v_info->itemsize = __pyx_t_6;

  /* "View.MemoryView":492
 *         info.ndim = self.view.ndim
 *         info.itemsize = self.view.itemsize
 *         info.len = self.view.len             # <<<<<<<<<<<<<<
 *         info.readonly = 0
 *         info.obj = self
 */
  __pyx_t_6 = __pyx_v_self->view.len;
  __pyx_v_info->len = __pyx_t_6;

  /* "View.MemoryView":493
 *         info.itemsize = self.view.itemsize
 *         info.len = self.view.len
 *         info.readonly = 0             # <<<<<<<<<<<<<<
 *         info.obj = self
 * 
 */
  __pyx_v_info->readonly = 0;

  /* "View.MemoryView":494
 *         info.len = self.view.len
 *         info.readonly = 0
 *         info.obj = self             # <<<<<<<<<<<<<<
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __Pyx_GOTREF(__pyx_v_info->obj);
  __Pyx_DECREF(__pyx_v_info->obj);
  __pyx_v_info->obj = ((PyObject *)__pyx_v_self);

  /* "View.MemoryView":468
 * 
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
 *         if flags & PyBUF_STRIDES:
 *             info.shape = self.view.shape
 */

  /* function exit code */
  __pyx_r = 0;
  if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) {
    __Pyx_GOTREF(Py_None);
    __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL;
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":501
 *     property T:
 *         @cname('__pyx_memoryview_transpose')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             cdef _memoryviewslice result = memoryview_copy(self)
 *             transpose_memslice(&result.from_slice)
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_transpose(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_transpose(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview_transpose_MemoryView_10memoryview_1T___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview_transpose_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":502
 *         @cname('__pyx_memoryview_transpose')
 *         def __get__(self):
 *             cdef _memoryviewslice result = memoryview_copy(self)             # <<<<<<<<<<<<<<
 *             transpose_memslice(&result.from_slice)
 *             return result
 */
  __pyx_t_1 = __pyx_memoryview_copy_object(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_memoryviewslice_type))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":503
 *         def __get__(self):
 *             cdef _memoryviewslice result = memoryview_copy(self)
 *             transpose_memslice(&result.from_slice)             # <<<<<<<<<<<<<<
 *             return result
 * 
 */
  __pyx_t_2 = __pyx_memslice_transpose((&__pyx_v_result->from_slice)); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "View.MemoryView":504
 *             cdef _memoryviewslice result = memoryview_copy(self)
 *             transpose_memslice(&result.from_slice)
 *             return result             # <<<<<<<<<<<<<<
 * 
 *     property base:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "View.MemoryView":501
 *     property T:
 *         @cname('__pyx_memoryview_transpose')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             cdef _memoryviewslice result = memoryview_copy(self)
 *             transpose_memslice(&result.from_slice)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.T.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":508
 *     property base:
 *         @cname('__pyx_memoryview__get__base')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.obj
 * 
 */

/* Python wrapper */
static PyObject *__pyx_memoryview__get__base(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview__get__base(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview__get__base_MemoryView_10memoryview_4base___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview__get__base_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":509
 *         @cname('__pyx_memoryview__get__base')
 *         def __get__(self):
 *             return self.obj             # <<<<<<<<<<<<<<
 * 
 *     property shape:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->obj);
  __pyx_r = __pyx_v_self->obj;
  goto __pyx_L0;

  /* "View.MemoryView":508
 *     property base:
 *         @cname('__pyx_memoryview__get__base')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.obj
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":513
 *     property shape:
 *         @cname('__pyx_memoryview_get_shape')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return tuple([self.view.shape[i] for i in xrange(self.view.ndim)])
 * 
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_get_shape(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_shape(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview_get_shape_MemoryView_10memoryview_5shape___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview_get_shape_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":514
 *         @cname('__pyx_memoryview_get_shape')
 *         def __get__(self):
 *             return tuple([self.view.shape[i] for i in xrange(self.view.ndim)])             # <<<<<<<<<<<<<<
 * 
 *     property strides:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_v_self->view.ndim;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;
    __pyx_t_4 = PyInt_FromSsize_t((__pyx_v_self->view.shape[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_t_4 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":513
 *     property shape:
 *         @cname('__pyx_memoryview_get_shape')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return tuple([self.view.shape[i] for i in xrange(self.view.ndim)])
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("View.MemoryView.memoryview.shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":518
 *     property strides:
 *         @cname('__pyx_memoryview_get_strides')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.view.strides == NULL:
 * 
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_get_strides(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_strides(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview_get_strides_MemoryView_10memoryview_7strides___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview_get_strides_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":519
 *         @cname('__pyx_memoryview_get_strides')
 *         def __get__(self):
 *             if self.view.strides == NULL:             # <<<<<<<<<<<<<<
 * 
 *                 raise ValueError("Buffer view does not expose strides")
 */
  __pyx_t_1 = ((__pyx_v_self->view.strides == NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":521
 *             if self.view.strides == NULL:
 * 
 *                 raise ValueError("Buffer view does not expose strides")             # <<<<<<<<<<<<<<
 * 
 *             return tuple([self.view.strides[i] for i in xrange(self.view.ndim)])
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__109, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "View.MemoryView":523
 *                 raise ValueError("Buffer view does not expose strides")
 * 
 *             return tuple([self.view.strides[i] for i in xrange(self.view.ndim)])             # <<<<<<<<<<<<<<
 * 
 *     property suboffsets:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __pyx_v_self->view.ndim;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;
    __pyx_t_5 = PyInt_FromSsize_t((__pyx_v_self->view.strides[__pyx_v_i])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_5))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":518
 *     property strides:
 *         @cname('__pyx_memoryview_get_strides')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.view.strides == NULL:
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView.memoryview.strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":527
 *     property suboffsets:
 *         @cname('__pyx_memoryview_get_suboffsets')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.view.suboffsets == NULL:
 *                 return [-1] * self.view.ndim
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_get_suboffsets(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_suboffsets(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview_get_suboffsets_MemoryView_10memoryview_10suboffsets___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview_get_suboffsets_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":528
 *         @cname('__pyx_memoryview_get_suboffsets')
 *         def __get__(self):
 *             if self.view.suboffsets == NULL:             # <<<<<<<<<<<<<<
 *                 return [-1] * self.view.ndim
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->view.suboffsets == NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":529
 *         def __get__(self):
 *             if self.view.suboffsets == NULL:
 *                 return [-1] * self.view.ndim             # <<<<<<<<<<<<<<
 * 
 *             return tuple([self.view.suboffsets[i] for i in xrange(self.view.ndim)])
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyList_New(1 * ((__pyx_v_self->view.ndim<0) ? 0:__pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    { Py_ssize_t __pyx_temp;
      for (__pyx_temp=0; __pyx_temp < __pyx_v_self->view.ndim; __pyx_temp++) {
        __Pyx_INCREF(__pyx_int_neg_1);
        PyList_SET_ITEM(__pyx_t_2, __pyx_temp, __pyx_int_neg_1);
        __Pyx_GIVEREF(__pyx_int_neg_1);
      }
    }
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "View.MemoryView":531
 *                 return [-1] * self.view.ndim
 * 
 *             return tuple([self.view.suboffsets[i] for i in xrange(self.view.ndim)])             # <<<<<<<<<<<<<<
 * 
 *     property ndim:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __pyx_v_self->view.ndim;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;
    __pyx_t_5 = PyInt_FromSsize_t((__pyx_v_self->view.suboffsets[__pyx_v_i])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_5))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":527
 *     property suboffsets:
 *         @cname('__pyx_memoryview_get_suboffsets')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.view.suboffsets == NULL:
 *                 return [-1] * self.view.ndim
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView.memoryview.suboffsets.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":535
 *     property ndim:
 *         @cname('__pyx_memoryview_get_ndim')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.view.ndim
 * 
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_get_ndim(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_ndim(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview_get_ndim_MemoryView_10memoryview_4ndim___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview_get_ndim_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":536
 *         @cname('__pyx_memoryview_get_ndim')
 *         def __get__(self):
 *             return self.view.ndim             # <<<<<<<<<<<<<<
 * 
 *     property itemsize:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":535
 *     property ndim:
 *         @cname('__pyx_memoryview_get_ndim')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.view.ndim
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.ndim.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":540
 *     property itemsize:
 *         @cname('__pyx_memoryview_get_itemsize')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.view.itemsize
 * 
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_get_itemsize(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_itemsize(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview_get_itemsize_MemoryView_10memoryview_8itemsize___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview_get_itemsize_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":541
 *         @cname('__pyx_memoryview_get_itemsize')
 *         def __get__(self):
 *             return self.view.itemsize             # <<<<<<<<<<<<<<
 * 
 *     property nbytes:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":540
 *     property itemsize:
 *         @cname('__pyx_memoryview_get_itemsize')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.view.itemsize
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.itemsize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":545
 *     property nbytes:
 *         @cname('__pyx_memoryview_get_nbytes')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.size * self.view.itemsize
 * 
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_get_nbytes(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_nbytes(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview_get_nbytes_MemoryView_10memoryview_6nbytes___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview_get_nbytes_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":546
 *         @cname('__pyx_memoryview_get_nbytes')
 *         def __get__(self):
 *             return self.size * self.view.itemsize             # <<<<<<<<<<<<<<
 * 
 *     property size:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":545
 *     property nbytes:
 *         @cname('__pyx_memoryview_get_nbytes')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.size * self.view.itemsize
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.memoryview.nbytes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":550
 *     property size:
 *         @cname('__pyx_memoryview_get_size')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self._size is None:
 *                 result = 1
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_get_size(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_size(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview_get_size_MemoryView_10memoryview_4size___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview_get_size_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_length = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":551
 *         @cname('__pyx_memoryview_get_size')
 *         def __get__(self):
 *             if self._size is None:             # <<<<<<<<<<<<<<
 *                 result = 1
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_size == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":552
 *         def __get__(self):
 *             if self._size is None:
 *                 result = 1             # <<<<<<<<<<<<<<
 * 
 *                 for length in self.shape:
 */
    __Pyx_INCREF(__pyx_int_1);
    __pyx_v_result = __pyx_int_1;

    /* "View.MemoryView":554
 *                 result = 1
 * 
 *                 for length in self.shape:             # <<<<<<<<<<<<<<
 *                     result *= length
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "View.MemoryView":555
 * 
 *                 for length in self.shape:
 *                     result *= length             # <<<<<<<<<<<<<<
 * 
 *                 self._size = result
 */
      __pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_v_result, __pyx_v_length); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "View.MemoryView":554
 *                 result = 1
 * 
 *                 for length in self.shape:             # <<<<<<<<<<<<<<
 *                     result *= length
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "View.MemoryView":557
 *                     result *= length
 * 
 *                 self._size = result             # <<<<<<<<<<<<<<
 * 
 *             return self._size
 */
    __Pyx_INCREF(__pyx_v_result);
    __Pyx_GIVEREF(__pyx_v_result);
    __Pyx_GOTREF(__pyx_v_self->_size);
    __Pyx_DECREF(__pyx_v_self->_size);
    __pyx_v_self->_size = __pyx_v_result;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "View.MemoryView":559
 *                 self._size = result
 * 
 *             return self._size             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_size);
  __pyx_r = __pyx_v_self->_size;
  goto __pyx_L0;

  /* "View.MemoryView":550
 *     property size:
 *         @cname('__pyx_memoryview_get_size')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self._size is None:
 *                 result = 1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("View.MemoryView.memoryview.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_length);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":561
 *             return self._size
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         if self.view.ndim >= 1:
 *             return self.view.shape[0]
 */

/* Python wrapper */
static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview_MemoryView_10memoryview_10__len__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_memoryview_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "View.MemoryView":562
 * 
 *     def __len__(self):
 *         if self.view.ndim >= 1:             # <<<<<<<<<<<<<<
 *             return self.view.shape[0]
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->view.ndim >= 1) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":563
 *     def __len__(self):
 *         if self.view.ndim >= 1:
 *             return self.view.shape[0]             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
    __pyx_r = (__pyx_v_self->view.shape[0]);
    goto __pyx_L0;
  }

  /* "View.MemoryView":565
 *             return self.view.shape[0]
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "View.MemoryView":561
 *             return self._size
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         if self.view.ndim >= 1:
 *             return self.view.shape[0]
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":567
 *         return 0
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
 *                                                id(self))
 */

/* Python wrapper */
static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview_MemoryView_10memoryview_12__repr__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "View.MemoryView":568
 * 
 *     def __repr__(self):
 *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,             # <<<<<<<<<<<<<<
 *                                                id(self))
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "View.MemoryView":569
 *     def __repr__(self):
 *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
 *                                                id(self))             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "View.MemoryView":568
 * 
 *     def __repr__(self):
 *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,             # <<<<<<<<<<<<<<
 *                                                id(self))
 * 
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":567
 *         return 0
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
 *                                                id(self))
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.memoryview.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":571
 *                                                id(self))
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview_MemoryView_10memoryview_14__str__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "View.MemoryView":572
 * 
 *     def __str__(self):
 *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_object, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":571
 *                                                id(self))
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.memoryview.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":575
 * 
 * 
 *     def is_c_contig(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice *mslice
 *         cdef __Pyx_memviewslice tmp
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_c_contig (wrapper)", 0);
  __pyx_r = __pyx_memoryview_MemoryView_10memoryview_16is_c_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
  __Pyx_memviewslice *__pyx_v_mslice;
  __Pyx_memviewslice __pyx_v_tmp;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_c_contig", 0);

  /* "View.MemoryView":578
 *         cdef __Pyx_memviewslice *mslice
 *         cdef __Pyx_memviewslice tmp
 *         mslice = get_slice_from_memview(self, &tmp)             # <<<<<<<<<<<<<<
 *         return slice_is_contig(mslice, 'C', self.view.ndim)
 * 
 */
  __pyx_v_mslice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp));

  /* "View.MemoryView":579
 *         cdef __Pyx_memviewslice tmp
 *         mslice = get_slice_from_memview(self, &tmp)
 *         return slice_is_contig(mslice, 'C', self.view.ndim)             # <<<<<<<<<<<<<<
 * 
 *     def is_f_contig(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig(__pyx_v_mslice, 'C', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":575
 * 
 * 
 *     def is_c_contig(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice *mslice
 *         cdef __Pyx_memviewslice tmp
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.is_c_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":581
 *         return slice_is_contig(mslice, 'C', self.view.ndim)
 * 
 *     def is_f_contig(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice *mslice
 *         cdef __Pyx_memviewslice tmp
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_f_contig (wrapper)", 0);
  __pyx_r = __pyx_memoryview_MemoryView_10memoryview_18is_f_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
  __Pyx_memviewslice *__pyx_v_mslice;
  __Pyx_memviewslice __pyx_v_tmp;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_f_contig", 0);

  /* "View.MemoryView":584
 *         cdef __Pyx_memviewslice *mslice
 *         cdef __Pyx_memviewslice tmp
 *         mslice = get_slice_from_memview(self, &tmp)             # <<<<<<<<<<<<<<
 *         return slice_is_contig(mslice, 'F', self.view.ndim)
 * 
 */
  __pyx_v_mslice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp));

  /* "View.MemoryView":585
 *         cdef __Pyx_memviewslice tmp
 *         mslice = get_slice_from_memview(self, &tmp)
 *         return slice_is_contig(mslice, 'F', self.view.ndim)             # <<<<<<<<<<<<<<
 * 
 *     def copy(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig(__pyx_v_mslice, 'F', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":581
 *         return slice_is_contig(mslice, 'C', self.view.ndim)
 * 
 *     def is_f_contig(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice *mslice
 *         cdef __Pyx_memviewslice tmp
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.is_f_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":587
 *         return slice_is_contig(mslice, 'F', self.view.ndim)
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice mslice
 *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy (wrapper)", 0);
  __pyx_r = __pyx_memoryview_MemoryView_10memoryview_20copy(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self) {
  __Pyx_memviewslice __pyx_v_mslice;
  int __pyx_v_flags;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_memviewslice __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("copy", 0);

  /* "View.MemoryView":589
 *     def copy(self):
 *         cdef __Pyx_memviewslice mslice
 *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS             # <<<<<<<<<<<<<<
 * 
 *         slice_copy(self, &mslice)
 */
  __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_F_CONTIGUOUS));

  /* "View.MemoryView":591
 *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
 * 
 *         slice_copy(self, &mslice)             # <<<<<<<<<<<<<<
 *         mslice = slice_copy_contig(&mslice, "c", self.view.ndim,
 *                                    self.view.itemsize,
 */
  __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_mslice));

  /* "View.MemoryView":592
 * 
 *         slice_copy(self, &mslice)
 *         mslice = slice_copy_contig(&mslice, "c", self.view.ndim,             # <<<<<<<<<<<<<<
 *                                    self.view.itemsize,
 *                                    flags|PyBUF_C_CONTIGUOUS,
 */
  __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_mslice), __pyx_k_c, __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_C_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_mslice = __pyx_t_1;

  /* "View.MemoryView":597
 *                                    self.dtype_is_object)
 * 
 *         return memoryview_copy_from_slice(self, &mslice)             # <<<<<<<<<<<<<<
 * 
 *     def copy_fortran(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_mslice)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":587
 *         return slice_is_contig(mslice, 'F', self.view.ndim)
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice mslice
 *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.memoryview.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":599
 *         return memoryview_copy_from_slice(self, &mslice)
 * 
 *     def copy_fortran(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice src, dst
 *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy_fortran (wrapper)", 0);
  __pyx_r = __pyx_memoryview_MemoryView_10memoryview_22copy_fortran(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self) {
  __Pyx_memviewslice __pyx_v_src;
  __Pyx_memviewslice __pyx_v_dst;
  int __pyx_v_flags;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_memviewslice __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("copy_fortran", 0);

  /* "View.MemoryView":601
 *     def copy_fortran(self):
 *         cdef __Pyx_memviewslice src, dst
 *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS             # <<<<<<<<<<<<<<
 * 
 *         slice_copy(self, &src)
 */
  __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_C_CONTIGUOUS));

  /* "View.MemoryView":603
 *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
 * 
 *         slice_copy(self, &src)             # <<<<<<<<<<<<<<
 *         dst = slice_copy_contig(&src, "fortran", self.view.ndim,
 *                                 self.view.itemsize,
 */
  __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_src));

  /* "View.MemoryView":604
 * 
 *         slice_copy(self, &src)
 *         dst = slice_copy_contig(&src, "fortran", self.view.ndim,             # <<<<<<<<<<<<<<
 *                                 self.view.itemsize,
 *                                 flags|PyBUF_F_CONTIGUOUS,
 */
  __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_src), __pyx_k_fortran, __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_F_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_dst = __pyx_t_1;

  /* "View.MemoryView":609
 *                                 self.dtype_is_object)
 * 
 *         return memoryview_copy_from_slice(self, &dst)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_dst)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":599
 *         return memoryview_copy_from_slice(self, &mslice)
 * 
 *     def copy_fortran(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice src, dst
 *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.memoryview.copy_fortran", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":613
 * 
 * @cname('__pyx_memoryview_new')
 * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):             # <<<<<<<<<<<<<<
 *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
 *     result.typeinfo = typeinfo
 */

static PyObject *__pyx_memoryview_new(PyObject *__pyx_v_o, int __pyx_v_flags, int __pyx_v_dtype_is_object, __Pyx_TypeInfo *__pyx_v_typeinfo) {
  struct __pyx_memoryview_obj *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("memoryview_cwrapper", 0);

  /* "View.MemoryView":614
 * @cname('__pyx_memoryview_new')
 * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
 *     cdef memoryview result = memoryview(o, flags, dtype_is_object)             # <<<<<<<<<<<<<<
 *     result.typeinfo = typeinfo
 *     return result
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_o);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o);
  __Pyx_GIVEREF(__pyx_v_o);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_memoryview_type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_result = ((struct __pyx_memoryview_obj *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "View.MemoryView":615
 * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
 *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
 *     result.typeinfo = typeinfo             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
  __pyx_v_result->typeinfo = __pyx_v_typeinfo;

  /* "View.MemoryView":616
 *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
 *     result.typeinfo = typeinfo
 *     return result             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_check')
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "View.MemoryView":613
 * 
 * @cname('__pyx_memoryview_new')
 * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):             # <<<<<<<<<<<<<<
 *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
 *     result.typeinfo = typeinfo
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.memoryview_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":619
 * 
 * @cname('__pyx_memoryview_check')
 * cdef inline bint memoryview_check(object o):             # <<<<<<<<<<<<<<
 *     return isinstance(o, memoryview)
 * 
 */

static CYTHON_INLINE int __pyx_memoryview_check(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("memoryview_check", 0);

  /* "View.MemoryView":620
 * @cname('__pyx_memoryview_check')
 * cdef inline bint memoryview_check(object o):
 *     return isinstance(o, memoryview)             # <<<<<<<<<<<<<<
 * 
 * cdef tuple _unellipsify(object index, int ndim):
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_o, ((PyObject *)__pyx_memoryview_type)); 
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* "View.MemoryView":619
 * 
 * @cname('__pyx_memoryview_check')
 * cdef inline bint memoryview_check(object o):             # <<<<<<<<<<<<<<
 *     return isinstance(o, memoryview)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":622
 *     return isinstance(o, memoryview)
 * 
 * cdef tuple _unellipsify(object index, int ndim):             # <<<<<<<<<<<<<<
 *     """
 *     Replace all ellipses with full slices and fill incomplete indices with
 */

static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) {
  PyObject *__pyx_v_tup = NULL;
  PyObject *__pyx_v_result = NULL;
  int __pyx_v_have_slices;
  int __pyx_v_seen_ellipsis;
  CYTHON_UNUSED PyObject *__pyx_v_idx = NULL;
  PyObject *__pyx_v_item = NULL;
  Py_ssize_t __pyx_v_nslices;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_unellipsify", 0);

  /* "View.MemoryView":627
 *     full slices.
 *     """
 *     if not isinstance(index, tuple):             # <<<<<<<<<<<<<<
 *         tup = (index,)
 *     else:
 */
  __pyx_t_1 = PyTuple_Check(__pyx_v_index); 
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":628
 *     """
 *     if not isinstance(index, tuple):
 *         tup = (index,)             # <<<<<<<<<<<<<<
 *     else:
 *         tup = index
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_index);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_index);
    __Pyx_GIVEREF(__pyx_v_index);
    __pyx_v_tup = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "View.MemoryView":630
 *         tup = (index,)
 *     else:
 *         tup = index             # <<<<<<<<<<<<<<
 * 
 *     result = []
 */
    __Pyx_INCREF(__pyx_v_index);
    __pyx_v_tup = __pyx_v_index;
  }
  __pyx_L3:;

  /* "View.MemoryView":632
 *         tup = index
 * 
 *     result = []             # <<<<<<<<<<<<<<
 *     have_slices = False
 *     seen_ellipsis = False
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_result = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "View.MemoryView":633
 * 
 *     result = []
 *     have_slices = False             # <<<<<<<<<<<<<<
 *     seen_ellipsis = False
 *     for idx, item in enumerate(tup):
 */
  __pyx_v_have_slices = 0;

  /* "View.MemoryView":634
 *     result = []
 *     have_slices = False
 *     seen_ellipsis = False             # <<<<<<<<<<<<<<
 *     for idx, item in enumerate(tup):
 *         if item is Ellipsis:
 */
  __pyx_v_seen_ellipsis = 0;

  /* "View.MemoryView":635
 *     have_slices = False
 *     seen_ellipsis = False
 *     for idx, item in enumerate(tup):             # <<<<<<<<<<<<<<
 *         if item is Ellipsis:
 *             if not seen_ellipsis:
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_3 = __pyx_int_0;
  if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) {
    __pyx_t_4 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_7 = __pyx_t_6(__pyx_t_4);
      if (unlikely(!__pyx_t_7)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_7);
    }
    __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7);
    __pyx_t_7 = 0;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_3);
    __pyx_t_7 = PyNumber_Add(__pyx_t_3, __pyx_int_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_3 = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "View.MemoryView":636
 *     seen_ellipsis = False
 *     for idx, item in enumerate(tup):
 *         if item is Ellipsis:             # <<<<<<<<<<<<<<
 *             if not seen_ellipsis:
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
 */
    __pyx_t_2 = (__pyx_v_item == __pyx_builtin_Ellipsis);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":637
 *     for idx, item in enumerate(tup):
 *         if item is Ellipsis:
 *             if not seen_ellipsis:             # <<<<<<<<<<<<<<
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
 *                 seen_ellipsis = True
 */
      __pyx_t_1 = ((!(__pyx_v_seen_ellipsis != 0)) != 0);
      if (__pyx_t_1) {

        /* "View.MemoryView":638
 *         if item is Ellipsis:
 *             if not seen_ellipsis:
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))             # <<<<<<<<<<<<<<
 *                 seen_ellipsis = True
 *             else:
 */
        __pyx_t_8 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_7 = PyList_New(1 * ((((__pyx_v_ndim - __pyx_t_8) + 1)<0) ? 0:((__pyx_v_ndim - __pyx_t_8) + 1))); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        { Py_ssize_t __pyx_temp;
          for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) {
            __Pyx_INCREF(__pyx_slice__110);
            PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__110);
            __Pyx_GIVEREF(__pyx_slice__110);
          }
        }
        __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "View.MemoryView":639
 *             if not seen_ellipsis:
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
 *                 seen_ellipsis = True             # <<<<<<<<<<<<<<
 *             else:
 *                 result.append(slice(None))
 */
        __pyx_v_seen_ellipsis = 1;
        goto __pyx_L7;
      }
      /*else*/ {

        /* "View.MemoryView":641
 *                 seen_ellipsis = True
 *             else:
 *                 result.append(slice(None))             # <<<<<<<<<<<<<<
 *             have_slices = True
 *         else:
 */
        __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__111); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L7:;

      /* "View.MemoryView":642
 *             else:
 *                 result.append(slice(None))
 *             have_slices = True             # <<<<<<<<<<<<<<
 *         else:
 *             if not isinstance(item, slice) and not PyIndex_Check(item):
 */
      __pyx_v_have_slices = 1;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "View.MemoryView":644
 *             have_slices = True
 *         else:
 *             if not isinstance(item, slice) and not PyIndex_Check(item):             # <<<<<<<<<<<<<<
 *                 raise TypeError("Cannot index with type '%s'" % type(item))
 * 
 */
      __pyx_t_2 = PySlice_Check(__pyx_v_item); 
      __pyx_t_10 = ((!(__pyx_t_2 != 0)) != 0);
      if (__pyx_t_10) {
      } else {
        __pyx_t_1 = __pyx_t_10;
        goto __pyx_L9_bool_binop_done;
      }
      __pyx_t_10 = ((!(PyIndex_Check(__pyx_v_item) != 0)) != 0);
      __pyx_t_1 = __pyx_t_10;
      __pyx_L9_bool_binop_done:;
      if (__pyx_t_1) {

        /* "View.MemoryView":645
 *         else:
 *             if not isinstance(item, slice) and not PyIndex_Check(item):
 *                 raise TypeError("Cannot index with type '%s'" % type(item))             # <<<<<<<<<<<<<<
 * 
 *             have_slices = have_slices or isinstance(item, slice)
 */
        __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Cannot_index_with_type_s, ((PyObject *)Py_TYPE(__pyx_v_item))); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_7);
        __pyx_t_7 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_Raise(__pyx_t_7, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        {__pyx_filename = __pyx_f[2]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }

      /* "View.MemoryView":647
 *                 raise TypeError("Cannot index with type '%s'" % type(item))
 * 
 *             have_slices = have_slices or isinstance(item, slice)             # <<<<<<<<<<<<<<
 *             result.append(item)
 * 
 */
      __pyx_t_10 = (__pyx_v_have_slices != 0);
      if (!__pyx_t_10) {
      } else {
        __pyx_t_1 = __pyx_t_10;
        goto __pyx_L11_bool_binop_done;
      }
      __pyx_t_10 = PySlice_Check(__pyx_v_item); 
      __pyx_t_2 = (__pyx_t_10 != 0);
      __pyx_t_1 = __pyx_t_2;
      __pyx_L11_bool_binop_done:;
      __pyx_v_have_slices = __pyx_t_1;

      /* "View.MemoryView":648
 * 
 *             have_slices = have_slices or isinstance(item, slice)
 *             result.append(item)             # <<<<<<<<<<<<<<
 * 
 *     nslices = ndim - len(result)
 */
      __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_item); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L6:;

    /* "View.MemoryView":635
 *     have_slices = False
 *     seen_ellipsis = False
 *     for idx, item in enumerate(tup):             # <<<<<<<<<<<<<<
 *         if item is Ellipsis:
 *             if not seen_ellipsis:
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "View.MemoryView":650
 *             result.append(item)
 * 
 *     nslices = ndim - len(result)             # <<<<<<<<<<<<<<
 *     if nslices:
 *         result.extend([slice(None)] * nslices)
 */
  __pyx_t_5 = PyList_GET_SIZE(__pyx_v_result); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_nslices = (__pyx_v_ndim - __pyx_t_5);

  /* "View.MemoryView":651
 * 
 *     nslices = ndim - len(result)
 *     if nslices:             # <<<<<<<<<<<<<<
 *         result.extend([slice(None)] * nslices)
 * 
 */
  __pyx_t_1 = (__pyx_v_nslices != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":652
 *     nslices = ndim - len(result)
 *     if nslices:
 *         result.extend([slice(None)] * nslices)             # <<<<<<<<<<<<<<
 * 
 *     return have_slices or nslices, tuple(result)
 */
    __pyx_t_3 = PyList_New(1 * ((__pyx_v_nslices<0) ? 0:__pyx_v_nslices)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    { Py_ssize_t __pyx_temp;
      for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) {
        __Pyx_INCREF(__pyx_slice__112);
        PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__112);
        __Pyx_GIVEREF(__pyx_slice__112);
      }
    }
    __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "View.MemoryView":654
 *         result.extend([slice(None)] * nslices)
 * 
 *     return have_slices or nslices, tuple(result)             # <<<<<<<<<<<<<<
 * 
 * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
 */
  __Pyx_XDECREF(__pyx_r);
  if (!__pyx_v_have_slices) {
  } else {
    __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_have_slices); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L14_bool_binop_done;
  }
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_nslices); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_L14_bool_binop_done:;
  __pyx_t_4 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_r = ((PyObject*)__pyx_t_7);
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":622
 *     return isinstance(o, memoryview)
 * 
 * cdef tuple _unellipsify(object index, int ndim):             # <<<<<<<<<<<<<<
 *     """
 *     Replace all ellipses with full slices and fill incomplete indices with
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("View.MemoryView._unellipsify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_tup);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_idx);
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":656
 *     return have_slices or nslices, tuple(result)
 * 
 * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):             # <<<<<<<<<<<<<<
 *     cdef int i
 *     for i in range(ndim):
 */

static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __pyx_v_ndim) {
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("assert_direct_dimensions", 0);

  /* "View.MemoryView":658
 * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
 *     cdef int i
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         if suboffsets[i] >= 0:
 *             raise ValueError("Indirect dimensions not supported")
 */
  __pyx_t_1 = __pyx_v_ndim;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "View.MemoryView":659
 *     cdef int i
 *     for i in range(ndim):
 *         if suboffsets[i] >= 0:             # <<<<<<<<<<<<<<
 *             raise ValueError("Indirect dimensions not supported")
 * 
 */
    __pyx_t_3 = (((__pyx_v_suboffsets[__pyx_v_i]) >= 0) != 0);
    if (__pyx_t_3) {

      /* "View.MemoryView":660
 *     for i in range(ndim):
 *         if suboffsets[i] >= 0:
 *             raise ValueError("Indirect dimensions not supported")             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__113, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }

  /* "View.MemoryView":656
 *     return have_slices or nslices, tuple(result)
 * 
 * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):             # <<<<<<<<<<<<<<
 *     cdef int i
 *     for i in range(ndim):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("View.MemoryView.assert_direct_dimensions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":667
 * 
 * @cname('__pyx_memview_slice')
 * cdef memoryview memview_slice(memoryview memview, object indices):             # <<<<<<<<<<<<<<
 *     cdef int new_ndim = 0, suboffset_dim = -1, dim
 *     cdef bint negative_step
 */

static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *__pyx_v_memview, PyObject *__pyx_v_indices) {
  int __pyx_v_new_ndim;
  int __pyx_v_suboffset_dim;
  int __pyx_v_dim;
  __Pyx_memviewslice __pyx_v_src;
  __Pyx_memviewslice __pyx_v_dst;
  __Pyx_memviewslice *__pyx_v_p_src;
  struct __pyx_memoryviewslice_obj *__pyx_v_memviewsliceobj = 0;
  __Pyx_memviewslice *__pyx_v_p_dst;
  int *__pyx_v_p_suboffset_dim;
  Py_ssize_t __pyx_v_start;
  Py_ssize_t __pyx_v_stop;
  Py_ssize_t __pyx_v_step;
  int __pyx_v_have_start;
  int __pyx_v_have_stop;
  int __pyx_v_have_step;
  PyObject *__pyx_v_index = NULL;
  struct __pyx_memoryview_obj *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  struct __pyx_memoryview_obj *__pyx_t_4;
  char *__pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  int __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("memview_slice", 0);

  /* "View.MemoryView":668
 * @cname('__pyx_memview_slice')
 * cdef memoryview memview_slice(memoryview memview, object indices):
 *     cdef int new_ndim = 0, suboffset_dim = -1, dim             # <<<<<<<<<<<<<<
 *     cdef bint negative_step
 *     cdef __Pyx_memviewslice src, dst
 */
  __pyx_v_new_ndim = 0;
  __pyx_v_suboffset_dim = -1;

  /* "View.MemoryView":675
 * 
 * 
 *     memset(&dst, 0, sizeof(dst))             # <<<<<<<<<<<<<<
 * 
 *     cdef _memoryviewslice memviewsliceobj
 */
  memset((&__pyx_v_dst), 0, (sizeof(__pyx_v_dst)));

  /* "View.MemoryView":679
 *     cdef _memoryviewslice memviewsliceobj
 * 
 *     assert memview.view.ndim > 0             # <<<<<<<<<<<<<<
 * 
 *     if isinstance(memview, _memoryviewslice):
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_memview->view.ndim > 0) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "View.MemoryView":681
 *     assert memview.view.ndim > 0
 * 
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         memviewsliceobj = memview
 *         p_src = &memviewsliceobj.from_slice
 */
  __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), ((PyObject *)__pyx_memoryviewslice_type)); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":682
 * 
 *     if isinstance(memview, _memoryviewslice):
 *         memviewsliceobj = memview             # <<<<<<<<<<<<<<
 *         p_src = &memviewsliceobj.from_slice
 *     else:
 */
    if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = ((PyObject *)__pyx_v_memview);
    __Pyx_INCREF(__pyx_t_3);
    __pyx_v_memviewsliceobj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "View.MemoryView":683
 *     if isinstance(memview, _memoryviewslice):
 *         memviewsliceobj = memview
 *         p_src = &memviewsliceobj.from_slice             # <<<<<<<<<<<<<<
 *     else:
 *         slice_copy(memview, &src)
 */
    __pyx_v_p_src = (&__pyx_v_memviewsliceobj->from_slice);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "View.MemoryView":685
 *         p_src = &memviewsliceobj.from_slice
 *     else:
 *         slice_copy(memview, &src)             # <<<<<<<<<<<<<<
 *         p_src = &src
 * 
 */
    __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_src));

    /* "View.MemoryView":686
 *     else:
 *         slice_copy(memview, &src)
 *         p_src = &src             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_v_p_src = (&__pyx_v_src);
  }
  __pyx_L3:;

  /* "View.MemoryView":692
 * 
 * 
 *     dst.memview = p_src.memview             # <<<<<<<<<<<<<<
 *     dst.data = p_src.data
 * 
 */
  __pyx_t_4 = __pyx_v_p_src->memview;
  __pyx_v_dst.memview = __pyx_t_4;

  /* "View.MemoryView":693
 * 
 *     dst.memview = p_src.memview
 *     dst.data = p_src.data             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = __pyx_v_p_src->data;
  __pyx_v_dst.data = __pyx_t_5;

  /* "View.MemoryView":698
 * 
 * 
 *     cdef __Pyx_memviewslice *p_dst = &dst             # <<<<<<<<<<<<<<
 *     cdef int *p_suboffset_dim = &suboffset_dim
 *     cdef Py_ssize_t start, stop, step
 */
  __pyx_v_p_dst = (&__pyx_v_dst);

  /* "View.MemoryView":699
 * 
 *     cdef __Pyx_memviewslice *p_dst = &dst
 *     cdef int *p_suboffset_dim = &suboffset_dim             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t start, stop, step
 *     cdef bint have_start, have_stop, have_step
 */
  __pyx_v_p_suboffset_dim = (&__pyx_v_suboffset_dim);

  /* "View.MemoryView":703
 *     cdef bint have_start, have_stop, have_step
 * 
 *     for dim, index in enumerate(indices):             # <<<<<<<<<<<<<<
 *         if PyIndex_Check(index):
 *             slice_memviewslice(
 */
  __pyx_t_6 = 0;
  if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) {
    __pyx_t_3 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      }
    } else {
      __pyx_t_9 = __pyx_t_8(__pyx_t_3);
      if (unlikely(!__pyx_t_9)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_9);
    }
    __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_v_dim = __pyx_t_6;
    __pyx_t_6 = (__pyx_t_6 + 1);

    /* "View.MemoryView":704
 * 
 *     for dim, index in enumerate(indices):
 *         if PyIndex_Check(index):             # <<<<<<<<<<<<<<
 *             slice_memviewslice(
 *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
 */
    __pyx_t_2 = (PyIndex_Check(__pyx_v_index) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":708
 *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
 *                 dim, new_ndim, p_suboffset_dim,
 *                 index, 0, 0, # start, stop, step             # <<<<<<<<<<<<<<
 *                 0, 0, 0, # have_{start,stop,step}
 *                 False)
 */
      __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_index); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "View.MemoryView":705
 *     for dim, index in enumerate(indices):
 *         if PyIndex_Check(index):
 *             slice_memviewslice(             # <<<<<<<<<<<<<<
 *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
 *                 dim, new_ndim, p_suboffset_dim,
 */
      __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_t_10, 0, 0, 0, 0, 0, 0); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L6;
    }

    /* "View.MemoryView":711
 *                 0, 0, 0, # have_{start,stop,step}
 *                 False)
 *         elif index is None:             # <<<<<<<<<<<<<<
 *             p_dst.shape[new_ndim] = 1
 *             p_dst.strides[new_ndim] = 0
 */
    __pyx_t_2 = (__pyx_v_index == Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":712
 *                 False)
 *         elif index is None:
 *             p_dst.shape[new_ndim] = 1             # <<<<<<<<<<<<<<
 *             p_dst.strides[new_ndim] = 0
 *             p_dst.suboffsets[new_ndim] = -1
 */
      (__pyx_v_p_dst->shape[__pyx_v_new_ndim]) = 1;

      /* "View.MemoryView":713
 *         elif index is None:
 *             p_dst.shape[new_ndim] = 1
 *             p_dst.strides[new_ndim] = 0             # <<<<<<<<<<<<<<
 *             p_dst.suboffsets[new_ndim] = -1
 *             new_ndim += 1
 */
      (__pyx_v_p_dst->strides[__pyx_v_new_ndim]) = 0;

      /* "View.MemoryView":714
 *             p_dst.shape[new_ndim] = 1
 *             p_dst.strides[new_ndim] = 0
 *             p_dst.suboffsets[new_ndim] = -1             # <<<<<<<<<<<<<<
 *             new_ndim += 1
 *         else:
 */
      (__pyx_v_p_dst->suboffsets[__pyx_v_new_ndim]) = -1;

      /* "View.MemoryView":715
 *             p_dst.strides[new_ndim] = 0
 *             p_dst.suboffsets[new_ndim] = -1
 *             new_ndim += 1             # <<<<<<<<<<<<<<
 *         else:
 *             start = index.start or 0
 */
      __pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
      goto __pyx_L6;
    }
    /*else*/ {

      /* "View.MemoryView":717
 *             new_ndim += 1
 *         else:
 *             start = index.start or 0             # <<<<<<<<<<<<<<
 *             stop = index.stop or 0
 *             step = index.step or 0
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (!__pyx_t_1) {
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_10 = __pyx_t_12;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L7_bool_binop_done;
      }
      __pyx_t_10 = 0;
      __pyx_L7_bool_binop_done:;
      __pyx_v_start = __pyx_t_10;

      /* "View.MemoryView":718
 *         else:
 *             start = index.start or 0
 *             stop = index.stop or 0             # <<<<<<<<<<<<<<
 *             step = index.step or 0
 * 
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (!__pyx_t_1) {
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_10 = __pyx_t_12;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L9_bool_binop_done;
      }
      __pyx_t_10 = 0;
      __pyx_L9_bool_binop_done:;
      __pyx_v_stop = __pyx_t_10;

      /* "View.MemoryView":719
 *             start = index.start or 0
 *             stop = index.stop or 0
 *             step = index.step or 0             # <<<<<<<<<<<<<<
 * 
 *             have_start = index.start is not None
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (!__pyx_t_1) {
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_10 = __pyx_t_12;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L11_bool_binop_done;
      }
      __pyx_t_10 = 0;
      __pyx_L11_bool_binop_done:;
      __pyx_v_step = __pyx_t_10;

      /* "View.MemoryView":721
 *             step = index.step or 0
 * 
 *             have_start = index.start is not None             # <<<<<<<<<<<<<<
 *             have_stop = index.stop is not None
 *             have_step = index.step is not None
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = (__pyx_t_9 != Py_None);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_v_have_start = __pyx_t_1;

      /* "View.MemoryView":722
 * 
 *             have_start = index.start is not None
 *             have_stop = index.stop is not None             # <<<<<<<<<<<<<<
 *             have_step = index.step is not None
 * 
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = (__pyx_t_9 != Py_None);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_v_have_stop = __pyx_t_1;

      /* "View.MemoryView":723
 *             have_start = index.start is not None
 *             have_stop = index.stop is not None
 *             have_step = index.step is not None             # <<<<<<<<<<<<<<
 * 
 *             slice_memviewslice(
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = (__pyx_t_9 != Py_None);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_v_have_step = __pyx_t_1;

      /* "View.MemoryView":725
 *             have_step = index.step is not None
 * 
 *             slice_memviewslice(             # <<<<<<<<<<<<<<
 *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
 *                 dim, new_ndim, p_suboffset_dim,
 */
      __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_v_start, __pyx_v_stop, __pyx_v_step, __pyx_v_have_start, __pyx_v_have_stop, __pyx_v_have_step, 1); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "View.MemoryView":731
 *                 have_start, have_stop, have_step,
 *                 True)
 *             new_ndim += 1             # <<<<<<<<<<<<<<
 * 
 *     if isinstance(memview, _memoryviewslice):
 */
      __pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
    }
    __pyx_L6:;

    /* "View.MemoryView":703
 *     cdef bint have_start, have_stop, have_step
 * 
 *     for dim, index in enumerate(indices):             # <<<<<<<<<<<<<<
 *         if PyIndex_Check(index):
 *             slice_memviewslice(
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "View.MemoryView":733
 *             new_ndim += 1
 * 
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         return memoryview_fromslice(dst, new_ndim,
 *                                     memviewsliceobj.to_object_func,
 */
  __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), ((PyObject *)__pyx_memoryviewslice_type)); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":734
 * 
 *     if isinstance(memview, _memoryviewslice):
 *         return memoryview_fromslice(dst, new_ndim,             # <<<<<<<<<<<<<<
 *                                     memviewsliceobj.to_object_func,
 *                                     memviewsliceobj.to_dtype_func,
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));

    /* "View.MemoryView":735
 *     if isinstance(memview, _memoryviewslice):
 *         return memoryview_fromslice(dst, new_ndim,
 *                                     memviewsliceobj.to_object_func,             # <<<<<<<<<<<<<<
 *                                     memviewsliceobj.to_dtype_func,
 *                                     memview.dtype_is_object)
 */
    if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }

    /* "View.MemoryView":736
 *         return memoryview_fromslice(dst, new_ndim,
 *                                     memviewsliceobj.to_object_func,
 *                                     memviewsliceobj.to_dtype_func,             # <<<<<<<<<<<<<<
 *                                     memview.dtype_is_object)
 *     else:
 */
    if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }

    /* "View.MemoryView":734
 * 
 *     if isinstance(memview, _memoryviewslice):
 *         return memoryview_fromslice(dst, new_ndim,             # <<<<<<<<<<<<<<
 *                                     memviewsliceobj.to_object_func,
 *                                     memviewsliceobj.to_dtype_func,
 */
    __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, __pyx_v_memviewsliceobj->to_object_func, __pyx_v_memviewsliceobj->to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "View.MemoryView":739
 *                                     memview.dtype_is_object)
 *     else:
 *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,             # <<<<<<<<<<<<<<
 *                                     memview.dtype_is_object)
 * 
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));

    /* "View.MemoryView":740
 *     else:
 *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,
 *                                     memview.dtype_is_object)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, NULL, NULL, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);

    /* "View.MemoryView":739
 *                                     memview.dtype_is_object)
 *     else:
 *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,             # <<<<<<<<<<<<<<
 *                                     memview.dtype_is_object)
 * 
 */
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "View.MemoryView":667
 * 
 * @cname('__pyx_memview_slice')
 * cdef memoryview memview_slice(memoryview memview, object indices):             # <<<<<<<<<<<<<<
 *     cdef int new_ndim = 0, suboffset_dim = -1, dim
 *     cdef bint negative_step
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("View.MemoryView.memview_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_memviewsliceobj);
  __Pyx_XDECREF(__pyx_v_index);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":764
 * 
 * @cname('__pyx_memoryview_slice_memviewslice')
 * cdef int slice_memviewslice(             # <<<<<<<<<<<<<<
 *         __Pyx_memviewslice *dst,
 *         Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
 */

static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, Py_ssize_t __pyx_v_shape, Py_ssize_t __pyx_v_stride, Py_ssize_t __pyx_v_suboffset, int __pyx_v_dim, int __pyx_v_new_ndim, int *__pyx_v_suboffset_dim, Py_ssize_t __pyx_v_start, Py_ssize_t __pyx_v_stop, Py_ssize_t __pyx_v_step, int __pyx_v_have_start, int __pyx_v_have_stop, int __pyx_v_have_step, int __pyx_v_is_slice) {
  Py_ssize_t __pyx_v_new_shape;
  int __pyx_v_negative_step;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "View.MemoryView":784
 *     cdef bint negative_step
 * 
 *     if not is_slice:             # <<<<<<<<<<<<<<
 * 
 *         if start < 0:
 */
  __pyx_t_1 = ((!(__pyx_v_is_slice != 0)) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":786
 *     if not is_slice:
 * 
 *         if start < 0:             # <<<<<<<<<<<<<<
 *             start += shape
 *         if not 0 <= start < shape:
 */
    __pyx_t_1 = ((__pyx_v_start < 0) != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":787
 * 
 *         if start < 0:
 *             start += shape             # <<<<<<<<<<<<<<
 *         if not 0 <= start < shape:
 *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
 */
      __pyx_v_start = (__pyx_v_start + __pyx_v_shape);
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "View.MemoryView":788
 *         if start < 0:
 *             start += shape
 *         if not 0 <= start < shape:             # <<<<<<<<<<<<<<
 *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
 *     else:
 */
    __pyx_t_1 = (0 <= __pyx_v_start);
    if (__pyx_t_1) {
      __pyx_t_1 = (__pyx_v_start < __pyx_v_shape);
    }
    __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":789
 *             start += shape
 *         if not 0 <= start < shape:
 *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)             # <<<<<<<<<<<<<<
 *     else:
 * 
 */
      __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, __pyx_k_Index_out_of_bounds_axis_d, __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "View.MemoryView":792
 *     else:
 * 
 *         negative_step = have_step != 0 and step < 0             # <<<<<<<<<<<<<<
 * 
 *         if have_step and step == 0:
 */
    __pyx_t_1 = ((__pyx_v_have_step != 0) != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_1 = ((__pyx_v_step < 0) != 0);
    __pyx_t_2 = __pyx_t_1;
    __pyx_L6_bool_binop_done:;
    __pyx_v_negative_step = __pyx_t_2;

    /* "View.MemoryView":794
 *         negative_step = have_step != 0 and step < 0
 * 
 *         if have_step and step == 0:             # <<<<<<<<<<<<<<
 *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
 * 
 */
    __pyx_t_1 = (__pyx_v_have_step != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L9_bool_binop_done;
    }
    __pyx_t_1 = ((__pyx_v_step == 0) != 0);
    __pyx_t_2 = __pyx_t_1;
    __pyx_L9_bool_binop_done:;
    if (__pyx_t_2) {

      /* "View.MemoryView":795
 * 
 *         if have_step and step == 0:
 *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, __pyx_k_Step_may_not_be_zero_axis_d, __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "View.MemoryView":798
 * 
 * 
 *         if have_start:             # <<<<<<<<<<<<<<
 *             if start < 0:
 *                 start += shape
 */
    __pyx_t_2 = (__pyx_v_have_start != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":799
 * 
 *         if have_start:
 *             if start < 0:             # <<<<<<<<<<<<<<
 *                 start += shape
 *                 if start < 0:
 */
      __pyx_t_2 = ((__pyx_v_start < 0) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":800
 *         if have_start:
 *             if start < 0:
 *                 start += shape             # <<<<<<<<<<<<<<
 *                 if start < 0:
 *                     start = 0
 */
        __pyx_v_start = (__pyx_v_start + __pyx_v_shape);

        /* "View.MemoryView":801
 *             if start < 0:
 *                 start += shape
 *                 if start < 0:             # <<<<<<<<<<<<<<
 *                     start = 0
 *             elif start >= shape:
 */
        __pyx_t_2 = ((__pyx_v_start < 0) != 0);
        if (__pyx_t_2) {

          /* "View.MemoryView":802
 *                 start += shape
 *                 if start < 0:
 *                     start = 0             # <<<<<<<<<<<<<<
 *             elif start >= shape:
 *                 if negative_step:
 */
          __pyx_v_start = 0;
          goto __pyx_L13;
        }
        __pyx_L13:;
        goto __pyx_L12;
      }

      /* "View.MemoryView":803
 *                 if start < 0:
 *                     start = 0
 *             elif start >= shape:             # <<<<<<<<<<<<<<
 *                 if negative_step:
 *                     start = shape - 1
 */
      __pyx_t_2 = ((__pyx_v_start >= __pyx_v_shape) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":804
 *                     start = 0
 *             elif start >= shape:
 *                 if negative_step:             # <<<<<<<<<<<<<<
 *                     start = shape - 1
 *                 else:
 */
        __pyx_t_2 = (__pyx_v_negative_step != 0);
        if (__pyx_t_2) {

          /* "View.MemoryView":805
 *             elif start >= shape:
 *                 if negative_step:
 *                     start = shape - 1             # <<<<<<<<<<<<<<
 *                 else:
 *                     start = shape
 */
          __pyx_v_start = (__pyx_v_shape - 1);
          goto __pyx_L14;
        }
        /*else*/ {

          /* "View.MemoryView":807
 *                     start = shape - 1
 *                 else:
 *                     start = shape             # <<<<<<<<<<<<<<
 *         else:
 *             if negative_step:
 */
          __pyx_v_start = __pyx_v_shape;
        }
        __pyx_L14:;
        goto __pyx_L12;
      }
      __pyx_L12:;
      goto __pyx_L11;
    }
    /*else*/ {

      /* "View.MemoryView":809
 *                     start = shape
 *         else:
 *             if negative_step:             # <<<<<<<<<<<<<<
 *                 start = shape - 1
 *             else:
 */
      __pyx_t_2 = (__pyx_v_negative_step != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":810
 *         else:
 *             if negative_step:
 *                 start = shape - 1             # <<<<<<<<<<<<<<
 *             else:
 *                 start = 0
 */
        __pyx_v_start = (__pyx_v_shape - 1);
        goto __pyx_L15;
      }
      /*else*/ {

        /* "View.MemoryView":812
 *                 start = shape - 1
 *             else:
 *                 start = 0             # <<<<<<<<<<<<<<
 * 
 *         if have_stop:
 */
        __pyx_v_start = 0;
      }
      __pyx_L15:;
    }
    __pyx_L11:;

    /* "View.MemoryView":814
 *                 start = 0
 * 
 *         if have_stop:             # <<<<<<<<<<<<<<
 *             if stop < 0:
 *                 stop += shape
 */
    __pyx_t_2 = (__pyx_v_have_stop != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":815
 * 
 *         if have_stop:
 *             if stop < 0:             # <<<<<<<<<<<<<<
 *                 stop += shape
 *                 if stop < 0:
 */
      __pyx_t_2 = ((__pyx_v_stop < 0) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":816
 *         if have_stop:
 *             if stop < 0:
 *                 stop += shape             # <<<<<<<<<<<<<<
 *                 if stop < 0:
 *                     stop = 0
 */
        __pyx_v_stop = (__pyx_v_stop + __pyx_v_shape);

        /* "View.MemoryView":817
 *             if stop < 0:
 *                 stop += shape
 *                 if stop < 0:             # <<<<<<<<<<<<<<
 *                     stop = 0
 *             elif stop > shape:
 */
        __pyx_t_2 = ((__pyx_v_stop < 0) != 0);
        if (__pyx_t_2) {

          /* "View.MemoryView":818
 *                 stop += shape
 *                 if stop < 0:
 *                     stop = 0             # <<<<<<<<<<<<<<
 *             elif stop > shape:
 *                 stop = shape
 */
          __pyx_v_stop = 0;
          goto __pyx_L18;
        }
        __pyx_L18:;
        goto __pyx_L17;
      }

      /* "View.MemoryView":819
 *                 if stop < 0:
 *                     stop = 0
 *             elif stop > shape:             # <<<<<<<<<<<<<<
 *                 stop = shape
 *         else:
 */
      __pyx_t_2 = ((__pyx_v_stop > __pyx_v_shape) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":820
 *                     stop = 0
 *             elif stop > shape:
 *                 stop = shape             # <<<<<<<<<<<<<<
 *         else:
 *             if negative_step:
 */
        __pyx_v_stop = __pyx_v_shape;
        goto __pyx_L17;
      }
      __pyx_L17:;
      goto __pyx_L16;
    }
    /*else*/ {

      /* "View.MemoryView":822
 *                 stop = shape
 *         else:
 *             if negative_step:             # <<<<<<<<<<<<<<
 *                 stop = -1
 *             else:
 */
      __pyx_t_2 = (__pyx_v_negative_step != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":823
 *         else:
 *             if negative_step:
 *                 stop = -1             # <<<<<<<<<<<<<<
 *             else:
 *                 stop = shape
 */
        __pyx_v_stop = -1;
        goto __pyx_L19;
      }
      /*else*/ {

        /* "View.MemoryView":825
 *                 stop = -1
 *             else:
 *                 stop = shape             # <<<<<<<<<<<<<<
 * 
 *         if not have_step:
 */
        __pyx_v_stop = __pyx_v_shape;
      }
      __pyx_L19:;
    }
    __pyx_L16:;

    /* "View.MemoryView":827
 *                 stop = shape
 * 
 *         if not have_step:             # <<<<<<<<<<<<<<
 *             step = 1
 * 
 */
    __pyx_t_2 = ((!(__pyx_v_have_step != 0)) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":828
 * 
 *         if not have_step:
 *             step = 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_v_step = 1;
      goto __pyx_L20;
    }
    __pyx_L20:;

    /* "View.MemoryView":832
 * 
 *         with cython.cdivision(True):
 *             new_shape = (stop - start) // step             # <<<<<<<<<<<<<<
 * 
 *             if (stop - start) - step * new_shape:
 */
    __pyx_v_new_shape = ((__pyx_v_stop - __pyx_v_start) / __pyx_v_step);

    /* "View.MemoryView":834
 *             new_shape = (stop - start) // step
 * 
 *             if (stop - start) - step * new_shape:             # <<<<<<<<<<<<<<
 *                 new_shape += 1
 * 
 */
    __pyx_t_2 = (((__pyx_v_stop - __pyx_v_start) - (__pyx_v_step * __pyx_v_new_shape)) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":835
 * 
 *             if (stop - start) - step * new_shape:
 *                 new_shape += 1             # <<<<<<<<<<<<<<
 * 
 *         if new_shape < 0:
 */
      __pyx_v_new_shape = (__pyx_v_new_shape + 1);
      goto __pyx_L21;
    }
    __pyx_L21:;

    /* "View.MemoryView":837
 *                 new_shape += 1
 * 
 *         if new_shape < 0:             # <<<<<<<<<<<<<<
 *             new_shape = 0
 * 
 */
    __pyx_t_2 = ((__pyx_v_new_shape < 0) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":838
 * 
 *         if new_shape < 0:
 *             new_shape = 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_v_new_shape = 0;
      goto __pyx_L22;
    }
    __pyx_L22:;

    /* "View.MemoryView":841
 * 
 * 
 *         dst.strides[new_ndim] = stride * step             # <<<<<<<<<<<<<<
 *         dst.shape[new_ndim] = new_shape
 *         dst.suboffsets[new_ndim] = suboffset
 */
    (__pyx_v_dst->strides[__pyx_v_new_ndim]) = (__pyx_v_stride * __pyx_v_step);

    /* "View.MemoryView":842
 * 
 *         dst.strides[new_ndim] = stride * step
 *         dst.shape[new_ndim] = new_shape             # <<<<<<<<<<<<<<
 *         dst.suboffsets[new_ndim] = suboffset
 * 
 */
    (__pyx_v_dst->shape[__pyx_v_new_ndim]) = __pyx_v_new_shape;

    /* "View.MemoryView":843
 *         dst.strides[new_ndim] = stride * step
 *         dst.shape[new_ndim] = new_shape
 *         dst.suboffsets[new_ndim] = suboffset             # <<<<<<<<<<<<<<
 * 
 * 
 */
    (__pyx_v_dst->suboffsets[__pyx_v_new_ndim]) = __pyx_v_suboffset;
  }
  __pyx_L3:;

  /* "View.MemoryView":846
 * 
 * 
 *     if suboffset_dim[0] < 0:             # <<<<<<<<<<<<<<
 *         dst.data += start * stride
 *     else:
 */
  __pyx_t_2 = (((__pyx_v_suboffset_dim[0]) < 0) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":847
 * 
 *     if suboffset_dim[0] < 0:
 *         dst.data += start * stride             # <<<<<<<<<<<<<<
 *     else:
 *         dst.suboffsets[suboffset_dim[0]] += start * stride
 */
    __pyx_v_dst->data = (__pyx_v_dst->data + (__pyx_v_start * __pyx_v_stride));
    goto __pyx_L23;
  }
  /*else*/ {

    /* "View.MemoryView":849
 *         dst.data += start * stride
 *     else:
 *         dst.suboffsets[suboffset_dim[0]] += start * stride             # <<<<<<<<<<<<<<
 * 
 *     if suboffset >= 0:
 */
    __pyx_t_3 = (__pyx_v_suboffset_dim[0]);
    (__pyx_v_dst->suboffsets[__pyx_t_3]) = ((__pyx_v_dst->suboffsets[__pyx_t_3]) + (__pyx_v_start * __pyx_v_stride));
  }
  __pyx_L23:;

  /* "View.MemoryView":851
 *         dst.suboffsets[suboffset_dim[0]] += start * stride
 * 
 *     if suboffset >= 0:             # <<<<<<<<<<<<<<
 *         if not is_slice:
 *             if new_ndim == 0:
 */
  __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":852
 * 
 *     if suboffset >= 0:
 *         if not is_slice:             # <<<<<<<<<<<<<<
 *             if new_ndim == 0:
 *                 dst.data = (<char **> dst.data)[0] + suboffset
 */
    __pyx_t_2 = ((!(__pyx_v_is_slice != 0)) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":853
 *     if suboffset >= 0:
 *         if not is_slice:
 *             if new_ndim == 0:             # <<<<<<<<<<<<<<
 *                 dst.data = (<char **> dst.data)[0] + suboffset
 *             else:
 */
      __pyx_t_2 = ((__pyx_v_new_ndim == 0) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":854
 *         if not is_slice:
 *             if new_ndim == 0:
 *                 dst.data = (<char **> dst.data)[0] + suboffset             # <<<<<<<<<<<<<<
 *             else:
 *                 _err_dim(IndexError, "All dimensions preceding dimension %d "
 */
        __pyx_v_dst->data = ((((char **)__pyx_v_dst->data)[0]) + __pyx_v_suboffset);
        goto __pyx_L26;
      }
      /*else*/ {

        /* "View.MemoryView":856
 *                 dst.data = (<char **> dst.data)[0] + suboffset
 *             else:
 *                 _err_dim(IndexError, "All dimensions preceding dimension %d "             # <<<<<<<<<<<<<<
 *                                      "must be indexed and not sliced", dim)
 *         else:
 */
        __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, __pyx_k_All_dimensions_preceding_dimensi, __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L26:;
      goto __pyx_L25;
    }
    /*else*/ {

      /* "View.MemoryView":859
 *                                      "must be indexed and not sliced", dim)
 *         else:
 *             suboffset_dim[0] = new_ndim             # <<<<<<<<<<<<<<
 * 
 *     return 0
 */
      (__pyx_v_suboffset_dim[0]) = __pyx_v_new_ndim;
    }
    __pyx_L25:;
    goto __pyx_L24;
  }
  __pyx_L24:;

  /* "View.MemoryView":861
 *             suboffset_dim[0] = new_ndim
 * 
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "View.MemoryView":764
 * 
 * @cname('__pyx_memoryview_slice_memviewslice')
 * cdef int slice_memviewslice(             # <<<<<<<<<<<<<<
 *         __Pyx_memviewslice *dst,
 *         Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
 */

  /* function exit code */
  __pyx_L1_error:;
  {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    __Pyx_AddTraceback("View.MemoryView.slice_memviewslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
  }
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":867
 * 
 * @cname('__pyx_pybuffer_index')
 * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,             # <<<<<<<<<<<<<<
 *                           Py_ssize_t dim) except NULL:
 *     cdef Py_ssize_t shape, stride, suboffset = -1
 */

static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, Py_ssize_t __pyx_v_index, Py_ssize_t __pyx_v_dim) {
  Py_ssize_t __pyx_v_shape;
  Py_ssize_t __pyx_v_stride;
  Py_ssize_t __pyx_v_suboffset;
  Py_ssize_t __pyx_v_itemsize;
  char *__pyx_v_resultp;
  char *__pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("pybuffer_index", 0);

  /* "View.MemoryView":869
 * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,
 *                           Py_ssize_t dim) except NULL:
 *     cdef Py_ssize_t shape, stride, suboffset = -1             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t itemsize = view.itemsize
 *     cdef char *resultp
 */
  __pyx_v_suboffset = -1;

  /* "View.MemoryView":870
 *                           Py_ssize_t dim) except NULL:
 *     cdef Py_ssize_t shape, stride, suboffset = -1
 *     cdef Py_ssize_t itemsize = view.itemsize             # <<<<<<<<<<<<<<
 *     cdef char *resultp
 * 
 */
  __pyx_t_1 = __pyx_v_view->itemsize;
  __pyx_v_itemsize = __pyx_t_1;

  /* "View.MemoryView":873
 *     cdef char *resultp
 * 
 *     if view.ndim == 0:             # <<<<<<<<<<<<<<
 *         shape = view.len / itemsize
 *         stride = itemsize
 */
  __pyx_t_2 = ((__pyx_v_view->ndim == 0) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":874
 * 
 *     if view.ndim == 0:
 *         shape = view.len / itemsize             # <<<<<<<<<<<<<<
 *         stride = itemsize
 *     else:
 */
    if (unlikely(__pyx_v_itemsize == 0)) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      #ifdef WITH_THREAD
      PyGILState_Release(__pyx_gilstate_save);
      #endif
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    else if (sizeof(Py_ssize_t) == sizeof(long) && unlikely(__pyx_v_itemsize == -1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_view->len))) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
      #ifdef WITH_THREAD
      PyGILState_Release(__pyx_gilstate_save);
      #endif
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_shape = __Pyx_div_Py_ssize_t(__pyx_v_view->len, __pyx_v_itemsize);

    /* "View.MemoryView":875
 *     if view.ndim == 0:
 *         shape = view.len / itemsize
 *         stride = itemsize             # <<<<<<<<<<<<<<
 *     else:
 *         shape = view.shape[dim]
 */
    __pyx_v_stride = __pyx_v_itemsize;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "View.MemoryView":877
 *         stride = itemsize
 *     else:
 *         shape = view.shape[dim]             # <<<<<<<<<<<<<<
 *         stride = view.strides[dim]
 *         if view.suboffsets != NULL:
 */
    __pyx_v_shape = (__pyx_v_view->shape[__pyx_v_dim]);

    /* "View.MemoryView":878
 *     else:
 *         shape = view.shape[dim]
 *         stride = view.strides[dim]             # <<<<<<<<<<<<<<
 *         if view.suboffsets != NULL:
 *             suboffset = view.suboffsets[dim]
 */
    __pyx_v_stride = (__pyx_v_view->strides[__pyx_v_dim]);

    /* "View.MemoryView":879
 *         shape = view.shape[dim]
 *         stride = view.strides[dim]
 *         if view.suboffsets != NULL:             # <<<<<<<<<<<<<<
 *             suboffset = view.suboffsets[dim]
 * 
 */
    __pyx_t_2 = ((__pyx_v_view->suboffsets != NULL) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":880
 *         stride = view.strides[dim]
 *         if view.suboffsets != NULL:
 *             suboffset = view.suboffsets[dim]             # <<<<<<<<<<<<<<
 * 
 *     if index < 0:
 */
      __pyx_v_suboffset = (__pyx_v_view->suboffsets[__pyx_v_dim]);
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  __pyx_L3:;

  /* "View.MemoryView":882
 *             suboffset = view.suboffsets[dim]
 * 
 *     if index < 0:             # <<<<<<<<<<<<<<
 *         index += view.shape[dim]
 *         if index < 0:
 */
  __pyx_t_2 = ((__pyx_v_index < 0) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":883
 * 
 *     if index < 0:
 *         index += view.shape[dim]             # <<<<<<<<<<<<<<
 *         if index < 0:
 *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 */
    __pyx_v_index = (__pyx_v_index + (__pyx_v_view->shape[__pyx_v_dim]));

    /* "View.MemoryView":884
 *     if index < 0:
 *         index += view.shape[dim]
 *         if index < 0:             # <<<<<<<<<<<<<<
 *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 */
    __pyx_t_2 = ((__pyx_v_index < 0) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":885
 *         index += view.shape[dim]
 *         if index < 0:
 *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)             # <<<<<<<<<<<<<<
 * 
 *     if index >= shape:
 */
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "View.MemoryView":887
 *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 *     if index >= shape:             # <<<<<<<<<<<<<<
 *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 */
  __pyx_t_2 = ((__pyx_v_index >= __pyx_v_shape) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":888
 * 
 *     if index >= shape:
 *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)             # <<<<<<<<<<<<<<
 * 
 *     resultp = bufp + index * stride
 */
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "View.MemoryView":890
 *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 *     resultp = bufp + index * stride             # <<<<<<<<<<<<<<
 *     if suboffset >= 0:
 *         resultp = (<char **> resultp)[0] + suboffset
 */
  __pyx_v_resultp = (__pyx_v_bufp + (__pyx_v_index * __pyx_v_stride));

  /* "View.MemoryView":891
 * 
 *     resultp = bufp + index * stride
 *     if suboffset >= 0:             # <<<<<<<<<<<<<<
 *         resultp = (<char **> resultp)[0] + suboffset
 * 
 */
  __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":892
 *     resultp = bufp + index * stride
 *     if suboffset >= 0:
 *         resultp = (<char **> resultp)[0] + suboffset             # <<<<<<<<<<<<<<
 * 
 *     return resultp
 */
    __pyx_v_resultp = ((((char **)__pyx_v_resultp)[0]) + __pyx_v_suboffset);
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "View.MemoryView":894
 *         resultp = (<char **> resultp)[0] + suboffset
 * 
 *     return resultp             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_resultp;
  goto __pyx_L0;

  /* "View.MemoryView":867
 * 
 * @cname('__pyx_pybuffer_index')
 * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,             # <<<<<<<<<<<<<<
 *                           Py_ssize_t dim) except NULL:
 *     cdef Py_ssize_t shape, stride, suboffset = -1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("View.MemoryView.pybuffer_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":900
 * 
 * @cname('__pyx_memslice_transpose')
 * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:             # <<<<<<<<<<<<<<
 *     cdef int ndim = memslice.memview.view.ndim
 * 
 */

static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) {
  int __pyx_v_ndim;
  Py_ssize_t *__pyx_v_shape;
  Py_ssize_t *__pyx_v_strides;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_r;
  int __pyx_t_1;
  Py_ssize_t *__pyx_t_2;
  long __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "View.MemoryView":901
 * @cname('__pyx_memslice_transpose')
 * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:
 *     cdef int ndim = memslice.memview.view.ndim             # <<<<<<<<<<<<<<
 * 
 *     cdef Py_ssize_t *shape = memslice.shape
 */
  __pyx_t_1 = __pyx_v_memslice->memview->view.ndim;
  __pyx_v_ndim = __pyx_t_1;

  /* "View.MemoryView":903
 *     cdef int ndim = memslice.memview.view.ndim
 * 
 *     cdef Py_ssize_t *shape = memslice.shape             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t *strides = memslice.strides
 * 
 */
  __pyx_t_2 = __pyx_v_memslice->shape;
  __pyx_v_shape = __pyx_t_2;

  /* "View.MemoryView":904
 * 
 *     cdef Py_ssize_t *shape = memslice.shape
 *     cdef Py_ssize_t *strides = memslice.strides             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __pyx_v_memslice->strides;
  __pyx_v_strides = __pyx_t_2;

  /* "View.MemoryView":908
 * 
 *     cdef int i, j
 *     for i in range(ndim / 2):             # <<<<<<<<<<<<<<
 *         j = ndim - 1 - i
 *         strides[i], strides[j] = strides[j], strides[i]
 */
  __pyx_t_3 = __Pyx_div_long(__pyx_v_ndim, 2);
  for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "View.MemoryView":909
 *     cdef int i, j
 *     for i in range(ndim / 2):
 *         j = ndim - 1 - i             # <<<<<<<<<<<<<<
 *         strides[i], strides[j] = strides[j], strides[i]
 *         shape[i], shape[j] = shape[j], shape[i]
 */
    __pyx_v_j = ((__pyx_v_ndim - 1) - __pyx_v_i);

    /* "View.MemoryView":910
 *     for i in range(ndim / 2):
 *         j = ndim - 1 - i
 *         strides[i], strides[j] = strides[j], strides[i]             # <<<<<<<<<<<<<<
 *         shape[i], shape[j] = shape[j], shape[i]
 * 
 */
    __pyx_t_4 = (__pyx_v_strides[__pyx_v_j]);
    __pyx_t_5 = (__pyx_v_strides[__pyx_v_i]);
    (__pyx_v_strides[__pyx_v_i]) = __pyx_t_4;
    (__pyx_v_strides[__pyx_v_j]) = __pyx_t_5;

    /* "View.MemoryView":911
 *         j = ndim - 1 - i
 *         strides[i], strides[j] = strides[j], strides[i]
 *         shape[i], shape[j] = shape[j], shape[i]             # <<<<<<<<<<<<<<
 * 
 *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
 */
    __pyx_t_5 = (__pyx_v_shape[__pyx_v_j]);
    __pyx_t_4 = (__pyx_v_shape[__pyx_v_i]);
    (__pyx_v_shape[__pyx_v_i]) = __pyx_t_5;
    (__pyx_v_shape[__pyx_v_j]) = __pyx_t_4;

    /* "View.MemoryView":913
 *         shape[i], shape[j] = shape[j], shape[i]
 * 
 *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:             # <<<<<<<<<<<<<<
 *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
 * 
 */
    __pyx_t_7 = (((__pyx_v_memslice->suboffsets[__pyx_v_i]) >= 0) != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_7 = (((__pyx_v_memslice->suboffsets[__pyx_v_j]) >= 0) != 0);
    __pyx_t_6 = __pyx_t_7;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_6) {

      /* "View.MemoryView":914
 * 
 *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
 *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")             # <<<<<<<<<<<<<<
 * 
 *     return 1
 */
      __pyx_t_8 = __pyx_memoryview_err(__pyx_builtin_ValueError, __pyx_k_Cannot_transpose_memoryview_with); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "View.MemoryView":916
 *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
 * 
 *     return 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "View.MemoryView":900
 * 
 * @cname('__pyx_memslice_transpose')
 * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:             # <<<<<<<<<<<<<<
 *     cdef int ndim = memslice.memview.view.ndim
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    __Pyx_AddTraceback("View.MemoryView.transpose_memslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
  }
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":933
 *     cdef int (*to_dtype_func)(char *, object) except 0
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
 * 
 */

/* Python wrapper */
static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_memoryviewslice_MemoryView_16_memoryviewslice___dealloc__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_memoryviewslice_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "View.MemoryView":934
 * 
 *     def __dealloc__(self):
 *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)             # <<<<<<<<<<<<<<
 * 
 *     cdef convert_item_to_object(self, char *itemp):
 */
  __PYX_XDEC_MEMVIEW((&__pyx_v_self->from_slice), 1);

  /* "View.MemoryView":933
 *     cdef int (*to_dtype_func)(char *, object) except 0
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
 * 
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "View.MemoryView":936
 *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
 * 
 *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
 *         if self.to_object_func != NULL:
 *             return self.to_object_func(itemp)
 */

static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("convert_item_to_object", 0);

  /* "View.MemoryView":937
 * 
 *     cdef convert_item_to_object(self, char *itemp):
 *         if self.to_object_func != NULL:             # <<<<<<<<<<<<<<
 *             return self.to_object_func(itemp)
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_self->to_object_func != NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":938
 *     cdef convert_item_to_object(self, char *itemp):
 *         if self.to_object_func != NULL:
 *             return self.to_object_func(itemp)             # <<<<<<<<<<<<<<
 *         else:
 *             return memoryview.convert_item_to_object(self, itemp)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __pyx_v_self->to_object_func(__pyx_v_itemp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "View.MemoryView":940
 *             return self.to_object_func(itemp)
 *         else:
 *             return memoryview.convert_item_to_object(self, itemp)             # <<<<<<<<<<<<<<
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __pyx_memoryview_convert_item_to_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "View.MemoryView":936
 *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
 * 
 *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
 *         if self.to_object_func != NULL:
 *             return self.to_object_func(itemp)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView._memoryviewslice.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":942
 *             return memoryview.convert_item_to_object(self, itemp)
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
 *         if self.to_dtype_func != NULL:
 *             self.to_dtype_func(itemp, value)
 */

static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("assign_item_from_object", 0);

  /* "View.MemoryView":943
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):
 *         if self.to_dtype_func != NULL:             # <<<<<<<<<<<<<<
 *             self.to_dtype_func(itemp, value)
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_self->to_dtype_func != NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":944
 *     cdef assign_item_from_object(self, char *itemp, object value):
 *         if self.to_dtype_func != NULL:
 *             self.to_dtype_func(itemp, value)             # <<<<<<<<<<<<<<
 *         else:
 *             memoryview.assign_item_from_object(self, itemp, value)
 */
    __pyx_t_2 = __pyx_v_self->to_dtype_func(__pyx_v_itemp, __pyx_v_value); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  /*else*/ {

    /* "View.MemoryView":946
 *             self.to_dtype_func(itemp, value)
 *         else:
 *             memoryview.assign_item_from_object(self, itemp, value)             # <<<<<<<<<<<<<<
 * 
 *     property base:
 */
    __pyx_t_3 = __pyx_memoryview_assign_item_from_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "View.MemoryView":942
 *             return memoryview.convert_item_to_object(self, itemp)
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
 *         if self.to_dtype_func != NULL:
 *             self.to_dtype_func(itemp, value)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView._memoryviewslice.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":950
 *     property base:
 *         @cname('__pyx_memoryviewslice__get__base')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.from_object
 * 
 */

/* Python wrapper */
static PyObject *__pyx_memoryviewslice__get__base(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryviewslice__get__base(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_memoryviewslice__get__base_MemoryView_16_memoryviewslice_4base___get__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryviewslice__get__base_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":951
 *         @cname('__pyx_memoryviewslice__get__base')
 *         def __get__(self):
 *             return self.from_object             # <<<<<<<<<<<<<<
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->from_object);
  __pyx_r = __pyx_v_self->from_object;
  goto __pyx_L0;

  /* "View.MemoryView":950
 *     property base:
 *         @cname('__pyx_memoryviewslice__get__base')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.from_object
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":957
 * 
 * @cname('__pyx_memoryview_fromslice')
 * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice,             # <<<<<<<<<<<<<<
 *                           int ndim,
 *                           object (*to_object_func)(char *),
 */

static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewslice, int __pyx_v_ndim, PyObject *(*__pyx_v_to_object_func)(char *), int (*__pyx_v_to_dtype_func)(char *, PyObject *), int __pyx_v_dtype_is_object) {
  struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_TypeInfo *__pyx_t_4;
  Py_buffer __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("memoryview_fromslice", 0);

  /* "View.MemoryView":966
 *     cdef int i
 * 
 *     if <PyObject *> memviewslice.memview == Py_None:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  __pyx_t_1 = ((((PyObject *)__pyx_v_memviewslice.memview) == Py_None) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":967
 * 
 *     if <PyObject *> memviewslice.memview == Py_None:
 *         return None             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
  }

  /* "View.MemoryView":972
 * 
 * 
 *     result = _memoryviewslice(None, 0, dtype_is_object)             # <<<<<<<<<<<<<<
 * 
 *     result.from_slice = memviewslice
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_3, 0, Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_memoryviewslice_type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "View.MemoryView":974
 *     result = _memoryviewslice(None, 0, dtype_is_object)
 * 
 *     result.from_slice = memviewslice             # <<<<<<<<<<<<<<
 *     __PYX_INC_MEMVIEW(&memviewslice, 1)
 * 
 */
  __pyx_v_result->from_slice = __pyx_v_memviewslice;

  /* "View.MemoryView":975
 * 
 *     result.from_slice = memviewslice
 *     __PYX_INC_MEMVIEW(&memviewslice, 1)             # <<<<<<<<<<<<<<
 * 
 *     result.from_object = (<memoryview> memviewslice.memview).base
 */
  __PYX_INC_MEMVIEW((&__pyx_v_memviewslice), 1);

  /* "View.MemoryView":977
 *     __PYX_INC_MEMVIEW(&memviewslice, 1)
 * 
 *     result.from_object = (<memoryview> memviewslice.memview).base             # <<<<<<<<<<<<<<
 *     result.typeinfo = memviewslice.memview.typeinfo
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_memviewslice.memview), __pyx_n_s_base); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_result->from_object);
  __Pyx_DECREF(__pyx_v_result->from_object);
  __pyx_v_result->from_object = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "View.MemoryView":978
 * 
 *     result.from_object = (<memoryview> memviewslice.memview).base
 *     result.typeinfo = memviewslice.memview.typeinfo             # <<<<<<<<<<<<<<
 * 
 *     result.view = memviewslice.memview.view
 */
  __pyx_t_4 = __pyx_v_memviewslice.memview->typeinfo;
  __pyx_v_result->__pyx_base.typeinfo = __pyx_t_4;

  /* "View.MemoryView":980
 *     result.typeinfo = memviewslice.memview.typeinfo
 * 
 *     result.view = memviewslice.memview.view             # <<<<<<<<<<<<<<
 *     result.view.buf = <void *> memviewslice.data
 *     result.view.ndim = ndim
 */
  __pyx_t_5 = __pyx_v_memviewslice.memview->view;
  __pyx_v_result->__pyx_base.view = __pyx_t_5;

  /* "View.MemoryView":981
 * 
 *     result.view = memviewslice.memview.view
 *     result.view.buf = <void *> memviewslice.data             # <<<<<<<<<<<<<<
 *     result.view.ndim = ndim
 *     (<__pyx_buffer *> &result.view).obj = Py_None
 */
  __pyx_v_result->__pyx_base.view.buf = ((void *)__pyx_v_memviewslice.data);

  /* "View.MemoryView":982
 *     result.view = memviewslice.memview.view
 *     result.view.buf = <void *> memviewslice.data
 *     result.view.ndim = ndim             # <<<<<<<<<<<<<<
 *     (<__pyx_buffer *> &result.view).obj = Py_None
 *     Py_INCREF(Py_None)
 */
  __pyx_v_result->__pyx_base.view.ndim = __pyx_v_ndim;

  /* "View.MemoryView":983
 *     result.view.buf = <void *> memviewslice.data
 *     result.view.ndim = ndim
 *     (<__pyx_buffer *> &result.view).obj = Py_None             # <<<<<<<<<<<<<<
 *     Py_INCREF(Py_None)
 * 
 */
  ((Py_buffer *)(&__pyx_v_result->__pyx_base.view))->obj = Py_None;

  /* "View.MemoryView":984
 *     result.view.ndim = ndim
 *     (<__pyx_buffer *> &result.view).obj = Py_None
 *     Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
 * 
 *     result.flags = PyBUF_RECORDS
 */
  Py_INCREF(Py_None);

  /* "View.MemoryView":986
 *     Py_INCREF(Py_None)
 * 
 *     result.flags = PyBUF_RECORDS             # <<<<<<<<<<<<<<
 * 
 *     result.view.shape = <Py_ssize_t *> result.from_slice.shape
 */
  __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS;

  /* "View.MemoryView":988
 *     result.flags = PyBUF_RECORDS
 * 
 *     result.view.shape = <Py_ssize_t *> result.from_slice.shape             # <<<<<<<<<<<<<<
 *     result.view.strides = <Py_ssize_t *> result.from_slice.strides
 *     result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
 */
  __pyx_v_result->__pyx_base.view.shape = ((Py_ssize_t *)__pyx_v_result->from_slice.shape);

  /* "View.MemoryView":989
 * 
 *     result.view.shape = <Py_ssize_t *> result.from_slice.shape
 *     result.view.strides = <Py_ssize_t *> result.from_slice.strides             # <<<<<<<<<<<<<<
 *     result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
 * 
 */
  __pyx_v_result->__pyx_base.view.strides = ((Py_ssize_t *)__pyx_v_result->from_slice.strides);

  /* "View.MemoryView":990
 *     result.view.shape = <Py_ssize_t *> result.from_slice.shape
 *     result.view.strides = <Py_ssize_t *> result.from_slice.strides
 *     result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets             # <<<<<<<<<<<<<<
 * 
 *     result.view.len = result.view.itemsize
 */
  __pyx_v_result->__pyx_base.view.suboffsets = ((Py_ssize_t *)__pyx_v_result->from_slice.suboffsets);

  /* "View.MemoryView":992
 *     result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
 * 
 *     result.view.len = result.view.itemsize             # <<<<<<<<<<<<<<
 *     for i in range(ndim):
 *         result.view.len *= result.view.shape[i]
 */
  __pyx_t_6 = __pyx_v_result->__pyx_base.view.itemsize;
  __pyx_v_result->__pyx_base.view.len = __pyx_t_6;

  /* "View.MemoryView":993
 * 
 *     result.view.len = result.view.itemsize
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         result.view.len *= result.view.shape[i]
 * 
 */
  __pyx_t_7 = __pyx_v_ndim;
  for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
    __pyx_v_i = __pyx_t_8;

    /* "View.MemoryView":994
 *     result.view.len = result.view.itemsize
 *     for i in range(ndim):
 *         result.view.len *= result.view.shape[i]             # <<<<<<<<<<<<<<
 * 
 *     result.to_object_func = to_object_func
 */
    __pyx_v_result->__pyx_base.view.len = (__pyx_v_result->__pyx_base.view.len * (__pyx_v_result->__pyx_base.view.shape[__pyx_v_i]));
  }

  /* "View.MemoryView":996
 *         result.view.len *= result.view.shape[i]
 * 
 *     result.to_object_func = to_object_func             # <<<<<<<<<<<<<<
 *     result.to_dtype_func = to_dtype_func
 * 
 */
  __pyx_v_result->to_object_func = __pyx_v_to_object_func;

  /* "View.MemoryView":997
 * 
 *     result.to_object_func = to_object_func
 *     result.to_dtype_func = to_dtype_func             # <<<<<<<<<<<<<<
 * 
 *     return result
 */
  __pyx_v_result->to_dtype_func = __pyx_v_to_dtype_func;

  /* "View.MemoryView":999
 *     result.to_dtype_func = to_dtype_func
 * 
 *     return result             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_get_slice_from_memoryview')
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "View.MemoryView":957
 * 
 * @cname('__pyx_memoryview_fromslice')
 * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice,             # <<<<<<<<<<<<<<
 *                           int ndim,
 *                           object (*to_object_func)(char *),
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.memoryview_fromslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":1002
 * 
 * @cname('__pyx_memoryview_get_slice_from_memoryview')
 * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview,             # <<<<<<<<<<<<<<
 *                                                    __Pyx_memviewslice *mslice):
 *     cdef _memoryviewslice obj
 */

static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_mslice) {
  struct __pyx_memoryviewslice_obj *__pyx_v_obj = 0;
  __Pyx_memviewslice *__pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_slice_from_memview", 0);

  /* "View.MemoryView":1005
 *                                                    __Pyx_memviewslice *mslice):
 *     cdef _memoryviewslice obj
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         obj = memview
 *         return &obj.from_slice
 */
  __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), ((PyObject *)__pyx_memoryviewslice_type)); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1006
 *     cdef _memoryviewslice obj
 *     if isinstance(memview, _memoryviewslice):
 *         obj = memview             # <<<<<<<<<<<<<<
 *         return &obj.from_slice
 *     else:
 */
    if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = ((PyObject *)__pyx_v_memview);
    __Pyx_INCREF(__pyx_t_3);
    __pyx_v_obj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "View.MemoryView":1007
 *     if isinstance(memview, _memoryviewslice):
 *         obj = memview
 *         return &obj.from_slice             # <<<<<<<<<<<<<<
 *     else:
 *         slice_copy(memview, mslice)
 */
    __pyx_r = (&__pyx_v_obj->from_slice);
    goto __pyx_L0;
  }
  /*else*/ {

    /* "View.MemoryView":1009
 *         return &obj.from_slice
 *     else:
 *         slice_copy(memview, mslice)             # <<<<<<<<<<<<<<
 *         return mslice
 * 
 */
    __pyx_memoryview_slice_copy(__pyx_v_memview, __pyx_v_mslice);

    /* "View.MemoryView":1010
 *     else:
 *         slice_copy(memview, mslice)
 *         return mslice             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_slice_copy')
 */
    __pyx_r = __pyx_v_mslice;
    goto __pyx_L0;
  }

  /* "View.MemoryView":1002
 * 
 * @cname('__pyx_memoryview_get_slice_from_memoryview')
 * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview,             # <<<<<<<<<<<<<<
 *                                                    __Pyx_memviewslice *mslice):
 *     cdef _memoryviewslice obj
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("View.MemoryView.get_slice_from_memview", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_obj);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":1013
 * 
 * @cname('__pyx_memoryview_slice_copy')
 * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst):             # <<<<<<<<<<<<<<
 *     cdef int dim
 *     cdef (Py_ssize_t*) shape, strides, suboffsets
 */

static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_dst) {
  int __pyx_v_dim;
  Py_ssize_t *__pyx_v_shape;
  Py_ssize_t *__pyx_v_strides;
  Py_ssize_t *__pyx_v_suboffsets;
  __Pyx_RefNannyDeclarations
  Py_ssize_t *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("slice_copy", 0);

  /* "View.MemoryView":1017
 *     cdef (Py_ssize_t*) shape, strides, suboffsets
 * 
 *     shape = memview.view.shape             # <<<<<<<<<<<<<<
 *     strides = memview.view.strides
 *     suboffsets = memview.view.suboffsets
 */
  __pyx_t_1 = __pyx_v_memview->view.shape;
  __pyx_v_shape = __pyx_t_1;

  /* "View.MemoryView":1018
 * 
 *     shape = memview.view.shape
 *     strides = memview.view.strides             # <<<<<<<<<<<<<<
 *     suboffsets = memview.view.suboffsets
 * 
 */
  __pyx_t_1 = __pyx_v_memview->view.strides;
  __pyx_v_strides = __pyx_t_1;

  /* "View.MemoryView":1019
 *     shape = memview.view.shape
 *     strides = memview.view.strides
 *     suboffsets = memview.view.suboffsets             # <<<<<<<<<<<<<<
 * 
 *     dst.memview = <__pyx_memoryview *> memview
 */
  __pyx_t_1 = __pyx_v_memview->view.suboffsets;
  __pyx_v_suboffsets = __pyx_t_1;

  /* "View.MemoryView":1021
 *     suboffsets = memview.view.suboffsets
 * 
 *     dst.memview = <__pyx_memoryview *> memview             # <<<<<<<<<<<<<<
 *     dst.data = <char *> memview.view.buf
 * 
 */
  __pyx_v_dst->memview = ((struct __pyx_memoryview_obj *)__pyx_v_memview);

  /* "View.MemoryView":1022
 * 
 *     dst.memview = <__pyx_memoryview *> memview
 *     dst.data = <char *> memview.view.buf             # <<<<<<<<<<<<<<
 * 
 *     for dim in range(memview.view.ndim):
 */
  __pyx_v_dst->data = ((char *)__pyx_v_memview->view.buf);

  /* "View.MemoryView":1024
 *     dst.data = <char *> memview.view.buf
 * 
 *     for dim in range(memview.view.ndim):             # <<<<<<<<<<<<<<
 *         dst.shape[dim] = shape[dim]
 *         dst.strides[dim] = strides[dim]
 */
  __pyx_t_2 = __pyx_v_memview->view.ndim;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_dim = __pyx_t_3;

    /* "View.MemoryView":1025
 * 
 *     for dim in range(memview.view.ndim):
 *         dst.shape[dim] = shape[dim]             # <<<<<<<<<<<<<<
 *         dst.strides[dim] = strides[dim]
 *         if suboffsets == NULL:
 */
    (__pyx_v_dst->shape[__pyx_v_dim]) = (__pyx_v_shape[__pyx_v_dim]);

    /* "View.MemoryView":1026
 *     for dim in range(memview.view.ndim):
 *         dst.shape[dim] = shape[dim]
 *         dst.strides[dim] = strides[dim]             # <<<<<<<<<<<<<<
 *         if suboffsets == NULL:
 *             dst.suboffsets[dim] = -1
 */
    (__pyx_v_dst->strides[__pyx_v_dim]) = (__pyx_v_strides[__pyx_v_dim]);

    /* "View.MemoryView":1027
 *         dst.shape[dim] = shape[dim]
 *         dst.strides[dim] = strides[dim]
 *         if suboffsets == NULL:             # <<<<<<<<<<<<<<
 *             dst.suboffsets[dim] = -1
 *         else:
 */
    __pyx_t_4 = ((__pyx_v_suboffsets == NULL) != 0);
    if (__pyx_t_4) {

      /* "View.MemoryView":1028
 *         dst.strides[dim] = strides[dim]
 *         if suboffsets == NULL:
 *             dst.suboffsets[dim] = -1             # <<<<<<<<<<<<<<
 *         else:
 *             dst.suboffsets[dim] = suboffsets[dim]
 */
      (__pyx_v_dst->suboffsets[__pyx_v_dim]) = -1;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "View.MemoryView":1030
 *             dst.suboffsets[dim] = -1
 *         else:
 *             dst.suboffsets[dim] = suboffsets[dim]             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_copy_object')
 */
      (__pyx_v_dst->suboffsets[__pyx_v_dim]) = (__pyx_v_suboffsets[__pyx_v_dim]);
    }
    __pyx_L5:;
  }

  /* "View.MemoryView":1013
 * 
 * @cname('__pyx_memoryview_slice_copy')
 * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst):             # <<<<<<<<<<<<<<
 *     cdef int dim
 *     cdef (Py_ssize_t*) shape, strides, suboffsets
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "View.MemoryView":1033
 * 
 * @cname('__pyx_memoryview_copy_object')
 * cdef memoryview_copy(memoryview memview):             # <<<<<<<<<<<<<<
 *     "Create a new memoryview object"
 *     cdef __Pyx_memviewslice memviewslice
 */

static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx_v_memview) {
  __Pyx_memviewslice __pyx_v_memviewslice;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("memoryview_copy", 0);

  /* "View.MemoryView":1036
 *     "Create a new memoryview object"
 *     cdef __Pyx_memviewslice memviewslice
 *     slice_copy(memview, &memviewslice)             # <<<<<<<<<<<<<<
 *     return memoryview_copy_from_slice(memview, &memviewslice)
 * 
 */
  __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_memviewslice));

  /* "View.MemoryView":1037
 *     cdef __Pyx_memviewslice memviewslice
 *     slice_copy(memview, &memviewslice)
 *     return memoryview_copy_from_slice(memview, &memviewslice)             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_copy_object_from_slice')
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_memoryview_copy_object_from_slice(__pyx_v_memview, (&__pyx_v_memviewslice)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1037; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":1033
 * 
 * @cname('__pyx_memoryview_copy_object')
 * cdef memoryview_copy(memoryview memview):             # <<<<<<<<<<<<<<
 *     "Create a new memoryview object"
 *     cdef __Pyx_memviewslice memviewslice
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview_copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":1040
 * 
 * @cname('__pyx_memoryview_copy_object_from_slice')
 * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice):             # <<<<<<<<<<<<<<
 *     """
 *     Create a new memoryview object from a given memoryview object and slice.
 */

static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_memviewslice) {
  PyObject *(*__pyx_v_to_object_func)(char *);
  int (*__pyx_v_to_dtype_func)(char *, PyObject *);
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *(*__pyx_t_3)(char *);
  int (*__pyx_t_4)(char *, PyObject *);
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("memoryview_copy_from_slice", 0);

  /* "View.MemoryView":1047
 *     cdef int (*to_dtype_func)(char *, object) except 0
 * 
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         to_object_func = (<_memoryviewslice> memview).to_object_func
 *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
 */
  __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), ((PyObject *)__pyx_memoryviewslice_type)); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1048
 * 
 *     if isinstance(memview, _memoryviewslice):
 *         to_object_func = (<_memoryviewslice> memview).to_object_func             # <<<<<<<<<<<<<<
 *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
 *     else:
 */
    __pyx_t_3 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_object_func;
    __pyx_v_to_object_func = __pyx_t_3;

    /* "View.MemoryView":1049
 *     if isinstance(memview, _memoryviewslice):
 *         to_object_func = (<_memoryviewslice> memview).to_object_func
 *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func             # <<<<<<<<<<<<<<
 *     else:
 *         to_object_func = NULL
 */
    __pyx_t_4 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_dtype_func;
    __pyx_v_to_dtype_func = __pyx_t_4;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "View.MemoryView":1051
 *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
 *     else:
 *         to_object_func = NULL             # <<<<<<<<<<<<<<
 *         to_dtype_func = NULL
 * 
 */
    __pyx_v_to_object_func = NULL;

    /* "View.MemoryView":1052
 *     else:
 *         to_object_func = NULL
 *         to_dtype_func = NULL             # <<<<<<<<<<<<<<
 * 
 *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,
 */
    __pyx_v_to_dtype_func = NULL;
  }
  __pyx_L3:;

  /* "View.MemoryView":1054
 *         to_dtype_func = NULL
 * 
 *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,             # <<<<<<<<<<<<<<
 *                                 to_object_func, to_dtype_func,
 *                                 memview.dtype_is_object)
 */
  __Pyx_XDECREF(__pyx_r);

  /* "View.MemoryView":1056
 *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,
 *                                 to_object_func, to_dtype_func,
 *                                 memview.dtype_is_object)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = __pyx_memoryview_fromslice((__pyx_v_memviewslice[0]), __pyx_v_memview->view.ndim, __pyx_v_to_object_func, __pyx_v_to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":1040
 * 
 * @cname('__pyx_memoryview_copy_object_from_slice')
 * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice):             # <<<<<<<<<<<<<<
 *     """
 *     Create a new memoryview object from a given memoryview object and slice.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView.memoryview_copy_from_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":1062
 * 
 * 
 * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:             # <<<<<<<<<<<<<<
 *     if arg < 0:
 *         return -arg
 */

static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) {
  Py_ssize_t __pyx_r;
  int __pyx_t_1;

  /* "View.MemoryView":1063
 * 
 * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
 *     if arg < 0:             # <<<<<<<<<<<<<<
 *         return -arg
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_arg < 0) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1064
 * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
 *     if arg < 0:
 *         return -arg             # <<<<<<<<<<<<<<
 *     else:
 *         return arg
 */
    __pyx_r = (-__pyx_v_arg);
    goto __pyx_L0;
  }
  /*else*/ {

    /* "View.MemoryView":1066
 *         return -arg
 *     else:
 *         return arg             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_get_best_slice_order')
 */
    __pyx_r = __pyx_v_arg;
    goto __pyx_L0;
  }

  /* "View.MemoryView":1062
 * 
 * 
 * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:             # <<<<<<<<<<<<<<
 *     if arg < 0:
 *         return -arg
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":1069
 * 
 * @cname('__pyx_get_best_slice_order')
 * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Figure out the best memory access order for a given slice.
 */

static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim) {
  int __pyx_v_i;
  Py_ssize_t __pyx_v_c_stride;
  Py_ssize_t __pyx_v_f_stride;
  char __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;

  /* "View.MemoryView":1074
 *     """
 *     cdef int i
 *     cdef Py_ssize_t c_stride = 0             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t f_stride = 0
 * 
 */
  __pyx_v_c_stride = 0;

  /* "View.MemoryView":1075
 *     cdef int i
 *     cdef Py_ssize_t c_stride = 0
 *     cdef Py_ssize_t f_stride = 0             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim - 1, -1, -1):
 */
  __pyx_v_f_stride = 0;

  /* "View.MemoryView":1077
 *     cdef Py_ssize_t f_stride = 0
 * 
 *     for i in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
 *         if mslice.shape[i] > 1:
 *             c_stride = mslice.strides[i]
 */
  for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) {
    __pyx_v_i = __pyx_t_1;

    /* "View.MemoryView":1078
 * 
 *     for i in range(ndim - 1, -1, -1):
 *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
 *             c_stride = mslice.strides[i]
 *             break
 */
    __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1079
 *     for i in range(ndim - 1, -1, -1):
 *         if mslice.shape[i] > 1:
 *             c_stride = mslice.strides[i]             # <<<<<<<<<<<<<<
 *             break
 * 
 */
      __pyx_v_c_stride = (__pyx_v_mslice->strides[__pyx_v_i]);

      /* "View.MemoryView":1080
 *         if mslice.shape[i] > 1:
 *             c_stride = mslice.strides[i]
 *             break             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim):
 */
      goto __pyx_L4_break;
    }
  }
  __pyx_L4_break:;

  /* "View.MemoryView":1082
 *             break
 * 
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         if mslice.shape[i] > 1:
 *             f_stride = mslice.strides[i]
 */
  __pyx_t_1 = __pyx_v_ndim;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_1; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "View.MemoryView":1083
 * 
 *     for i in range(ndim):
 *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
 *             f_stride = mslice.strides[i]
 *             break
 */
    __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1084
 *     for i in range(ndim):
 *         if mslice.shape[i] > 1:
 *             f_stride = mslice.strides[i]             # <<<<<<<<<<<<<<
 *             break
 * 
 */
      __pyx_v_f_stride = (__pyx_v_mslice->strides[__pyx_v_i]);

      /* "View.MemoryView":1085
 *         if mslice.shape[i] > 1:
 *             f_stride = mslice.strides[i]
 *             break             # <<<<<<<<<<<<<<
 * 
 *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
 */
      goto __pyx_L7_break;
    }
  }
  __pyx_L7_break:;

  /* "View.MemoryView":1087
 *             break
 * 
 *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):             # <<<<<<<<<<<<<<
 *         return 'C'
 *     else:
 */
  __pyx_t_2 = ((abs_py_ssize_t(__pyx_v_c_stride) <= abs_py_ssize_t(__pyx_v_f_stride)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1088
 * 
 *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
 *         return 'C'             # <<<<<<<<<<<<<<
 *     else:
 *         return 'F'
 */
    __pyx_r = 'C';
    goto __pyx_L0;
  }
  /*else*/ {

    /* "View.MemoryView":1090
 *         return 'C'
 *     else:
 *         return 'F'             # <<<<<<<<<<<<<<
 * 
 * @cython.cdivision(True)
 */
    __pyx_r = 'F';
    goto __pyx_L0;
  }

  /* "View.MemoryView":1069
 * 
 * @cname('__pyx_get_best_slice_order')
 * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Figure out the best memory access order for a given slice.
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":1093
 * 
 * @cython.cdivision(True)
 * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides,             # <<<<<<<<<<<<<<
 *                                    char *dst_data, Py_ssize_t *dst_strides,
 *                                    Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
 */

static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v_src_strides, char *__pyx_v_dst_data, Py_ssize_t *__pyx_v_dst_strides, Py_ssize_t *__pyx_v_src_shape, Py_ssize_t *__pyx_v_dst_shape, int __pyx_v_ndim, size_t __pyx_v_itemsize) {
  CYTHON_UNUSED Py_ssize_t __pyx_v_i;
  CYTHON_UNUSED Py_ssize_t __pyx_v_src_extent;
  Py_ssize_t __pyx_v_dst_extent;
  Py_ssize_t __pyx_v_src_stride;
  Py_ssize_t __pyx_v_dst_stride;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  Py_ssize_t __pyx_t_5;

  /* "View.MemoryView":1100
 * 
 *     cdef Py_ssize_t i
 *     cdef Py_ssize_t src_extent = src_shape[0]             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t dst_extent = dst_shape[0]
 *     cdef Py_ssize_t src_stride = src_strides[0]
 */
  __pyx_v_src_extent = (__pyx_v_src_shape[0]);

  /* "View.MemoryView":1101
 *     cdef Py_ssize_t i
 *     cdef Py_ssize_t src_extent = src_shape[0]
 *     cdef Py_ssize_t dst_extent = dst_shape[0]             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t src_stride = src_strides[0]
 *     cdef Py_ssize_t dst_stride = dst_strides[0]
 */
  __pyx_v_dst_extent = (__pyx_v_dst_shape[0]);

  /* "View.MemoryView":1102
 *     cdef Py_ssize_t src_extent = src_shape[0]
 *     cdef Py_ssize_t dst_extent = dst_shape[0]
 *     cdef Py_ssize_t src_stride = src_strides[0]             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t dst_stride = dst_strides[0]
 * 
 */
  __pyx_v_src_stride = (__pyx_v_src_strides[0]);

  /* "View.MemoryView":1103
 *     cdef Py_ssize_t dst_extent = dst_shape[0]
 *     cdef Py_ssize_t src_stride = src_strides[0]
 *     cdef Py_ssize_t dst_stride = dst_strides[0]             # <<<<<<<<<<<<<<
 * 
 *     if ndim == 1:
 */
  __pyx_v_dst_stride = (__pyx_v_dst_strides[0]);

  /* "View.MemoryView":1105
 *     cdef Py_ssize_t dst_stride = dst_strides[0]
 * 
 *     if ndim == 1:             # <<<<<<<<<<<<<<
 *        if (src_stride > 0 and dst_stride > 0 and
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):
 */
  __pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1106
 * 
 *     if ndim == 1:
 *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):
 *            memcpy(dst_data, src_data, itemsize * dst_extent)
 */
    __pyx_t_2 = ((__pyx_v_src_stride > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_dst_stride > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L5_bool_binop_done;
    }

    /* "View.MemoryView":1107
 *     if ndim == 1:
 *        if (src_stride > 0 and dst_stride > 0 and
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):             # <<<<<<<<<<<<<<
 *            memcpy(dst_data, src_data, itemsize * dst_extent)
 *        else:
 */
    __pyx_t_2 = (((size_t)__pyx_v_src_stride) == __pyx_v_itemsize);
    if (__pyx_t_2) {
      __pyx_t_2 = (__pyx_v_itemsize == ((size_t)__pyx_v_dst_stride));
    }
    __pyx_t_3 = (__pyx_t_2 != 0);
    __pyx_t_1 = __pyx_t_3;
    __pyx_L5_bool_binop_done:;
    if (__pyx_t_1) {

      /* "View.MemoryView":1108
 *        if (src_stride > 0 and dst_stride > 0 and
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):
 *            memcpy(dst_data, src_data, itemsize * dst_extent)             # <<<<<<<<<<<<<<
 *        else:
 *            for i in range(dst_extent):
 */
      memcpy(__pyx_v_dst_data, __pyx_v_src_data, (__pyx_v_itemsize * __pyx_v_dst_extent));
      goto __pyx_L4;
    }
    /*else*/ {

      /* "View.MemoryView":1110
 *            memcpy(dst_data, src_data, itemsize * dst_extent)
 *        else:
 *            for i in range(dst_extent):             # <<<<<<<<<<<<<<
 *                memcpy(dst_data, src_data, itemsize)
 *                src_data += src_stride
 */
      __pyx_t_4 = __pyx_v_dst_extent;
      for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
        __pyx_v_i = __pyx_t_5;

        /* "View.MemoryView":1111
 *        else:
 *            for i in range(dst_extent):
 *                memcpy(dst_data, src_data, itemsize)             # <<<<<<<<<<<<<<
 *                src_data += src_stride
 *                dst_data += dst_stride
 */
        memcpy(__pyx_v_dst_data, __pyx_v_src_data, __pyx_v_itemsize);

        /* "View.MemoryView":1112
 *            for i in range(dst_extent):
 *                memcpy(dst_data, src_data, itemsize)
 *                src_data += src_stride             # <<<<<<<<<<<<<<
 *                dst_data += dst_stride
 *     else:
 */
        __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);

        /* "View.MemoryView":1113
 *                memcpy(dst_data, src_data, itemsize)
 *                src_data += src_stride
 *                dst_data += dst_stride             # <<<<<<<<<<<<<<
 *     else:
 *         for i in range(dst_extent):
 */
        __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
      }
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "View.MemoryView":1115
 *                dst_data += dst_stride
 *     else:
 *         for i in range(dst_extent):             # <<<<<<<<<<<<<<
 *             _copy_strided_to_strided(src_data, src_strides + 1,
 *                                      dst_data, dst_strides + 1,
 */
    __pyx_t_4 = __pyx_v_dst_extent;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_v_i = __pyx_t_5;

      /* "View.MemoryView":1116
 *     else:
 *         for i in range(dst_extent):
 *             _copy_strided_to_strided(src_data, src_strides + 1,             # <<<<<<<<<<<<<<
 *                                      dst_data, dst_strides + 1,
 *                                      src_shape + 1, dst_shape + 1,
 */
      _copy_strided_to_strided(__pyx_v_src_data, (__pyx_v_src_strides + 1), __pyx_v_dst_data, (__pyx_v_dst_strides + 1), (__pyx_v_src_shape + 1), (__pyx_v_dst_shape + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize);

      /* "View.MemoryView":1120
 *                                      src_shape + 1, dst_shape + 1,
 *                                      ndim - 1, itemsize)
 *             src_data += src_stride             # <<<<<<<<<<<<<<
 *             dst_data += dst_stride
 * 
 */
      __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);

      /* "View.MemoryView":1121
 *                                      ndim - 1, itemsize)
 *             src_data += src_stride
 *             dst_data += dst_stride             # <<<<<<<<<<<<<<
 * 
 * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,
 */
      __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
    }
  }
  __pyx_L3:;

  /* "View.MemoryView":1093
 * 
 * @cython.cdivision(True)
 * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides,             # <<<<<<<<<<<<<<
 *                                    char *dst_data, Py_ssize_t *dst_strides,
 *                                    Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
 */

  /* function exit code */
}

/* "View.MemoryView":1123
 *             dst_data += dst_stride
 * 
 * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
 *                                   __Pyx_memviewslice *dst,
 *                                   int ndim, size_t itemsize) nogil:
 */

static void copy_strided_to_strided(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize) {

  /* "View.MemoryView":1126
 *                                   __Pyx_memviewslice *dst,
 *                                   int ndim, size_t itemsize) nogil:
 *     _copy_strided_to_strided(src.data, src.strides, dst.data, dst.strides,             # <<<<<<<<<<<<<<
 *                              src.shape, dst.shape, ndim, itemsize)
 * 
 */
  _copy_strided_to_strided(__pyx_v_src->data, __pyx_v_src->strides, __pyx_v_dst->data, __pyx_v_dst->strides, __pyx_v_src->shape, __pyx_v_dst->shape, __pyx_v_ndim, __pyx_v_itemsize);

  /* "View.MemoryView":1123
 *             dst_data += dst_stride
 * 
 * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
 *                                   __Pyx_memviewslice *dst,
 *                                   int ndim, size_t itemsize) nogil:
 */

  /* function exit code */
}

/* "View.MemoryView":1130
 * 
 * @cname('__pyx_memoryview_slice_get_size')
 * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:             # <<<<<<<<<<<<<<
 *     "Return the size of the memory occupied by the slice in number of bytes"
 *     cdef int i
 */

static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_src, int __pyx_v_ndim) {
  int __pyx_v_i;
  Py_ssize_t __pyx_v_size;
  Py_ssize_t __pyx_r;
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;

  /* "View.MemoryView":1133
 *     "Return the size of the memory occupied by the slice in number of bytes"
 *     cdef int i
 *     cdef Py_ssize_t size = src.memview.view.itemsize             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim):
 */
  __pyx_t_1 = __pyx_v_src->memview->view.itemsize;
  __pyx_v_size = __pyx_t_1;

  /* "View.MemoryView":1135
 *     cdef Py_ssize_t size = src.memview.view.itemsize
 * 
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         size *= src.shape[i]
 * 
 */
  __pyx_t_2 = __pyx_v_ndim;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "View.MemoryView":1136
 * 
 *     for i in range(ndim):
 *         size *= src.shape[i]             # <<<<<<<<<<<<<<
 * 
 *     return size
 */
    __pyx_v_size = (__pyx_v_size * (__pyx_v_src->shape[__pyx_v_i]));
  }

  /* "View.MemoryView":1138
 *         size *= src.shape[i]
 * 
 *     return size             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_fill_contig_strides_array')
 */
  __pyx_r = __pyx_v_size;
  goto __pyx_L0;

  /* "View.MemoryView":1130
 * 
 * @cname('__pyx_memoryview_slice_get_size')
 * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:             # <<<<<<<<<<<<<<
 *     "Return the size of the memory occupied by the slice in number of bytes"
 *     cdef int i
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":1141
 * 
 * @cname('__pyx_fill_contig_strides_array')
 * cdef Py_ssize_t fill_contig_strides_array(             # <<<<<<<<<<<<<<
 *                 Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
 *                 int ndim, char order) nogil:
 */

static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, Py_ssize_t __pyx_v_stride, int __pyx_v_ndim, char __pyx_v_order) {
  int __pyx_v_idx;
  Py_ssize_t __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;

  /* "View.MemoryView":1150
 *     cdef int idx
 * 
 *     if order == 'F':             # <<<<<<<<<<<<<<
 *         for idx in range(ndim):
 *             strides[idx] = stride
 */
  __pyx_t_1 = ((__pyx_v_order == 'F') != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1151
 * 
 *     if order == 'F':
 *         for idx in range(ndim):             # <<<<<<<<<<<<<<
 *             strides[idx] = stride
 *             stride = stride * shape[idx]
 */
    __pyx_t_2 = __pyx_v_ndim;
    for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
      __pyx_v_idx = __pyx_t_3;

      /* "View.MemoryView":1152
 *     if order == 'F':
 *         for idx in range(ndim):
 *             strides[idx] = stride             # <<<<<<<<<<<<<<
 *             stride = stride * shape[idx]
 *     else:
 */
      (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;

      /* "View.MemoryView":1153
 *         for idx in range(ndim):
 *             strides[idx] = stride
 *             stride = stride * shape[idx]             # <<<<<<<<<<<<<<
 *     else:
 *         for idx in range(ndim - 1, -1, -1):
 */
      __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
    }
    goto __pyx_L3;
  }
  /*else*/ {

    /* "View.MemoryView":1155
 *             stride = stride * shape[idx]
 *     else:
 *         for idx in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
 *             strides[idx] = stride
 *             stride = stride * shape[idx]
 */
    for (__pyx_t_2 = (__pyx_v_ndim - 1); __pyx_t_2 > -1; __pyx_t_2-=1) {
      __pyx_v_idx = __pyx_t_2;

      /* "View.MemoryView":1156
 *     else:
 *         for idx in range(ndim - 1, -1, -1):
 *             strides[idx] = stride             # <<<<<<<<<<<<<<
 *             stride = stride * shape[idx]
 * 
 */
      (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;

      /* "View.MemoryView":1157
 *         for idx in range(ndim - 1, -1, -1):
 *             strides[idx] = stride
 *             stride = stride * shape[idx]             # <<<<<<<<<<<<<<
 * 
 *     return stride
 */
      __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
    }
  }
  __pyx_L3:;

  /* "View.MemoryView":1159
 *             stride = stride * shape[idx]
 * 
 *     return stride             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_copy_data_to_temp')
 */
  __pyx_r = __pyx_v_stride;
  goto __pyx_L0;

  /* "View.MemoryView":1141
 * 
 * @cname('__pyx_fill_contig_strides_array')
 * cdef Py_ssize_t fill_contig_strides_array(             # <<<<<<<<<<<<<<
 *                 Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
 *                 int ndim, char order) nogil:
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":1162
 * 
 * @cname('__pyx_memoryview_copy_data_to_temp')
 * cdef void *copy_data_to_temp(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
 *                              __Pyx_memviewslice *tmpslice,
 *                              char order,
 */

static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_tmpslice, char __pyx_v_order, int __pyx_v_ndim) {
  int __pyx_v_i;
  void *__pyx_v_result;
  size_t __pyx_v_itemsize;
  size_t __pyx_v_size;
  void *__pyx_r;
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  struct __pyx_memoryview_obj *__pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "View.MemoryView":1173
 *     cdef void *result
 * 
 *     cdef size_t itemsize = src.memview.view.itemsize             # <<<<<<<<<<<<<<
 *     cdef size_t size = slice_get_size(src, ndim)
 * 
 */
  __pyx_t_1 = __pyx_v_src->memview->view.itemsize;
  __pyx_v_itemsize = __pyx_t_1;

  /* "View.MemoryView":1174
 * 
 *     cdef size_t itemsize = src.memview.view.itemsize
 *     cdef size_t size = slice_get_size(src, ndim)             # <<<<<<<<<<<<<<
 * 
 *     result = malloc(size)
 */
  __pyx_v_size = __pyx_memoryview_slice_get_size(__pyx_v_src, __pyx_v_ndim);

  /* "View.MemoryView":1176
 *     cdef size_t size = slice_get_size(src, ndim)
 * 
 *     result = malloc(size)             # <<<<<<<<<<<<<<
 *     if not result:
 *         _err(MemoryError, NULL)
 */
  __pyx_v_result = malloc(__pyx_v_size);

  /* "View.MemoryView":1177
 * 
 *     result = malloc(size)
 *     if not result:             # <<<<<<<<<<<<<<
 *         _err(MemoryError, NULL)
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_result != 0)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1178
 *     result = malloc(size)
 *     if not result:
 *         _err(MemoryError, NULL)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_3 = __pyx_memoryview_err(__pyx_builtin_MemoryError, NULL); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "View.MemoryView":1181
 * 
 * 
 *     tmpslice.data = <char *> result             # <<<<<<<<<<<<<<
 *     tmpslice.memview = src.memview
 *     for i in range(ndim):
 */
  __pyx_v_tmpslice->data = ((char *)__pyx_v_result);

  /* "View.MemoryView":1182
 * 
 *     tmpslice.data = <char *> result
 *     tmpslice.memview = src.memview             # <<<<<<<<<<<<<<
 *     for i in range(ndim):
 *         tmpslice.shape[i] = src.shape[i]
 */
  __pyx_t_4 = __pyx_v_src->memview;
  __pyx_v_tmpslice->memview = __pyx_t_4;

  /* "View.MemoryView":1183
 *     tmpslice.data = <char *> result
 *     tmpslice.memview = src.memview
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         tmpslice.shape[i] = src.shape[i]
 *         tmpslice.suboffsets[i] = -1
 */
  __pyx_t_3 = __pyx_v_ndim;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "View.MemoryView":1184
 *     tmpslice.memview = src.memview
 *     for i in range(ndim):
 *         tmpslice.shape[i] = src.shape[i]             # <<<<<<<<<<<<<<
 *         tmpslice.suboffsets[i] = -1
 * 
 */
    (__pyx_v_tmpslice->shape[__pyx_v_i]) = (__pyx_v_src->shape[__pyx_v_i]);

    /* "View.MemoryView":1185
 *     for i in range(ndim):
 *         tmpslice.shape[i] = src.shape[i]
 *         tmpslice.suboffsets[i] = -1             # <<<<<<<<<<<<<<
 * 
 *     fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize,
 */
    (__pyx_v_tmpslice->suboffsets[__pyx_v_i]) = -1;
  }

  /* "View.MemoryView":1187
 *         tmpslice.suboffsets[i] = -1
 * 
 *     fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize,             # <<<<<<<<<<<<<<
 *                               ndim, order)
 * 
 */
  __pyx_fill_contig_strides_array((&(__pyx_v_tmpslice->shape[0])), (&(__pyx_v_tmpslice->strides[0])), __pyx_v_itemsize, __pyx_v_ndim, __pyx_v_order);

  /* "View.MemoryView":1191
 * 
 * 
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         if tmpslice.shape[i] == 1:
 *             tmpslice.strides[i] = 0
 */
  __pyx_t_3 = __pyx_v_ndim;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "View.MemoryView":1192
 * 
 *     for i in range(ndim):
 *         if tmpslice.shape[i] == 1:             # <<<<<<<<<<<<<<
 *             tmpslice.strides[i] = 0
 * 
 */
    __pyx_t_2 = (((__pyx_v_tmpslice->shape[__pyx_v_i]) == 1) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1193
 *     for i in range(ndim):
 *         if tmpslice.shape[i] == 1:
 *             tmpslice.strides[i] = 0             # <<<<<<<<<<<<<<
 * 
 *     if slice_is_contig(src, order, ndim):
 */
      (__pyx_v_tmpslice->strides[__pyx_v_i]) = 0;
      goto __pyx_L8;
    }
    __pyx_L8:;
  }

  /* "View.MemoryView":1195
 *             tmpslice.strides[i] = 0
 * 
 *     if slice_is_contig(src, order, ndim):             # <<<<<<<<<<<<<<
 *         memcpy(result, src.data, size)
 *     else:
 */
  __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, __pyx_v_order, __pyx_v_ndim) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1196
 * 
 *     if slice_is_contig(src, order, ndim):
 *         memcpy(result, src.data, size)             # <<<<<<<<<<<<<<
 *     else:
 *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)
 */
    memcpy(__pyx_v_result, __pyx_v_src->data, __pyx_v_size);
    goto __pyx_L9;
  }
  /*else*/ {

    /* "View.MemoryView":1198
 *         memcpy(result, src.data, size)
 *     else:
 *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)             # <<<<<<<<<<<<<<
 * 
 *     return result
 */
    copy_strided_to_strided(__pyx_v_src, __pyx_v_tmpslice, __pyx_v_ndim, __pyx_v_itemsize);
  }
  __pyx_L9:;

  /* "View.MemoryView":1200
 *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)
 * 
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "View.MemoryView":1162
 * 
 * @cname('__pyx_memoryview_copy_data_to_temp')
 * cdef void *copy_data_to_temp(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
 *                              __Pyx_memviewslice *tmpslice,
 *                              char order,
 */

  /* function exit code */
  __pyx_L1_error:;
  {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    __Pyx_AddTraceback("View.MemoryView.copy_data_to_temp", __pyx_clineno, __pyx_lineno, __pyx_filename);
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
  }
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":1205
 * 
 * @cname('__pyx_memoryview_err_extents')
 * cdef int _err_extents(int i, Py_ssize_t extent1,             # <<<<<<<<<<<<<<
 *                              Py_ssize_t extent2) except -1 with gil:
 *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
 */

static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent1, Py_ssize_t __pyx_v_extent2) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_err_extents", 0);

  /* "View.MemoryView":1208
 *                              Py_ssize_t extent2) except -1 with gil:
 *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
 *                                                         (i, extent1, extent2))             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_err_dim')
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;

  /* "View.MemoryView":1207
 * cdef int _err_extents(int i, Py_ssize_t extent1,
 *                              Py_ssize_t extent2) except -1 with gil:
 *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %             # <<<<<<<<<<<<<<
 *                                                         (i, extent1, extent2))
 * 
 */
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "View.MemoryView":1205
 * 
 * @cname('__pyx_memoryview_err_extents')
 * cdef int _err_extents(int i, Py_ssize_t extent1,             # <<<<<<<<<<<<<<
 *                              Py_ssize_t extent2) except -1 with gil:
 *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("View.MemoryView._err_extents", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "View.MemoryView":1211
 * 
 * @cname('__pyx_memoryview_err_dim')
 * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:             # <<<<<<<<<<<<<<
 *     raise error(msg.decode('ascii') % dim)
 * 
 */

static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, int __pyx_v_dim) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_err_dim", 0);
  __Pyx_INCREF(__pyx_v_error);

  /* "View.MemoryView":1212
 * @cname('__pyx_memoryview_err_dim')
 * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:
 *     raise error(msg.decode('ascii') % dim)             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_err')
 */
  __pyx_t_2 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dim); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyUnicode_Format(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_v_error);
  __pyx_t_3 = __pyx_v_error; __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL;
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "View.MemoryView":1211
 * 
 * @cname('__pyx_memoryview_err_dim')
 * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:             # <<<<<<<<<<<<<<
 *     raise error(msg.decode('ascii') % dim)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView._err_dim", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_XDECREF(__pyx_v_error);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "View.MemoryView":1215
 * 
 * @cname('__pyx_memoryview_err')
 * cdef int _err(object error, char *msg) except -1 with gil:             # <<<<<<<<<<<<<<
 *     if msg != NULL:
 *         raise error(msg.decode('ascii'))
 */

static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_err", 0);
  __Pyx_INCREF(__pyx_v_error);

  /* "View.MemoryView":1216
 * @cname('__pyx_memoryview_err')
 * cdef int _err(object error, char *msg) except -1 with gil:
 *     if msg != NULL:             # <<<<<<<<<<<<<<
 *         raise error(msg.decode('ascii'))
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_msg != NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1217
 * cdef int _err(object error, char *msg) except -1 with gil:
 *     if msg != NULL:
 *         raise error(msg.decode('ascii'))             # <<<<<<<<<<<<<<
 *     else:
 *         raise error
 */
    __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_error);
    __pyx_t_4 = __pyx_v_error; __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL;
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  /*else*/ {

    /* "View.MemoryView":1219
 *         raise error(msg.decode('ascii'))
 *     else:
 *         raise error             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_copy_contents')
 */
    __Pyx_Raise(__pyx_v_error, 0, 0, 0);
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "View.MemoryView":1215
 * 
 * @cname('__pyx_memoryview_err')
 * cdef int _err(object error, char *msg) except -1 with gil:             # <<<<<<<<<<<<<<
 *     if msg != NULL:
 *         raise error(msg.decode('ascii'))
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("View.MemoryView._err", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_XDECREF(__pyx_v_error);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "View.MemoryView":1222
 * 
 * @cname('__pyx_memoryview_copy_contents')
 * cdef int memoryview_copy_contents(__Pyx_memviewslice src,             # <<<<<<<<<<<<<<
 *                                   __Pyx_memviewslice dst,
 *                                   int src_ndim, int dst_ndim,
 */

static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_memviewslice __pyx_v_dst, int __pyx_v_src_ndim, int __pyx_v_dst_ndim, int __pyx_v_dtype_is_object) {
  void *__pyx_v_tmpdata;
  size_t __pyx_v_itemsize;
  int __pyx_v_i;
  char __pyx_v_order;
  int __pyx_v_broadcasting;
  int __pyx_v_direct_copy;
  __Pyx_memviewslice __pyx_v_tmp;
  int __pyx_v_ndim;
  int __pyx_r;
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  void *__pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "View.MemoryView":1230
 *     Check for overlapping memory and verify the shapes.
 *     """
 *     cdef void *tmpdata = NULL             # <<<<<<<<<<<<<<
 *     cdef size_t itemsize = src.memview.view.itemsize
 *     cdef int i
 */
  __pyx_v_tmpdata = NULL;

  /* "View.MemoryView":1231
 *     """
 *     cdef void *tmpdata = NULL
 *     cdef size_t itemsize = src.memview.view.itemsize             # <<<<<<<<<<<<<<
 *     cdef int i
 *     cdef char order = get_best_order(&src, src_ndim)
 */
  __pyx_t_1 = __pyx_v_src.memview->view.itemsize;
  __pyx_v_itemsize = __pyx_t_1;

  /* "View.MemoryView":1233
 *     cdef size_t itemsize = src.memview.view.itemsize
 *     cdef int i
 *     cdef char order = get_best_order(&src, src_ndim)             # <<<<<<<<<<<<<<
 *     cdef bint broadcasting = False
 *     cdef bint direct_copy = False
 */
  __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_src), __pyx_v_src_ndim);

  /* "View.MemoryView":1234
 *     cdef int i
 *     cdef char order = get_best_order(&src, src_ndim)
 *     cdef bint broadcasting = False             # <<<<<<<<<<<<<<
 *     cdef bint direct_copy = False
 *     cdef __Pyx_memviewslice tmp
 */
  __pyx_v_broadcasting = 0;

  /* "View.MemoryView":1235
 *     cdef char order = get_best_order(&src, src_ndim)
 *     cdef bint broadcasting = False
 *     cdef bint direct_copy = False             # <<<<<<<<<<<<<<
 *     cdef __Pyx_memviewslice tmp
 * 
 */
  __pyx_v_direct_copy = 0;

  /* "View.MemoryView":1238
 *     cdef __Pyx_memviewslice tmp
 * 
 *     if src_ndim < dst_ndim:             # <<<<<<<<<<<<<<
 *         broadcast_leading(&src, src_ndim, dst_ndim)
 *     elif dst_ndim < src_ndim:
 */
  __pyx_t_2 = ((__pyx_v_src_ndim < __pyx_v_dst_ndim) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1239
 * 
 *     if src_ndim < dst_ndim:
 *         broadcast_leading(&src, src_ndim, dst_ndim)             # <<<<<<<<<<<<<<
 *     elif dst_ndim < src_ndim:
 *         broadcast_leading(&dst, dst_ndim, src_ndim)
 */
    __pyx_memoryview_broadcast_leading((&__pyx_v_src), __pyx_v_src_ndim, __pyx_v_dst_ndim);
    goto __pyx_L3;
  }

  /* "View.MemoryView":1240
 *     if src_ndim < dst_ndim:
 *         broadcast_leading(&src, src_ndim, dst_ndim)
 *     elif dst_ndim < src_ndim:             # <<<<<<<<<<<<<<
 *         broadcast_leading(&dst, dst_ndim, src_ndim)
 * 
 */
  __pyx_t_2 = ((__pyx_v_dst_ndim < __pyx_v_src_ndim) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1241
 *         broadcast_leading(&src, src_ndim, dst_ndim)
 *     elif dst_ndim < src_ndim:
 *         broadcast_leading(&dst, dst_ndim, src_ndim)             # <<<<<<<<<<<<<<
 * 
 *     cdef int ndim = max(src_ndim, dst_ndim)
 */
    __pyx_memoryview_broadcast_leading((&__pyx_v_dst), __pyx_v_dst_ndim, __pyx_v_src_ndim);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "View.MemoryView":1243
 *         broadcast_leading(&dst, dst_ndim, src_ndim)
 * 
 *     cdef int ndim = max(src_ndim, dst_ndim)             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim):
 */
  __pyx_t_3 = __pyx_v_dst_ndim;
  __pyx_t_4 = __pyx_v_src_ndim;
  if (((__pyx_t_3 > __pyx_t_4) != 0)) {
    __pyx_t_5 = __pyx_t_3;
  } else {
    __pyx_t_5 = __pyx_t_4;
  }
  __pyx_v_ndim = __pyx_t_5;

  /* "View.MemoryView":1245
 *     cdef int ndim = max(src_ndim, dst_ndim)
 * 
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         if src.shape[i] != dst.shape[i]:
 *             if src.shape[i] == 1:
 */
  __pyx_t_5 = __pyx_v_ndim;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_5; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "View.MemoryView":1246
 * 
 *     for i in range(ndim):
 *         if src.shape[i] != dst.shape[i]:             # <<<<<<<<<<<<<<
 *             if src.shape[i] == 1:
 *                 broadcasting = True
 */
    __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) != (__pyx_v_dst.shape[__pyx_v_i])) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1247
 *     for i in range(ndim):
 *         if src.shape[i] != dst.shape[i]:
 *             if src.shape[i] == 1:             # <<<<<<<<<<<<<<
 *                 broadcasting = True
 *                 src.strides[i] = 0
 */
      __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) == 1) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":1248
 *         if src.shape[i] != dst.shape[i]:
 *             if src.shape[i] == 1:
 *                 broadcasting = True             # <<<<<<<<<<<<<<
 *                 src.strides[i] = 0
 *             else:
 */
        __pyx_v_broadcasting = 1;

        /* "View.MemoryView":1249
 *             if src.shape[i] == 1:
 *                 broadcasting = True
 *                 src.strides[i] = 0             # <<<<<<<<<<<<<<
 *             else:
 *                 _err_extents(i, dst.shape[i], src.shape[i])
 */
        (__pyx_v_src.strides[__pyx_v_i]) = 0;
        goto __pyx_L7;
      }
      /*else*/ {

        /* "View.MemoryView":1251
 *                 src.strides[i] = 0
 *             else:
 *                 _err_extents(i, dst.shape[i], src.shape[i])             # <<<<<<<<<<<<<<
 * 
 *         if src.suboffsets[i] >= 0:
 */
        __pyx_t_4 = __pyx_memoryview_err_extents(__pyx_v_i, (__pyx_v_dst.shape[__pyx_v_i]), (__pyx_v_src.shape[__pyx_v_i])); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L7:;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "View.MemoryView":1253
 *                 _err_extents(i, dst.shape[i], src.shape[i])
 * 
 *         if src.suboffsets[i] >= 0:             # <<<<<<<<<<<<<<
 *             _err_dim(ValueError, "Dimension %d is not direct", i)
 * 
 */
    __pyx_t_2 = (((__pyx_v_src.suboffsets[__pyx_v_i]) >= 0) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1254
 * 
 *         if src.suboffsets[i] >= 0:
 *             _err_dim(ValueError, "Dimension %d is not direct", i)             # <<<<<<<<<<<<<<
 * 
 *     if slices_overlap(&src, &dst, ndim, itemsize):
 */
      __pyx_t_4 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, __pyx_k_Dimension_d_is_not_direct, __pyx_v_i); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L8;
    }
    __pyx_L8:;
  }

  /* "View.MemoryView":1256
 *             _err_dim(ValueError, "Dimension %d is not direct", i)
 * 
 *     if slices_overlap(&src, &dst, ndim, itemsize):             # <<<<<<<<<<<<<<
 * 
 *         if not slice_is_contig(&src, order, ndim):
 */
  __pyx_t_2 = (__pyx_slices_overlap((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1258
 *     if slices_overlap(&src, &dst, ndim, itemsize):
 * 
 *         if not slice_is_contig(&src, order, ndim):             # <<<<<<<<<<<<<<
 *             order = get_best_order(&dst, ndim)
 * 
 */
    __pyx_t_2 = ((!(__pyx_memviewslice_is_contig((&__pyx_v_src), __pyx_v_order, __pyx_v_ndim) != 0)) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1259
 * 
 *         if not slice_is_contig(&src, order, ndim):
 *             order = get_best_order(&dst, ndim)             # <<<<<<<<<<<<<<
 * 
 *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
 */
      __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim);
      goto __pyx_L10;
    }
    __pyx_L10:;

    /* "View.MemoryView":1261
 *             order = get_best_order(&dst, ndim)
 * 
 *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)             # <<<<<<<<<<<<<<
 *         src = tmp
 * 
 */
    __pyx_t_6 = __pyx_memoryview_copy_data_to_temp((&__pyx_v_src), (&__pyx_v_tmp), __pyx_v_order, __pyx_v_ndim); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_tmpdata = __pyx_t_6;

    /* "View.MemoryView":1262
 * 
 *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
 *         src = tmp             # <<<<<<<<<<<<<<
 * 
 *     if not broadcasting:
 */
    __pyx_v_src = __pyx_v_tmp;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "View.MemoryView":1264
 *         src = tmp
 * 
 *     if not broadcasting:             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_broadcasting != 0)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1267
 * 
 * 
 *         if slice_is_contig(&src, 'C', ndim):             # <<<<<<<<<<<<<<
 *             direct_copy = slice_is_contig(&dst, 'C', ndim)
 *         elif slice_is_contig(&src, 'F', ndim):
 */
    __pyx_t_2 = (__pyx_memviewslice_is_contig((&__pyx_v_src), 'C', __pyx_v_ndim) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1268
 * 
 *         if slice_is_contig(&src, 'C', ndim):
 *             direct_copy = slice_is_contig(&dst, 'C', ndim)             # <<<<<<<<<<<<<<
 *         elif slice_is_contig(&src, 'F', ndim):
 *             direct_copy = slice_is_contig(&dst, 'F', ndim)
 */
      __pyx_v_direct_copy = __pyx_memviewslice_is_contig((&__pyx_v_dst), 'C', __pyx_v_ndim);
      goto __pyx_L12;
    }

    /* "View.MemoryView":1269
 *         if slice_is_contig(&src, 'C', ndim):
 *             direct_copy = slice_is_contig(&dst, 'C', ndim)
 *         elif slice_is_contig(&src, 'F', ndim):             # <<<<<<<<<<<<<<
 *             direct_copy = slice_is_contig(&dst, 'F', ndim)
 * 
 */
    __pyx_t_2 = (__pyx_memviewslice_is_contig((&__pyx_v_src), 'F', __pyx_v_ndim) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1270
 *             direct_copy = slice_is_contig(&dst, 'C', ndim)
 *         elif slice_is_contig(&src, 'F', ndim):
 *             direct_copy = slice_is_contig(&dst, 'F', ndim)             # <<<<<<<<<<<<<<
 * 
 *         if direct_copy:
 */
      __pyx_v_direct_copy = __pyx_memviewslice_is_contig((&__pyx_v_dst), 'F', __pyx_v_ndim);
      goto __pyx_L12;
    }
    __pyx_L12:;

    /* "View.MemoryView":1272
 *             direct_copy = slice_is_contig(&dst, 'F', ndim)
 * 
 *         if direct_copy:             # <<<<<<<<<<<<<<
 * 
 *             refcount_copying(&dst, dtype_is_object, ndim, False)
 */
    __pyx_t_2 = (__pyx_v_direct_copy != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1274
 *         if direct_copy:
 * 
 *             refcount_copying(&dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
 *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
 *             refcount_copying(&dst, dtype_is_object, ndim, True)
 */
      __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);

      /* "View.MemoryView":1275
 * 
 *             refcount_copying(&dst, dtype_is_object, ndim, False)
 *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))             # <<<<<<<<<<<<<<
 *             refcount_copying(&dst, dtype_is_object, ndim, True)
 *             free(tmpdata)
 */
      memcpy(__pyx_v_dst.data, __pyx_v_src.data, __pyx_memoryview_slice_get_size((&__pyx_v_src), __pyx_v_ndim));

      /* "View.MemoryView":1276
 *             refcount_copying(&dst, dtype_is_object, ndim, False)
 *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
 *             refcount_copying(&dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
 *             free(tmpdata)
 *             return 0
 */
      __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);

      /* "View.MemoryView":1277
 *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
 *             refcount_copying(&dst, dtype_is_object, ndim, True)
 *             free(tmpdata)             # <<<<<<<<<<<<<<
 *             return 0
 * 
 */
      free(__pyx_v_tmpdata);

      /* "View.MemoryView":1278
 *             refcount_copying(&dst, dtype_is_object, ndim, True)
 *             free(tmpdata)
 *             return 0             # <<<<<<<<<<<<<<
 * 
 *     if order == 'F' == get_best_order(&dst, ndim):
 */
      __pyx_r = 0;
      goto __pyx_L0;
    }
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "View.MemoryView":1280
 *             return 0
 * 
 *     if order == 'F' == get_best_order(&dst, ndim):             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = (__pyx_v_order == 'F');
  if (__pyx_t_2) {
    __pyx_t_2 = ('F' == __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim));
  }
  __pyx_t_7 = (__pyx_t_2 != 0);
  if (__pyx_t_7) {

    /* "View.MemoryView":1283
 * 
 * 
 *         transpose_memslice(&src)             # <<<<<<<<<<<<<<
 *         transpose_memslice(&dst)
 * 
 */
    __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "View.MemoryView":1284
 * 
 *         transpose_memslice(&src)
 *         transpose_memslice(&dst)             # <<<<<<<<<<<<<<
 * 
 *     refcount_copying(&dst, dtype_is_object, ndim, False)
 */
    __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_dst)); if (unlikely(__pyx_t_5 == 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L14;
  }
  __pyx_L14:;

  /* "View.MemoryView":1286
 *         transpose_memslice(&dst)
 * 
 *     refcount_copying(&dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
 *     copy_strided_to_strided(&src, &dst, ndim, itemsize)
 *     refcount_copying(&dst, dtype_is_object, ndim, True)
 */
  __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);

  /* "View.MemoryView":1287
 * 
 *     refcount_copying(&dst, dtype_is_object, ndim, False)
 *     copy_strided_to_strided(&src, &dst, ndim, itemsize)             # <<<<<<<<<<<<<<
 *     refcount_copying(&dst, dtype_is_object, ndim, True)
 * 
 */
  copy_strided_to_strided((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize);

  /* "View.MemoryView":1288
 *     refcount_copying(&dst, dtype_is_object, ndim, False)
 *     copy_strided_to_strided(&src, &dst, ndim, itemsize)
 *     refcount_copying(&dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
 * 
 *     free(tmpdata)
 */
  __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);

  /* "View.MemoryView":1290
 *     refcount_copying(&dst, dtype_is_object, ndim, True)
 * 
 *     free(tmpdata)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
  free(__pyx_v_tmpdata);

  /* "View.MemoryView":1291
 * 
 *     free(tmpdata)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_broadcast_leading')
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "View.MemoryView":1222
 * 
 * @cname('__pyx_memoryview_copy_contents')
 * cdef int memoryview_copy_contents(__Pyx_memviewslice src,             # <<<<<<<<<<<<<<
 *                                   __Pyx_memviewslice dst,
 *                                   int src_ndim, int dst_ndim,
 */

  /* function exit code */
  __pyx_L1_error:;
  {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    __Pyx_AddTraceback("View.MemoryView.memoryview_copy_contents", __pyx_clineno, __pyx_lineno, __pyx_filename);
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
  }
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":1294
 * 
 * @cname('__pyx_memoryview_broadcast_leading')
 * cdef void broadcast_leading(__Pyx_memviewslice *slice,             # <<<<<<<<<<<<<<
 *                             int ndim,
 *                             int ndim_other) nogil:
 */

static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_slice, int __pyx_v_ndim, int __pyx_v_ndim_other) {
  int __pyx_v_i;
  int __pyx_v_offset;
  int __pyx_t_1;
  int __pyx_t_2;

  /* "View.MemoryView":1298
 *                             int ndim_other) nogil:
 *     cdef int i
 *     cdef int offset = ndim_other - ndim             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim - 1, -1, -1):
 */
  __pyx_v_offset = (__pyx_v_ndim_other - __pyx_v_ndim);

  /* "View.MemoryView":1300
 *     cdef int offset = ndim_other - ndim
 * 
 *     for i in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
 *         slice.shape[i + offset] = slice.shape[i]
 *         slice.strides[i + offset] = slice.strides[i]
 */
  for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) {
    __pyx_v_i = __pyx_t_1;

    /* "View.MemoryView":1301
 * 
 *     for i in range(ndim - 1, -1, -1):
 *         slice.shape[i + offset] = slice.shape[i]             # <<<<<<<<<<<<<<
 *         slice.strides[i + offset] = slice.strides[i]
 *         slice.suboffsets[i + offset] = slice.suboffsets[i]
 */
    (__pyx_v_slice->shape[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_slice->shape[__pyx_v_i]);

    /* "View.MemoryView":1302
 *     for i in range(ndim - 1, -1, -1):
 *         slice.shape[i + offset] = slice.shape[i]
 *         slice.strides[i + offset] = slice.strides[i]             # <<<<<<<<<<<<<<
 *         slice.suboffsets[i + offset] = slice.suboffsets[i]
 * 
 */
    (__pyx_v_slice->strides[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_slice->strides[__pyx_v_i]);

    /* "View.MemoryView":1303
 *         slice.shape[i + offset] = slice.shape[i]
 *         slice.strides[i + offset] = slice.strides[i]
 *         slice.suboffsets[i + offset] = slice.suboffsets[i]             # <<<<<<<<<<<<<<
 * 
 *     for i in range(offset):
 */
    (__pyx_v_slice->suboffsets[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_slice->suboffsets[__pyx_v_i]);
  }

  /* "View.MemoryView":1305
 *         slice.suboffsets[i + offset] = slice.suboffsets[i]
 * 
 *     for i in range(offset):             # <<<<<<<<<<<<<<
 *         slice.shape[i] = 1
 *         slice.strides[i] = slice.strides[0]
 */
  __pyx_t_1 = __pyx_v_offset;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "View.MemoryView":1306
 * 
 *     for i in range(offset):
 *         slice.shape[i] = 1             # <<<<<<<<<<<<<<
 *         slice.strides[i] = slice.strides[0]
 *         slice.suboffsets[i] = -1
 */
    (__pyx_v_slice->shape[__pyx_v_i]) = 1;

    /* "View.MemoryView":1307
 *     for i in range(offset):
 *         slice.shape[i] = 1
 *         slice.strides[i] = slice.strides[0]             # <<<<<<<<<<<<<<
 *         slice.suboffsets[i] = -1
 * 
 */
    (__pyx_v_slice->strides[__pyx_v_i]) = (__pyx_v_slice->strides[0]);

    /* "View.MemoryView":1308
 *         slice.shape[i] = 1
 *         slice.strides[i] = slice.strides[0]
 *         slice.suboffsets[i] = -1             # <<<<<<<<<<<<<<
 * 
 * 
 */
    (__pyx_v_slice->suboffsets[__pyx_v_i]) = -1;
  }

  /* "View.MemoryView":1294
 * 
 * @cname('__pyx_memoryview_broadcast_leading')
 * cdef void broadcast_leading(__Pyx_memviewslice *slice,             # <<<<<<<<<<<<<<
 *                             int ndim,
 *                             int ndim_other) nogil:
 */

  /* function exit code */
}

/* "View.MemoryView":1316
 * 
 * @cname('__pyx_memoryview_refcount_copying')
 * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object,             # <<<<<<<<<<<<<<
 *                            int ndim, bint inc) nogil:
 * 
 */

static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_dtype_is_object, int __pyx_v_ndim, int __pyx_v_inc) {
  int __pyx_t_1;

  /* "View.MemoryView":1320
 * 
 * 
 *     if dtype_is_object:             # <<<<<<<<<<<<<<
 *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,
 *                                            dst.strides, ndim, inc)
 */
  __pyx_t_1 = (__pyx_v_dtype_is_object != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1321
 * 
 *     if dtype_is_object:
 *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,             # <<<<<<<<<<<<<<
 *                                            dst.strides, ndim, inc)
 * 
 */
    __pyx_memoryview_refcount_objects_in_slice_with_gil(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_inc);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "View.MemoryView":1316
 * 
 * @cname('__pyx_memoryview_refcount_copying')
 * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object,             # <<<<<<<<<<<<<<
 *                            int ndim, bint inc) nogil:
 * 
 */

  /* function exit code */
}

/* "View.MemoryView":1325
 * 
 * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
 * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                                              Py_ssize_t *strides, int ndim,
 *                                              bint inc) with gil:
 */

static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) {
  __Pyx_RefNannyDeclarations
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("refcount_objects_in_slice_with_gil", 0);

  /* "View.MemoryView":1328
 *                                              Py_ssize_t *strides, int ndim,
 *                                              bint inc) with gil:
 *     refcount_objects_in_slice(data, shape, strides, ndim, inc)             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_refcount_objects_in_slice')
 */
  __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, __pyx_v_shape, __pyx_v_strides, __pyx_v_ndim, __pyx_v_inc);

  /* "View.MemoryView":1325
 * 
 * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
 * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                                              Py_ssize_t *strides, int ndim,
 *                                              bint inc) with gil:
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
}

/* "View.MemoryView":1331
 * 
 * @cname('__pyx_memoryview_refcount_objects_in_slice')
 * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                                     Py_ssize_t *strides, int ndim, bint inc):
 *     cdef Py_ssize_t i
 */

static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) {
  CYTHON_UNUSED Py_ssize_t __pyx_v_i;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("refcount_objects_in_slice", 0);

  /* "View.MemoryView":1335
 *     cdef Py_ssize_t i
 * 
 *     for i in range(shape[0]):             # <<<<<<<<<<<<<<
 *         if ndim == 1:
 *             if inc:
 */
  __pyx_t_1 = (__pyx_v_shape[0]);
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "View.MemoryView":1336
 * 
 *     for i in range(shape[0]):
 *         if ndim == 1:             # <<<<<<<<<<<<<<
 *             if inc:
 *                 Py_INCREF((<PyObject **> data)[0])
 */
    __pyx_t_3 = ((__pyx_v_ndim == 1) != 0);
    if (__pyx_t_3) {

      /* "View.MemoryView":1337
 *     for i in range(shape[0]):
 *         if ndim == 1:
 *             if inc:             # <<<<<<<<<<<<<<
 *                 Py_INCREF((<PyObject **> data)[0])
 *             else:
 */
      __pyx_t_3 = (__pyx_v_inc != 0);
      if (__pyx_t_3) {

        /* "View.MemoryView":1338
 *         if ndim == 1:
 *             if inc:
 *                 Py_INCREF((<PyObject **> data)[0])             # <<<<<<<<<<<<<<
 *             else:
 *                 Py_DECREF((<PyObject **> data)[0])
 */
        Py_INCREF((((PyObject **)__pyx_v_data)[0]));
        goto __pyx_L6;
      }
      /*else*/ {

        /* "View.MemoryView":1340
 *                 Py_INCREF((<PyObject **> data)[0])
 *             else:
 *                 Py_DECREF((<PyObject **> data)[0])             # <<<<<<<<<<<<<<
 *         else:
 *             refcount_objects_in_slice(data, shape + 1, strides + 1,
 */
        Py_DECREF((((PyObject **)__pyx_v_data)[0]));
      }
      __pyx_L6:;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "View.MemoryView":1342
 *                 Py_DECREF((<PyObject **> data)[0])
 *         else:
 *             refcount_objects_in_slice(data, shape + 1, strides + 1,             # <<<<<<<<<<<<<<
 *                                       ndim - 1, inc)
 * 
 */
      __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_inc);
    }
    __pyx_L5:;

    /* "View.MemoryView":1345
 *                                       ndim - 1, inc)
 * 
 *         data += strides[0]             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0]));
  }

  /* "View.MemoryView":1331
 * 
 * @cname('__pyx_memoryview_refcount_objects_in_slice')
 * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                                     Py_ssize_t *strides, int ndim, bint inc):
 *     cdef Py_ssize_t i
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "View.MemoryView":1351
 * 
 * @cname('__pyx_memoryview_slice_assign_scalar')
 * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim,             # <<<<<<<<<<<<<<
 *                               size_t itemsize, void *item,
 *                               bint dtype_is_object) nogil:
 */

static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item, int __pyx_v_dtype_is_object) {

  /* "View.MemoryView":1354
 *                               size_t itemsize, void *item,
 *                               bint dtype_is_object) nogil:
 *     refcount_copying(dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
 *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
 *                          itemsize, item)
 */
  __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 0);

  /* "View.MemoryView":1355
 *                               bint dtype_is_object) nogil:
 *     refcount_copying(dst, dtype_is_object, ndim, False)
 *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,             # <<<<<<<<<<<<<<
 *                          itemsize, item)
 *     refcount_copying(dst, dtype_is_object, ndim, True)
 */
  __pyx_memoryview__slice_assign_scalar(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_itemsize, __pyx_v_item);

  /* "View.MemoryView":1357
 *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
 *                          itemsize, item)
 *     refcount_copying(dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 1);

  /* "View.MemoryView":1351
 * 
 * @cname('__pyx_memoryview_slice_assign_scalar')
 * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim,             # <<<<<<<<<<<<<<
 *                               size_t itemsize, void *item,
 *                               bint dtype_is_object) nogil:
 */

  /* function exit code */
}

/* "View.MemoryView":1361
 * 
 * @cname('__pyx_memoryview__slice_assign_scalar')
 * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                               Py_ssize_t *strides, int ndim,
 *                               size_t itemsize, void *item) nogil:
 */

static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item) {
  CYTHON_UNUSED Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_stride;
  Py_ssize_t __pyx_v_extent;
  int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;

  /* "View.MemoryView":1365
 *                               size_t itemsize, void *item) nogil:
 *     cdef Py_ssize_t i
 *     cdef Py_ssize_t stride = strides[0]             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t extent = shape[0]
 * 
 */
  __pyx_v_stride = (__pyx_v_strides[0]);

  /* "View.MemoryView":1366
 *     cdef Py_ssize_t i
 *     cdef Py_ssize_t stride = strides[0]
 *     cdef Py_ssize_t extent = shape[0]             # <<<<<<<<<<<<<<
 * 
 *     if ndim == 1:
 */
  __pyx_v_extent = (__pyx_v_shape[0]);

  /* "View.MemoryView":1368
 *     cdef Py_ssize_t extent = shape[0]
 * 
 *     if ndim == 1:             # <<<<<<<<<<<<<<
 *         for i in range(extent):
 *             memcpy(data, item, itemsize)
 */
  __pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1369
 * 
 *     if ndim == 1:
 *         for i in range(extent):             # <<<<<<<<<<<<<<
 *             memcpy(data, item, itemsize)
 *             data += stride
 */
    __pyx_t_2 = __pyx_v_extent;
    for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
      __pyx_v_i = __pyx_t_3;

      /* "View.MemoryView":1370
 *     if ndim == 1:
 *         for i in range(extent):
 *             memcpy(data, item, itemsize)             # <<<<<<<<<<<<<<
 *             data += stride
 *     else:
 */
      memcpy(__pyx_v_data, __pyx_v_item, __pyx_v_itemsize);

      /* "View.MemoryView":1371
 *         for i in range(extent):
 *             memcpy(data, item, itemsize)
 *             data += stride             # <<<<<<<<<<<<<<
 *     else:
 *         for i in range(extent):
 */
      __pyx_v_data = (__pyx_v_data + __pyx_v_stride);
    }
    goto __pyx_L3;
  }
  /*else*/ {

    /* "View.MemoryView":1373
 *             data += stride
 *     else:
 *         for i in range(extent):             # <<<<<<<<<<<<<<
 *             _slice_assign_scalar(data, shape + 1, strides + 1,
 *                                 ndim - 1, itemsize, item)
 */
    __pyx_t_2 = __pyx_v_extent;
    for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
      __pyx_v_i = __pyx_t_3;

      /* "View.MemoryView":1374
 *     else:
 *         for i in range(extent):
 *             _slice_assign_scalar(data, shape + 1, strides + 1,             # <<<<<<<<<<<<<<
 *                                 ndim - 1, itemsize, item)
 *             data += stride
 */
      __pyx_memoryview__slice_assign_scalar(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize, __pyx_v_item);

      /* "View.MemoryView":1376
 *             _slice_assign_scalar(data, shape + 1, strides + 1,
 *                                 ndim - 1, itemsize, item)
 *             data += stride             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_v_data = (__pyx_v_data + __pyx_v_stride);
    }
  }
  __pyx_L3:;

  /* "View.MemoryView":1361
 * 
 * @cname('__pyx_memoryview__slice_assign_scalar')
 * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                               Py_ssize_t *strides, int ndim,
 *                               size_t itemsize, void *item) nogil:
 */

  /* function exit code */
}
static struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixD __pyx_vtable_5lurrn_8sparsmat_CSRMatrixD;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_CSRMatrixD(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_CSRMatrixD;
  p->buf = Py_None; Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_CSRMatrixD(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *p = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_61__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->buf);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_CSRMatrixD(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *p = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)o;
  if (p->buf) {
    e = (*v)(p->buf, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_CSRMatrixD(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *p = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)o;
  tmp = ((PyObject*)p->buf);
  p->buf = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5lurrn_8sparsmat_CSRMatrixD(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_CSRMatrixD[] = {
  {"fromVectors", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_3fromVectors, METH_O, 0},
  {"print_csr", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_9print_csr, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_11get_size, METH_NOARGS, 0},
  {"item_iter", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_17item_iter, METH_NOARGS, 0},
  {"to_scipy", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_19to_scipy, METH_NOARGS, 0},
  {"get_maxcol", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_21get_maxcol, METH_NOARGS, 0},
  {"transform_mi", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_23transform_mi, METH_NOARGS, 0},
  {"transform_mi_discount", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_25transform_mi_discount, METH_NOARGS, 0},
  {"transform_ll", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_27transform_ll, METH_NOARGS, 0},
  {"transform_l1", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_29transform_l1, METH_NOARGS, 0},
  {"thresholds_norm", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_31thresholds_norm, METH_O, 0},
  {"thresholds_quantile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_33thresholds_quantile, METH_O, 0},
  {"thresholds_nonzero", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_35thresholds_nonzero, METH_O, 0},
  {"get_quantiles", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_37get_quantiles, METH_O, 0},
  {"apply_threshold", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_39apply_threshold, METH_O, 0},
  {"apply_scaling", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_41apply_scaling, METH_O, 0},
  {"scale_columns", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_43scale_columns, METH_O, 0},
  {"scale_rows", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_45scale_rows, METH_O, 0},
  {"left_marginals", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_47left_marginals, METH_NOARGS, 0},
  {"right_marginals", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_49right_marginals, METH_NOARGS, 0},
  {"right_squared_marginals", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_51right_squared_marginals, METH_NOARGS, 0},
  {"get_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_53get_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"write_binary", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_55write_binary, METH_O, __pyx_doc_5lurrn_8sparsmat_10CSRMatrixD_54write_binary},
  {"transpose", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_57transpose, METH_NOARGS, 0},
  {"__reduce__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_63__reduce__, METH_NOARGS, 0},
  {"__setstate__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_65__setstate__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_CSRMatrixD = {
  __pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_59__add__, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  __pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_5__lshift__, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  __pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_7__ilshift__, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_CSRMatrixD = {
  __pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_13__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5lurrn_8sparsmat_CSRMatrixD, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_CSRMatrixD = {
  __pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_13__len__, /*mp_length*/
  __pyx_pw_5lurrn_8sparsmat_10CSRMatrixD_15__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_CSRMatrixD = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.CSRMatrixD", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_CSRMatrixD, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_CSRMatrixD, /*tp_as_number*/
  &__pyx_tp_as_sequence_CSRMatrixD, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_CSRMatrixD, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_CSRMatrixD, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_CSRMatrixD, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_CSRMatrixD, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_CSRMatrixD, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixI __pyx_vtable_5lurrn_8sparsmat_CSRMatrixI;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_CSRMatrixI(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_CSRMatrixI;
  p->buf = Py_None; Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_CSRMatrixI(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *p = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_61__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->buf);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_CSRMatrixI(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *p = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)o;
  if (p->buf) {
    e = (*v)(p->buf, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_CSRMatrixI(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *p = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)o;
  tmp = ((PyObject*)p->buf);
  p->buf = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5lurrn_8sparsmat_CSRMatrixI(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_CSRMatrixI[] = {
  {"fromVectors", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_3fromVectors, METH_O, 0},
  {"print_csr", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_9print_csr, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_11get_size, METH_NOARGS, 0},
  {"item_iter", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_17item_iter, METH_NOARGS, 0},
  {"to_scipy", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_19to_scipy, METH_NOARGS, 0},
  {"get_maxcol", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_21get_maxcol, METH_NOARGS, 0},
  {"transform_mi", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_23transform_mi, METH_NOARGS, 0},
  {"transform_mi_discount", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_25transform_mi_discount, METH_NOARGS, 0},
  {"transform_ll", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_27transform_ll, METH_NOARGS, 0},
  {"transform_l1", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_29transform_l1, METH_NOARGS, 0},
  {"thresholds_norm", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_31thresholds_norm, METH_O, 0},
  {"thresholds_quantile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_33thresholds_quantile, METH_O, 0},
  {"thresholds_nonzero", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_35thresholds_nonzero, METH_O, 0},
  {"get_quantiles", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_37get_quantiles, METH_O, 0},
  {"apply_threshold", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_39apply_threshold, METH_O, 0},
  {"apply_scaling", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_41apply_scaling, METH_O, 0},
  {"scale_columns", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_43scale_columns, METH_O, 0},
  {"scale_rows", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_45scale_rows, METH_O, 0},
  {"left_marginals", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_47left_marginals, METH_NOARGS, 0},
  {"right_marginals", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_49right_marginals, METH_NOARGS, 0},
  {"right_squared_marginals", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_51right_squared_marginals, METH_NOARGS, 0},
  {"get_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_53get_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"write_binary", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_55write_binary, METH_O, __pyx_doc_5lurrn_8sparsmat_10CSRMatrixI_54write_binary},
  {"transpose", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_57transpose, METH_NOARGS, 0},
  {"__reduce__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_63__reduce__, METH_NOARGS, 0},
  {"__setstate__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_65__setstate__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_CSRMatrixI = {
  __pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_59__add__, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  __pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_5__lshift__, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  __pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_7__ilshift__, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_CSRMatrixI = {
  __pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_13__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5lurrn_8sparsmat_CSRMatrixI, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_CSRMatrixI = {
  __pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_13__len__, /*mp_length*/
  __pyx_pw_5lurrn_8sparsmat_10CSRMatrixI_15__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_CSRMatrixI = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.CSRMatrixI", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_CSRMatrixI, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_CSRMatrixI, /*tp_as_number*/
  &__pyx_tp_as_sequence_CSRMatrixI, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_CSRMatrixI, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_CSRMatrixI, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_CSRMatrixI, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_CSRMatrixI, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_CSRMatrixI, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorI __pyx_vtable_5lurrn_8sparsmat_SparseVectorI;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_SparseVectorI(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorI;
  p->buf = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_SparseVectorI(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *p = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_69__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->buf);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_SparseVectorI(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *p = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)o;
  if (p->buf) {
    e = (*v)(p->buf, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_SparseVectorI(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *p = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)o;
  tmp = ((PyObject*)p->buf);
  p->buf = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5lurrn_8sparsmat_SparseVectorI(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_SparseVectorI[] = {
  {"from_dense", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_3from_dense, METH_O, 0},
  {"dotSelf", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_5dotSelf, METH_NOARGS, 0},
  {"jaccard", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_7jaccard, METH_O, 0},
  {"dotSparse", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_9dotSparse, METH_O, 0},
  {"count_intersection", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_11count_intersection, METH_O, 0},
  {"min_sum", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_13min_sum, METH_O, 0},
  {"cosine", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_15cosine, METH_O, 0},
  {"jsd_unnorm", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_17jsd_unnorm, METH_O, 0},
  {"skew_unnorm", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_19skew_unnorm, METH_VARARGS|METH_KEYWORDS, 0},
  {"norm_l1", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_21norm_l1, METH_NOARGS, 0},
  {"norm_l2", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_23norm_l2, METH_NOARGS, 0},
  {"norm_lp", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_25norm_lp, METH_O, 0},
  {"dotFull", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_27dotFull, METH_O, 0},
  {"dotFull_check", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_29dotFull_check, METH_O, 0},
  {"dotMatrix", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_31dotMatrix, METH_O, 0},
  {"axpy", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_33axpy, METH_VARARGS|METH_KEYWORDS, 0},
  {"sqdist", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_35sqdist, METH_O, __pyx_doc_5lurrn_8sparsmat_13SparseVectorI_34sqdist},
  {"write_pairs", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_37write_pairs, METH_VARARGS|METH_KEYWORDS, 0},
  {"min_vals", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_43min_vals, METH_O, 0},
  {"scale_array", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_45scale_array, METH_O, 0},
  {"__reduce_ex__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_65__reduce_ex__, METH_O, 0},
  {"__setstate__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_67__setstate__, METH_O, 0},
  {"to_scipy", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorI_71to_scipy, METH_NOARGS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SparseVectorI = {
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_51__add__, /*nb_add*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_53__sub__, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_47__div__, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_57__lshift__, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_55__or__, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_39__imul__, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_41__idiv__, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_59__ilshift__, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SparseVectorI = {
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_49__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5lurrn_8sparsmat_SparseVectorI, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SparseVectorI = {
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_49__len__, /*mp_length*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_61__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_SparseVectorI = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.SparseVectorI", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_SparseVectorI, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_63__repr__, /*tp_repr*/
  &__pyx_tp_as_number_SparseVectorI, /*tp_as_number*/
  &__pyx_tp_as_sequence_SparseVectorI, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SparseVectorI, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_SparseVectorI, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_SparseVectorI, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_SparseVectorI, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorI_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_SparseVectorI, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI1 __pyx_vtable_5lurrn_8sparsmat_VecI1;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecI1(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_VecI1 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_VecI1;
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_VecI1(PyObject *o) {
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5lurrn_8sparsmat_5VecI1_41__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_VecI1[] = {
  {"item_iter", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_3item_iter, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_5get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"clear", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_9clear, METH_NOARGS, 0},
  {"get_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_11get_count, METH_O, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_13add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"to_sparse", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_17to_sparse, METH_NOARGS, 0},
  {"tofile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_19tofile, METH_O, 0},
  {"fromfile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_21fromfile, METH_O, 0},
  {"get_maxcol", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_23get_maxcol, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_25get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_27remap, METH_VARARGS|METH_KEYWORDS, 0},
  {"append", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_29append, METH_O, 0},
  {"extend", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_31extend, METH_O, 0},
  {"__reduce__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_35__reduce__, METH_NOARGS, 0},
  {"__setstate__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI1_37__setstate__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VecI1 = {
  __pyx_pw_5lurrn_8sparsmat_5VecI1_15__add__, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VecI1 = {
  __pyx_pw_5lurrn_8sparsmat_5VecI1_7__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VecI1 = {
  __pyx_pw_5lurrn_8sparsmat_5VecI1_7__len__, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_VecI1 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.VecI1", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_VecI1), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_VecI1, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_5lurrn_8sparsmat_5VecI1_39__repr__, /*tp_repr*/
  &__pyx_tp_as_number_VecI1, /*tp_as_number*/
  &__pyx_tp_as_sequence_VecI1, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VecI1, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "mutable sparse int matrix based on item vector", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecI1_33__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_VecI1, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecI1_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_VecI1, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI2 __pyx_vtable_5lurrn_8sparsmat_VecI2;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecI2(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_VecI2 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_VecI2;
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_VecI2(PyObject *o) {
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5lurrn_8sparsmat_5VecI2_41__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_VecI2[] = {
  {"item_iter", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_3item_iter, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_5get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"clear", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_9clear, METH_NOARGS, 0},
  {"get_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_11get_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_13add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"to_csr", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_17to_csr, METH_NOARGS, 0},
  {"tofile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_19tofile, METH_O, 0},
  {"fromfile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_21fromfile, METH_O, 0},
  {"get_maxcol", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_23get_maxcol, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_25get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_27remap, METH_VARARGS|METH_KEYWORDS, 0},
  {"append", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_29append, METH_O, 0},
  {"extend", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_31extend, METH_O, 0},
  {"__reduce__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_35__reduce__, METH_NOARGS, 0},
  {"__setstate__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI2_37__setstate__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VecI2 = {
  __pyx_pw_5lurrn_8sparsmat_5VecI2_15__add__, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VecI2 = {
  __pyx_pw_5lurrn_8sparsmat_5VecI2_7__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VecI2 = {
  __pyx_pw_5lurrn_8sparsmat_5VecI2_7__len__, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_VecI2 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.VecI2", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_VecI2), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_VecI2, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_5lurrn_8sparsmat_5VecI2_39__repr__, /*tp_repr*/
  &__pyx_tp_as_number_VecI2, /*tp_as_number*/
  &__pyx_tp_as_sequence_VecI2, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VecI2, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "mutable sparse int matrix based on item vector", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecI2_33__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_VecI2, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecI2_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_VecI2, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecI3 __pyx_vtable_5lurrn_8sparsmat_VecI3;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecI3(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_VecI3 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_VecI3;
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_VecI3(PyObject *o) {
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5lurrn_8sparsmat_5VecI3_39__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_VecI3[] = {
  {"item_iter", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI3_3item_iter, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI3_5get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"clear", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI3_9clear, METH_NOARGS, 0},
  {"get_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI3_11get_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI3_13add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"tofile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI3_17tofile, METH_O, 0},
  {"fromfile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI3_19fromfile, METH_O, 0},
  {"get_maxcol", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI3_21get_maxcol, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI3_23get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI3_25remap, METH_VARARGS|METH_KEYWORDS, 0},
  {"append", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI3_27append, METH_O, 0},
  {"extend", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI3_29extend, METH_O, 0},
  {"__reduce__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI3_33__reduce__, METH_NOARGS, 0},
  {"__setstate__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecI3_35__setstate__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VecI3 = {
  __pyx_pw_5lurrn_8sparsmat_5VecI3_15__add__, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VecI3 = {
  __pyx_pw_5lurrn_8sparsmat_5VecI3_7__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VecI3 = {
  __pyx_pw_5lurrn_8sparsmat_5VecI3_7__len__, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_VecI3 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.VecI3", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_VecI3), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_VecI3, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_5lurrn_8sparsmat_5VecI3_37__repr__, /*tp_repr*/
  &__pyx_tp_as_number_VecI3, /*tp_as_number*/
  &__pyx_tp_as_sequence_VecI3, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VecI3, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "mutable sparse int matrix based on item vector", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecI3_31__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_VecI3, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecI3_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_VecI3, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsI __pyx_vtable_5lurrn_8sparsmat_SparseVectorsI;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_SparseVectorsI(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorsI;
  p->vecs = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_SparseVectorsI(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *p = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->vecs);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_SparseVectorsI(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *p = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *)o;
  if (p->vecs) {
    e = (*v)(p->vecs, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_SparseVectorsI(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *p = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *)o;
  tmp = ((PyObject*)p->vecs);
  p->vecs = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5lurrn_8sparsmat_SparseVectorsI(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_SparseVectorsI[] = {
  {"to_vec", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_3to_vec, METH_NOARGS, 0},
  {"add", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_5add, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SparseVectorsI = {
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_9__add__, /*nb_add*/
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_11__sub__, /*nb_subtract*/
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_7__mul__, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SparseVectorsI = {
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_13__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5lurrn_8sparsmat_SparseVectorsI, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SparseVectorsI = {
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_13__len__, /*mp_length*/
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_15__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_SparseVectorsI = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.SparseVectorsI", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_SparseVectorsI, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_SparseVectorsI, /*tp_as_number*/
  &__pyx_tp_as_sequence_SparseVectorsI, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SparseVectorsI, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_SparseVectorsI, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_SparseVectorsI, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_SparseVectorsI, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsI_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_SparseVectorsI, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_CSRMatrixF __pyx_vtable_5lurrn_8sparsmat_CSRMatrixF;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_CSRMatrixF(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_CSRMatrixF;
  p->buf = Py_None; Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_CSRMatrixF(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *p = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_61__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->buf);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_CSRMatrixF(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *p = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)o;
  if (p->buf) {
    e = (*v)(p->buf, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_CSRMatrixF(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *p = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)o;
  tmp = ((PyObject*)p->buf);
  p->buf = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5lurrn_8sparsmat_CSRMatrixF(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_CSRMatrixF[] = {
  {"fromVectors", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_3fromVectors, METH_O, 0},
  {"print_csr", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_9print_csr, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_11get_size, METH_NOARGS, 0},
  {"item_iter", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_17item_iter, METH_NOARGS, 0},
  {"to_scipy", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_19to_scipy, METH_NOARGS, 0},
  {"get_maxcol", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_21get_maxcol, METH_NOARGS, 0},
  {"transform_mi", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_23transform_mi, METH_NOARGS, 0},
  {"transform_mi_discount", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_25transform_mi_discount, METH_NOARGS, 0},
  {"transform_ll", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_27transform_ll, METH_NOARGS, 0},
  {"transform_l1", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_29transform_l1, METH_NOARGS, 0},
  {"thresholds_norm", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_31thresholds_norm, METH_O, 0},
  {"thresholds_quantile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_33thresholds_quantile, METH_O, 0},
  {"thresholds_nonzero", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_35thresholds_nonzero, METH_O, 0},
  {"get_quantiles", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_37get_quantiles, METH_O, 0},
  {"apply_threshold", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_39apply_threshold, METH_O, 0},
  {"apply_scaling", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_41apply_scaling, METH_O, 0},
  {"scale_columns", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_43scale_columns, METH_O, 0},
  {"scale_rows", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_45scale_rows, METH_O, 0},
  {"left_marginals", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_47left_marginals, METH_NOARGS, 0},
  {"right_marginals", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_49right_marginals, METH_NOARGS, 0},
  {"right_squared_marginals", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_51right_squared_marginals, METH_NOARGS, 0},
  {"get_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_53get_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"write_binary", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_55write_binary, METH_O, __pyx_doc_5lurrn_8sparsmat_10CSRMatrixF_54write_binary},
  {"transpose", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_57transpose, METH_NOARGS, 0},
  {"__reduce__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_63__reduce__, METH_NOARGS, 0},
  {"__setstate__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_65__setstate__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_CSRMatrixF = {
  __pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_59__add__, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  __pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_5__lshift__, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  __pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_7__ilshift__, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_CSRMatrixF = {
  __pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_13__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5lurrn_8sparsmat_CSRMatrixF, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_CSRMatrixF = {
  __pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_13__len__, /*mp_length*/
  __pyx_pw_5lurrn_8sparsmat_10CSRMatrixF_15__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_CSRMatrixF = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.CSRMatrixF", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_CSRMatrixF, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_CSRMatrixF, /*tp_as_number*/
  &__pyx_tp_as_sequence_CSRMatrixF, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_CSRMatrixF, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_CSRMatrixF, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_CSRMatrixF, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_CSRMatrixF, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_CSRMatrixF, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorF __pyx_vtable_5lurrn_8sparsmat_SparseVectorF;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_SparseVectorF(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorF;
  p->buf = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_SparseVectorF(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *p = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_69__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->buf);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_SparseVectorF(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *p = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)o;
  if (p->buf) {
    e = (*v)(p->buf, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_SparseVectorF(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *p = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)o;
  tmp = ((PyObject*)p->buf);
  p->buf = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5lurrn_8sparsmat_SparseVectorF(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_SparseVectorF[] = {
  {"from_dense", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_3from_dense, METH_O, 0},
  {"dotSelf", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_5dotSelf, METH_NOARGS, 0},
  {"jaccard", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_7jaccard, METH_O, 0},
  {"dotSparse", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_9dotSparse, METH_O, 0},
  {"count_intersection", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_11count_intersection, METH_O, 0},
  {"min_sum", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_13min_sum, METH_O, 0},
  {"cosine", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_15cosine, METH_O, 0},
  {"jsd_unnorm", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_17jsd_unnorm, METH_O, 0},
  {"skew_unnorm", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_19skew_unnorm, METH_VARARGS|METH_KEYWORDS, 0},
  {"norm_l1", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_21norm_l1, METH_NOARGS, 0},
  {"norm_l2", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_23norm_l2, METH_NOARGS, 0},
  {"norm_lp", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_25norm_lp, METH_O, 0},
  {"dotFull", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_27dotFull, METH_O, 0},
  {"dotFull_check", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_29dotFull_check, METH_O, 0},
  {"dotMatrix", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_31dotMatrix, METH_O, 0},
  {"axpy", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_33axpy, METH_VARARGS|METH_KEYWORDS, 0},
  {"sqdist", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_35sqdist, METH_O, __pyx_doc_5lurrn_8sparsmat_13SparseVectorF_34sqdist},
  {"write_pairs", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_37write_pairs, METH_VARARGS|METH_KEYWORDS, 0},
  {"min_vals", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_43min_vals, METH_O, 0},
  {"scale_array", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_45scale_array, METH_O, 0},
  {"__reduce_ex__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_65__reduce_ex__, METH_O, 0},
  {"__setstate__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_67__setstate__, METH_O, 0},
  {"to_scipy", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorF_71to_scipy, METH_NOARGS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SparseVectorF = {
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_51__add__, /*nb_add*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_53__sub__, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_47__div__, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_57__lshift__, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_55__or__, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_39__imul__, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_41__idiv__, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_59__ilshift__, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SparseVectorF = {
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_49__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5lurrn_8sparsmat_SparseVectorF, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SparseVectorF = {
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_49__len__, /*mp_length*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_61__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_SparseVectorF = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.SparseVectorF", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_SparseVectorF, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_63__repr__, /*tp_repr*/
  &__pyx_tp_as_number_SparseVectorF, /*tp_as_number*/
  &__pyx_tp_as_sequence_SparseVectorF, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SparseVectorF, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_SparseVectorF, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_SparseVectorF, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_SparseVectorF, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorF_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_SparseVectorF, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF1 __pyx_vtable_5lurrn_8sparsmat_VecF1;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecF1(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_VecF1 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_VecF1;
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_VecF1(PyObject *o) {
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5lurrn_8sparsmat_5VecF1_41__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_VecF1[] = {
  {"item_iter", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_3item_iter, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_5get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"clear", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_9clear, METH_NOARGS, 0},
  {"get_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_11get_count, METH_O, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_13add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"to_sparse", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_17to_sparse, METH_NOARGS, 0},
  {"tofile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_19tofile, METH_O, 0},
  {"fromfile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_21fromfile, METH_O, 0},
  {"get_maxcol", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_23get_maxcol, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_25get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_27remap, METH_VARARGS|METH_KEYWORDS, 0},
  {"append", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_29append, METH_O, 0},
  {"extend", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_31extend, METH_O, 0},
  {"__reduce__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_35__reduce__, METH_NOARGS, 0},
  {"__setstate__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF1_37__setstate__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VecF1 = {
  __pyx_pw_5lurrn_8sparsmat_5VecF1_15__add__, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VecF1 = {
  __pyx_pw_5lurrn_8sparsmat_5VecF1_7__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VecF1 = {
  __pyx_pw_5lurrn_8sparsmat_5VecF1_7__len__, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_VecF1 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.VecF1", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_VecF1), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_VecF1, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_5lurrn_8sparsmat_5VecF1_39__repr__, /*tp_repr*/
  &__pyx_tp_as_number_VecF1, /*tp_as_number*/
  &__pyx_tp_as_sequence_VecF1, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VecF1, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "mutable sparse int matrix based on item vector", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecF1_33__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_VecF1, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecF1_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_VecF1, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF2 __pyx_vtable_5lurrn_8sparsmat_VecF2;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecF2(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_VecF2 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_VecF2;
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_VecF2(PyObject *o) {
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5lurrn_8sparsmat_5VecF2_41__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_VecF2[] = {
  {"item_iter", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_3item_iter, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_5get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"clear", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_9clear, METH_NOARGS, 0},
  {"get_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_11get_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_13add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"to_csr", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_17to_csr, METH_NOARGS, 0},
  {"tofile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_19tofile, METH_O, 0},
  {"fromfile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_21fromfile, METH_O, 0},
  {"get_maxcol", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_23get_maxcol, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_25get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_27remap, METH_VARARGS|METH_KEYWORDS, 0},
  {"append", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_29append, METH_O, 0},
  {"extend", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_31extend, METH_O, 0},
  {"__reduce__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_35__reduce__, METH_NOARGS, 0},
  {"__setstate__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF2_37__setstate__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VecF2 = {
  __pyx_pw_5lurrn_8sparsmat_5VecF2_15__add__, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VecF2 = {
  __pyx_pw_5lurrn_8sparsmat_5VecF2_7__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VecF2 = {
  __pyx_pw_5lurrn_8sparsmat_5VecF2_7__len__, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_VecF2 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.VecF2", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_VecF2), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_VecF2, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_5lurrn_8sparsmat_5VecF2_39__repr__, /*tp_repr*/
  &__pyx_tp_as_number_VecF2, /*tp_as_number*/
  &__pyx_tp_as_sequence_VecF2, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VecF2, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "mutable sparse int matrix based on item vector", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecF2_33__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_VecF2, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecF2_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_VecF2, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecF3 __pyx_vtable_5lurrn_8sparsmat_VecF3;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecF3(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_VecF3 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_VecF3;
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_VecF3(PyObject *o) {
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5lurrn_8sparsmat_5VecF3_39__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_VecF3[] = {
  {"item_iter", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF3_3item_iter, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF3_5get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"clear", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF3_9clear, METH_NOARGS, 0},
  {"get_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF3_11get_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF3_13add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"tofile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF3_17tofile, METH_O, 0},
  {"fromfile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF3_19fromfile, METH_O, 0},
  {"get_maxcol", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF3_21get_maxcol, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF3_23get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF3_25remap, METH_VARARGS|METH_KEYWORDS, 0},
  {"append", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF3_27append, METH_O, 0},
  {"extend", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF3_29extend, METH_O, 0},
  {"__reduce__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF3_33__reduce__, METH_NOARGS, 0},
  {"__setstate__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecF3_35__setstate__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VecF3 = {
  __pyx_pw_5lurrn_8sparsmat_5VecF3_15__add__, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VecF3 = {
  __pyx_pw_5lurrn_8sparsmat_5VecF3_7__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VecF3 = {
  __pyx_pw_5lurrn_8sparsmat_5VecF3_7__len__, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_VecF3 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.VecF3", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_VecF3), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_VecF3, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_5lurrn_8sparsmat_5VecF3_37__repr__, /*tp_repr*/
  &__pyx_tp_as_number_VecF3, /*tp_as_number*/
  &__pyx_tp_as_sequence_VecF3, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VecF3, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "mutable sparse int matrix based on item vector", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecF3_31__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_VecF3, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecF3_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_VecF3, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsF __pyx_vtable_5lurrn_8sparsmat_SparseVectorsF;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_SparseVectorsF(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorsF;
  p->vecs = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_SparseVectorsF(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *p = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->vecs);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_SparseVectorsF(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *p = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *)o;
  if (p->vecs) {
    e = (*v)(p->vecs, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_SparseVectorsF(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *p = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *)o;
  tmp = ((PyObject*)p->vecs);
  p->vecs = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5lurrn_8sparsmat_SparseVectorsF(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_SparseVectorsF[] = {
  {"to_vec", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_3to_vec, METH_NOARGS, 0},
  {"add", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_5add, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SparseVectorsF = {
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_9__add__, /*nb_add*/
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_11__sub__, /*nb_subtract*/
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_7__mul__, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SparseVectorsF = {
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_13__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5lurrn_8sparsmat_SparseVectorsF, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SparseVectorsF = {
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_13__len__, /*mp_length*/
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_15__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_SparseVectorsF = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.SparseVectorsF", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_SparseVectorsF, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_SparseVectorsF, /*tp_as_number*/
  &__pyx_tp_as_sequence_SparseVectorsF, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SparseVectorsF, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_SparseVectorsF, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_SparseVectorsF, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_SparseVectorsF, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsF_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_SparseVectorsF, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorD __pyx_vtable_5lurrn_8sparsmat_SparseVectorD;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_SparseVectorD(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorD;
  p->buf = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_SparseVectorD(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *p = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_69__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->buf);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_SparseVectorD(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *p = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)o;
  if (p->buf) {
    e = (*v)(p->buf, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_SparseVectorD(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *p = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)o;
  tmp = ((PyObject*)p->buf);
  p->buf = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5lurrn_8sparsmat_SparseVectorD(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_SparseVectorD[] = {
  {"from_dense", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_3from_dense, METH_O, 0},
  {"dotSelf", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_5dotSelf, METH_NOARGS, 0},
  {"jaccard", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_7jaccard, METH_O, 0},
  {"dotSparse", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_9dotSparse, METH_O, 0},
  {"count_intersection", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_11count_intersection, METH_O, 0},
  {"min_sum", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_13min_sum, METH_O, 0},
  {"cosine", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_15cosine, METH_O, 0},
  {"jsd_unnorm", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_17jsd_unnorm, METH_O, 0},
  {"skew_unnorm", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_19skew_unnorm, METH_VARARGS|METH_KEYWORDS, 0},
  {"norm_l1", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_21norm_l1, METH_NOARGS, 0},
  {"norm_l2", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_23norm_l2, METH_NOARGS, 0},
  {"norm_lp", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_25norm_lp, METH_O, 0},
  {"dotFull", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_27dotFull, METH_O, 0},
  {"dotFull_check", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_29dotFull_check, METH_O, 0},
  {"dotMatrix", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_31dotMatrix, METH_O, 0},
  {"axpy", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_33axpy, METH_VARARGS|METH_KEYWORDS, 0},
  {"sqdist", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_35sqdist, METH_O, __pyx_doc_5lurrn_8sparsmat_13SparseVectorD_34sqdist},
  {"write_pairs", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_37write_pairs, METH_VARARGS|METH_KEYWORDS, 0},
  {"min_vals", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_43min_vals, METH_O, 0},
  {"scale_array", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_45scale_array, METH_O, 0},
  {"__reduce_ex__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_65__reduce_ex__, METH_O, 0},
  {"__setstate__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_67__setstate__, METH_O, 0},
  {"to_scipy", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_13SparseVectorD_71to_scipy, METH_NOARGS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SparseVectorD = {
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_51__add__, /*nb_add*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_53__sub__, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_47__div__, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_57__lshift__, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_55__or__, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_39__imul__, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_41__idiv__, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_59__ilshift__, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SparseVectorD = {
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_49__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5lurrn_8sparsmat_SparseVectorD, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SparseVectorD = {
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_49__len__, /*mp_length*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_61__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_SparseVectorD = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.SparseVectorD", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_SparseVectorD, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_63__repr__, /*tp_repr*/
  &__pyx_tp_as_number_SparseVectorD, /*tp_as_number*/
  &__pyx_tp_as_sequence_SparseVectorD, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SparseVectorD, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_SparseVectorD, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_SparseVectorD, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_SparseVectorD, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_13SparseVectorD_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_SparseVectorD, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD1 __pyx_vtable_5lurrn_8sparsmat_VecD1;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecD1(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_VecD1 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_VecD1;
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_VecD1(PyObject *o) {
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5lurrn_8sparsmat_5VecD1_41__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_VecD1[] = {
  {"item_iter", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_3item_iter, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_5get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"clear", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_9clear, METH_NOARGS, 0},
  {"get_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_11get_count, METH_O, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_13add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"to_sparse", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_17to_sparse, METH_NOARGS, 0},
  {"tofile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_19tofile, METH_O, 0},
  {"fromfile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_21fromfile, METH_O, 0},
  {"get_maxcol", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_23get_maxcol, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_25get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_27remap, METH_VARARGS|METH_KEYWORDS, 0},
  {"append", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_29append, METH_O, 0},
  {"extend", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_31extend, METH_O, 0},
  {"__reduce__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_35__reduce__, METH_NOARGS, 0},
  {"__setstate__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD1_37__setstate__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VecD1 = {
  __pyx_pw_5lurrn_8sparsmat_5VecD1_15__add__, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VecD1 = {
  __pyx_pw_5lurrn_8sparsmat_5VecD1_7__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VecD1 = {
  __pyx_pw_5lurrn_8sparsmat_5VecD1_7__len__, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_VecD1 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.VecD1", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_VecD1), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_VecD1, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_5lurrn_8sparsmat_5VecD1_39__repr__, /*tp_repr*/
  &__pyx_tp_as_number_VecD1, /*tp_as_number*/
  &__pyx_tp_as_sequence_VecD1, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VecD1, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "mutable sparse int matrix based on item vector", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecD1_33__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_VecD1, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecD1_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_VecD1, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD2 __pyx_vtable_5lurrn_8sparsmat_VecD2;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecD2(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_VecD2 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_VecD2;
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_VecD2(PyObject *o) {
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5lurrn_8sparsmat_5VecD2_41__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_VecD2[] = {
  {"item_iter", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_3item_iter, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_5get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"clear", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_9clear, METH_NOARGS, 0},
  {"get_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_11get_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_13add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"to_csr", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_17to_csr, METH_NOARGS, 0},
  {"tofile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_19tofile, METH_O, 0},
  {"fromfile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_21fromfile, METH_O, 0},
  {"get_maxcol", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_23get_maxcol, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_25get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_27remap, METH_VARARGS|METH_KEYWORDS, 0},
  {"append", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_29append, METH_O, 0},
  {"extend", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_31extend, METH_O, 0},
  {"__reduce__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_35__reduce__, METH_NOARGS, 0},
  {"__setstate__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD2_37__setstate__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VecD2 = {
  __pyx_pw_5lurrn_8sparsmat_5VecD2_15__add__, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VecD2 = {
  __pyx_pw_5lurrn_8sparsmat_5VecD2_7__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VecD2 = {
  __pyx_pw_5lurrn_8sparsmat_5VecD2_7__len__, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_VecD2 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.VecD2", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_VecD2), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_VecD2, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_5lurrn_8sparsmat_5VecD2_39__repr__, /*tp_repr*/
  &__pyx_tp_as_number_VecD2, /*tp_as_number*/
  &__pyx_tp_as_sequence_VecD2, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VecD2, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "mutable sparse int matrix based on item vector", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecD2_33__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_VecD2, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecD2_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_VecD2, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecD3 __pyx_vtable_5lurrn_8sparsmat_VecD3;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecD3(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_VecD3 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_VecD3;
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_VecD3(PyObject *o) {
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5lurrn_8sparsmat_5VecD3_39__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_VecD3[] = {
  {"item_iter", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD3_3item_iter, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD3_5get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"clear", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD3_9clear, METH_NOARGS, 0},
  {"get_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD3_11get_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD3_13add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"tofile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD3_17tofile, METH_O, 0},
  {"fromfile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD3_19fromfile, METH_O, 0},
  {"get_maxcol", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD3_21get_maxcol, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD3_23get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD3_25remap, METH_VARARGS|METH_KEYWORDS, 0},
  {"append", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD3_27append, METH_O, 0},
  {"extend", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD3_29extend, METH_O, 0},
  {"__reduce__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD3_33__reduce__, METH_NOARGS, 0},
  {"__setstate__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecD3_35__setstate__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VecD3 = {
  __pyx_pw_5lurrn_8sparsmat_5VecD3_15__add__, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VecD3 = {
  __pyx_pw_5lurrn_8sparsmat_5VecD3_7__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VecD3 = {
  __pyx_pw_5lurrn_8sparsmat_5VecD3_7__len__, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_VecD3 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.VecD3", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_VecD3), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_VecD3, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_5lurrn_8sparsmat_5VecD3_37__repr__, /*tp_repr*/
  &__pyx_tp_as_number_VecD3, /*tp_as_number*/
  &__pyx_tp_as_sequence_VecD3, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VecD3, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "mutable sparse int matrix based on item vector", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecD3_31__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_VecD3, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecD3_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_VecD3, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_SparseVectorsD __pyx_vtable_5lurrn_8sparsmat_SparseVectorsD;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_SparseVectorsD(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorsD;
  p->vecs = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_SparseVectorsD(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *p = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->vecs);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_SparseVectorsD(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *p = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *)o;
  if (p->vecs) {
    e = (*v)(p->vecs, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_SparseVectorsD(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *p = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *)o;
  tmp = ((PyObject*)p->vecs);
  p->vecs = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5lurrn_8sparsmat_SparseVectorsD(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_SparseVectorsD[] = {
  {"to_vec", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_3to_vec, METH_NOARGS, 0},
  {"add", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_5add, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SparseVectorsD = {
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_9__add__, /*nb_add*/
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_11__sub__, /*nb_subtract*/
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_7__mul__, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SparseVectorsD = {
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_13__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5lurrn_8sparsmat_SparseVectorsD, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SparseVectorsD = {
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_13__len__, /*mp_length*/
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_15__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_SparseVectorsD = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.SparseVectorsD", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_SparseVectorsD, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_SparseVectorsD, /*tp_as_number*/
  &__pyx_tp_as_sequence_SparseVectorsD, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SparseVectorsD, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_SparseVectorsD, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_SparseVectorsD, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_SparseVectorsD, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_14SparseVectorsD_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_SparseVectorsD, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV1 __pyx_vtable_5lurrn_8sparsmat_VecV1;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecV1(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_VecV1 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_VecV1;
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_VecV1(PyObject *o) {
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5lurrn_8sparsmat_5VecV1_41__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_VecV1[] = {
  {"item_iter", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV1_3item_iter, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV1_5get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"clear", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV1_9clear, METH_NOARGS, 0},
  {"get_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV1_11get_count, METH_O, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV1_13add_count, METH_O, 0},
  {"to_array", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV1_17to_array, METH_NOARGS, 0},
  {"tofile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV1_19tofile, METH_O, 0},
  {"fromfile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV1_21fromfile, METH_O, 0},
  {"get_maxcol", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV1_23get_maxcol, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV1_25get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV1_27remap, METH_VARARGS|METH_KEYWORDS, 0},
  {"append", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV1_29append, METH_O, 0},
  {"extend", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV1_31extend, METH_O, 0},
  {"__reduce__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV1_35__reduce__, METH_NOARGS, 0},
  {"__setstate__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV1_37__setstate__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VecV1 = {
  __pyx_pw_5lurrn_8sparsmat_5VecV1_15__add__, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VecV1 = {
  __pyx_pw_5lurrn_8sparsmat_5VecV1_7__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VecV1 = {
  __pyx_pw_5lurrn_8sparsmat_5VecV1_7__len__, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_VecV1 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.VecV1", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_VecV1), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_VecV1, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_5lurrn_8sparsmat_5VecV1_39__repr__, /*tp_repr*/
  &__pyx_tp_as_number_VecV1, /*tp_as_number*/
  &__pyx_tp_as_sequence_VecV1, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VecV1, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "mutable sparse int matrix based on item vector", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecV1_33__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_VecV1, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecV1_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_VecV1, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV2 __pyx_vtable_5lurrn_8sparsmat_VecV2;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecV2(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_VecV2 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_VecV2;
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_VecV2(PyObject *o) {
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5lurrn_8sparsmat_5VecV2_39__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_VecV2[] = {
  {"item_iter", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV2_3item_iter, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV2_5get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"clear", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV2_9clear, METH_NOARGS, 0},
  {"get_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV2_11get_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV2_13add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"tofile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV2_17tofile, METH_O, 0},
  {"fromfile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV2_19fromfile, METH_O, 0},
  {"get_maxcol", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV2_21get_maxcol, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV2_23get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV2_25remap, METH_VARARGS|METH_KEYWORDS, 0},
  {"append", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV2_27append, METH_O, 0},
  {"extend", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV2_29extend, METH_O, 0},
  {"__reduce__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV2_33__reduce__, METH_NOARGS, 0},
  {"__setstate__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV2_35__setstate__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VecV2 = {
  __pyx_pw_5lurrn_8sparsmat_5VecV2_15__add__, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VecV2 = {
  __pyx_pw_5lurrn_8sparsmat_5VecV2_7__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VecV2 = {
  __pyx_pw_5lurrn_8sparsmat_5VecV2_7__len__, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_VecV2 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.VecV2", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_VecV2), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_VecV2, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_5lurrn_8sparsmat_5VecV2_37__repr__, /*tp_repr*/
  &__pyx_tp_as_number_VecV2, /*tp_as_number*/
  &__pyx_tp_as_sequence_VecV2, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VecV2, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "mutable sparse int matrix based on item vector", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecV2_31__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_VecV2, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecV2_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_VecV2, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_VecV3 __pyx_vtable_5lurrn_8sparsmat_VecV3;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_VecV3(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_VecV3 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_VecV3;
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_VecV3(PyObject *o) {
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5lurrn_8sparsmat_5VecV3_39__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_VecV3[] = {
  {"item_iter", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV3_3item_iter, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV3_5get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"clear", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV3_9clear, METH_NOARGS, 0},
  {"get_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV3_11get_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV3_13add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"tofile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV3_17tofile, METH_O, 0},
  {"fromfile", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV3_19fromfile, METH_O, 0},
  {"get_maxcol", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV3_21get_maxcol, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV3_23get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV3_25remap, METH_VARARGS|METH_KEYWORDS, 0},
  {"append", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV3_27append, METH_O, 0},
  {"extend", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV3_29extend, METH_O, 0},
  {"__reduce__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV3_33__reduce__, METH_NOARGS, 0},
  {"__setstate__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_5VecV3_35__setstate__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VecV3 = {
  __pyx_pw_5lurrn_8sparsmat_5VecV3_15__add__, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VecV3 = {
  __pyx_pw_5lurrn_8sparsmat_5VecV3_7__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VecV3 = {
  __pyx_pw_5lurrn_8sparsmat_5VecV3_7__len__, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_VecV3 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.VecV3", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_VecV3), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_VecV3, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_5lurrn_8sparsmat_5VecV3_37__repr__, /*tp_repr*/
  &__pyx_tp_as_number_VecV3, /*tp_as_number*/
  &__pyx_tp_as_sequence_VecV3, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VecV3, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "mutable sparse int matrix based on item vector", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecV3_31__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_VecV3, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_5VecV3_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_VecV3, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_CSRMatrixI_item_iter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter *)o);
  p->mat = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_CSRMatrixI_item_iter(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->mat);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_CSRMatrixI_item_iter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter *)o;
  if (p->mat) {
    e = (*v)(((PyObject*)p->mat), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_CSRMatrixI_item_iter(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter *)o;
  tmp = ((PyObject*)p->mat);
  p->mat = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_CSRMatrixI_item_iter[] = {
  {"__next__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_20CSRMatrixI_item_iter_5__next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_CSRMatrixI_item_iter = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.CSRMatrixI_item_iter", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI_item_iter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_CSRMatrixI_item_iter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_CSRMatrixI_item_iter, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_CSRMatrixI_item_iter, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_20CSRMatrixI_item_iter_3__iter__, /*tp_iter*/
  __pyx_pw_5lurrn_8sparsmat_20CSRMatrixI_item_iter_5__next__, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_CSRMatrixI_item_iter, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_20CSRMatrixI_item_iter_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_CSRMatrixI_item_iter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_CSRMatrixF_item_iter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter *)o);
  p->mat = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_CSRMatrixF_item_iter(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->mat);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_CSRMatrixF_item_iter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter *)o;
  if (p->mat) {
    e = (*v)(((PyObject*)p->mat), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_CSRMatrixF_item_iter(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter *)o;
  tmp = ((PyObject*)p->mat);
  p->mat = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_CSRMatrixF_item_iter[] = {
  {"__next__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_20CSRMatrixF_item_iter_5__next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_CSRMatrixF_item_iter = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.CSRMatrixF_item_iter", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF_item_iter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_CSRMatrixF_item_iter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_CSRMatrixF_item_iter, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_CSRMatrixF_item_iter, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_20CSRMatrixF_item_iter_3__iter__, /*tp_iter*/
  __pyx_pw_5lurrn_8sparsmat_20CSRMatrixF_item_iter_5__next__, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_CSRMatrixF_item_iter, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_20CSRMatrixF_item_iter_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_CSRMatrixF_item_iter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_CSRMatrixD_item_iter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter *)o);
  p->mat = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_CSRMatrixD_item_iter(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->mat);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_CSRMatrixD_item_iter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter *)o;
  if (p->mat) {
    e = (*v)(((PyObject*)p->mat), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_CSRMatrixD_item_iter(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter *)o;
  tmp = ((PyObject*)p->mat);
  p->mat = ((struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_CSRMatrixD_item_iter[] = {
  {"__next__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_20CSRMatrixD_item_iter_5__next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_CSRMatrixD_item_iter = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.CSRMatrixD_item_iter", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD_item_iter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_CSRMatrixD_item_iter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_CSRMatrixD_item_iter, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_CSRMatrixD_item_iter, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_20CSRMatrixD_item_iter_3__iter__, /*tp_iter*/
  __pyx_pw_5lurrn_8sparsmat_20CSRMatrixD_item_iter_5__next__, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_CSRMatrixD_item_iter, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_20CSRMatrixD_item_iter_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_CSRMatrixD_item_iter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecI1_iter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter *)o);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_IVecI1_iter(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->vec);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_IVecI1_iter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter *)o;
  if (p->vec) {
    e = (*v)(((PyObject*)p->vec), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_IVecI1_iter(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter *)o;
  tmp = ((PyObject*)p->vec);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_IVecI1_iter[] = {
  {"__next__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_11IVecI1_iter_5__next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_IVecI1_iter = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.IVecI1_iter", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_IVecI1_iter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_IVecI1_iter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_IVecI1_iter, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_IVecI1_iter, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecI1_iter_3__iter__, /*tp_iter*/
  __pyx_pw_5lurrn_8sparsmat_11IVecI1_iter_5__next__, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_IVecI1_iter, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecI1_iter_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_IVecI1_iter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecI1(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *)o);
  p->compact = Py_None; Py_INCREF(Py_None);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecI1(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->compact);
  Py_CLEAR(p->loose);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecI1(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *)o;
  if (p->compact) {
    e = (*v)(p->compact, a); if (e) return e;
  }
  if (p->loose) {
    e = (*v)(((PyObject*)p->loose), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_LargeVecI1(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1 *)o;
  tmp = ((PyObject*)p->compact);
  p->compact = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->loose);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI1 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecI1_compact(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecI1_7compact_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecI1_compact(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecI1_7compact_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecI1_7compact_5__del__(o);
  }
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecI1_loose(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecI1_5loose_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecI1_loose(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecI1_5loose_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecI1_5loose_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_LargeVecI1[] = {
  {"ensure_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_3ensure_compact, METH_NOARGS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_5add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_7get_compact, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_9get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_13get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI1_15remap, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5lurrn_8sparsmat_LargeVecI1[] = {
  {(char *)"compact", __pyx_getprop_5lurrn_8sparsmat_10LargeVecI1_compact, __pyx_setprop_5lurrn_8sparsmat_10LargeVecI1_compact, 0, 0},
  {(char *)"loose", __pyx_getprop_5lurrn_8sparsmat_10LargeVecI1_loose, __pyx_setprop_5lurrn_8sparsmat_10LargeVecI1_loose, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_LargeVecI1 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.LargeVecI1", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI1), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecI1, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecI1, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_LargeVecI1, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecI1_11__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_LargeVecI1, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5lurrn_8sparsmat_LargeVecI1, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecI1_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_LargeVecI1, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecI2_iter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter *)o);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_IVecI2_iter(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->vec);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_IVecI2_iter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter *)o;
  if (p->vec) {
    e = (*v)(((PyObject*)p->vec), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_IVecI2_iter(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter *)o;
  tmp = ((PyObject*)p->vec);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_IVecI2_iter[] = {
  {"__next__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_11IVecI2_iter_5__next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_IVecI2_iter = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.IVecI2_iter", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_IVecI2_iter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_IVecI2_iter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_IVecI2_iter, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_IVecI2_iter, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecI2_iter_3__iter__, /*tp_iter*/
  __pyx_pw_5lurrn_8sparsmat_11IVecI2_iter_5__next__, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_IVecI2_iter, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecI2_iter_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_IVecI2_iter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_LargeVecI2 __pyx_vtable_5lurrn_8sparsmat_LargeVecI2;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecI2(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_LargeVecI2;
  p->compact = Py_None; Py_INCREF(Py_None);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecI2(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->compact);
  Py_CLEAR(p->loose);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecI2(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *)o;
  if (p->compact) {
    e = (*v)(p->compact, a); if (e) return e;
  }
  if (p->loose) {
    e = (*v)(((PyObject*)p->loose), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_LargeVecI2(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *)o;
  tmp = ((PyObject*)p->compact);
  p->compact = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->loose);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI2 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecI2_compact(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecI2_7compact_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecI2_compact(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecI2_7compact_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecI2_7compact_5__del__(o);
  }
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecI2_loose(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecI2_5loose_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecI2_loose(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecI2_5loose_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecI2_5loose_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_LargeVecI2[] = {
  {"ensure_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_3ensure_compact, METH_NOARGS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_5add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_7get_compact, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_9get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"to_csr", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_13to_csr, METH_NOARGS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_15get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI2_17remap, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5lurrn_8sparsmat_LargeVecI2[] = {
  {(char *)"compact", __pyx_getprop_5lurrn_8sparsmat_10LargeVecI2_compact, __pyx_setprop_5lurrn_8sparsmat_10LargeVecI2_compact, 0, 0},
  {(char *)"loose", __pyx_getprop_5lurrn_8sparsmat_10LargeVecI2_loose, __pyx_setprop_5lurrn_8sparsmat_10LargeVecI2_loose, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_LargeVecI2 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.LargeVecI2", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecI2, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecI2, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_LargeVecI2, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecI2_11__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_LargeVecI2, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5lurrn_8sparsmat_LargeVecI2, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecI2_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_LargeVecI2, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecI3_iter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter *)o);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_IVecI3_iter(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->vec);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_IVecI3_iter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter *)o;
  if (p->vec) {
    e = (*v)(((PyObject*)p->vec), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_IVecI3_iter(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter *)o;
  tmp = ((PyObject*)p->vec);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_IVecI3_iter[] = {
  {"__next__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_11IVecI3_iter_5__next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_IVecI3_iter = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.IVecI3_iter", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_IVecI3_iter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_IVecI3_iter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_IVecI3_iter, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_IVecI3_iter, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecI3_iter_3__iter__, /*tp_iter*/
  __pyx_pw_5lurrn_8sparsmat_11IVecI3_iter_5__next__, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_IVecI3_iter, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecI3_iter_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_IVecI3_iter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecI3(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *)o);
  p->compact = Py_None; Py_INCREF(Py_None);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecI3(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->compact);
  Py_CLEAR(p->loose);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecI3(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *)o;
  if (p->compact) {
    e = (*v)(p->compact, a); if (e) return e;
  }
  if (p->loose) {
    e = (*v)(((PyObject*)p->loose), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_LargeVecI3(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3 *)o;
  tmp = ((PyObject*)p->compact);
  p->compact = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->loose);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecI3 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecI3_compact(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecI3_7compact_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecI3_compact(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecI3_7compact_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecI3_7compact_5__del__(o);
  }
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecI3_loose(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecI3_5loose_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecI3_loose(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecI3_5loose_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecI3_5loose_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_LargeVecI3[] = {
  {"ensure_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_3ensure_compact, METH_NOARGS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_5add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_7get_compact, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_9get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_13get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecI3_15remap, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5lurrn_8sparsmat_LargeVecI3[] = {
  {(char *)"compact", __pyx_getprop_5lurrn_8sparsmat_10LargeVecI3_compact, __pyx_setprop_5lurrn_8sparsmat_10LargeVecI3_compact, 0, 0},
  {(char *)"loose", __pyx_getprop_5lurrn_8sparsmat_10LargeVecI3_loose, __pyx_setprop_5lurrn_8sparsmat_10LargeVecI3_loose, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_LargeVecI3 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.LargeVecI3", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI3), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecI3, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecI3, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_LargeVecI3, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecI3_11__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_LargeVecI3, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5lurrn_8sparsmat_LargeVecI3, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecI3_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_LargeVecI3, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecF1_iter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter *)o);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_IVecF1_iter(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->vec);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_IVecF1_iter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter *)o;
  if (p->vec) {
    e = (*v)(((PyObject*)p->vec), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_IVecF1_iter(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter *)o;
  tmp = ((PyObject*)p->vec);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_IVecF1_iter[] = {
  {"__next__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_11IVecF1_iter_5__next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_IVecF1_iter = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.IVecF1_iter", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_IVecF1_iter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_IVecF1_iter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_IVecF1_iter, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_IVecF1_iter, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecF1_iter_3__iter__, /*tp_iter*/
  __pyx_pw_5lurrn_8sparsmat_11IVecF1_iter_5__next__, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_IVecF1_iter, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecF1_iter_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_IVecF1_iter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecF1(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *)o);
  p->compact = Py_None; Py_INCREF(Py_None);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecF1(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->compact);
  Py_CLEAR(p->loose);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecF1(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *)o;
  if (p->compact) {
    e = (*v)(p->compact, a); if (e) return e;
  }
  if (p->loose) {
    e = (*v)(((PyObject*)p->loose), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_LargeVecF1(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1 *)o;
  tmp = ((PyObject*)p->compact);
  p->compact = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->loose);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF1 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecF1_compact(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecF1_7compact_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecF1_compact(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecF1_7compact_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecF1_7compact_5__del__(o);
  }
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecF1_loose(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecF1_5loose_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecF1_loose(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecF1_5loose_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecF1_5loose_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_LargeVecF1[] = {
  {"ensure_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_3ensure_compact, METH_NOARGS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_5add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_7get_compact, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_9get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_13get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF1_15remap, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5lurrn_8sparsmat_LargeVecF1[] = {
  {(char *)"compact", __pyx_getprop_5lurrn_8sparsmat_10LargeVecF1_compact, __pyx_setprop_5lurrn_8sparsmat_10LargeVecF1_compact, 0, 0},
  {(char *)"loose", __pyx_getprop_5lurrn_8sparsmat_10LargeVecF1_loose, __pyx_setprop_5lurrn_8sparsmat_10LargeVecF1_loose, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_LargeVecF1 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.LargeVecF1", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF1), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecF1, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecF1, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_LargeVecF1, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecF1_11__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_LargeVecF1, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5lurrn_8sparsmat_LargeVecF1, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecF1_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_LargeVecF1, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecF2_iter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter *)o);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_IVecF2_iter(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->vec);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_IVecF2_iter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter *)o;
  if (p->vec) {
    e = (*v)(((PyObject*)p->vec), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_IVecF2_iter(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter *)o;
  tmp = ((PyObject*)p->vec);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_IVecF2_iter[] = {
  {"__next__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_11IVecF2_iter_5__next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_IVecF2_iter = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.IVecF2_iter", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_IVecF2_iter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_IVecF2_iter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_IVecF2_iter, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_IVecF2_iter, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecF2_iter_3__iter__, /*tp_iter*/
  __pyx_pw_5lurrn_8sparsmat_11IVecF2_iter_5__next__, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_IVecF2_iter, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecF2_iter_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_IVecF2_iter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_LargeVecF2 __pyx_vtable_5lurrn_8sparsmat_LargeVecF2;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecF2(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_LargeVecF2;
  p->compact = Py_None; Py_INCREF(Py_None);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecF2(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->compact);
  Py_CLEAR(p->loose);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecF2(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *)o;
  if (p->compact) {
    e = (*v)(p->compact, a); if (e) return e;
  }
  if (p->loose) {
    e = (*v)(((PyObject*)p->loose), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_LargeVecF2(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *)o;
  tmp = ((PyObject*)p->compact);
  p->compact = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->loose);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF2 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecF2_compact(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecF2_7compact_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecF2_compact(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecF2_7compact_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecF2_7compact_5__del__(o);
  }
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecF2_loose(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecF2_5loose_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecF2_loose(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecF2_5loose_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecF2_5loose_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_LargeVecF2[] = {
  {"ensure_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_3ensure_compact, METH_NOARGS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_5add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_7get_compact, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_9get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"to_csr", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_13to_csr, METH_NOARGS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_15get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF2_17remap, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5lurrn_8sparsmat_LargeVecF2[] = {
  {(char *)"compact", __pyx_getprop_5lurrn_8sparsmat_10LargeVecF2_compact, __pyx_setprop_5lurrn_8sparsmat_10LargeVecF2_compact, 0, 0},
  {(char *)"loose", __pyx_getprop_5lurrn_8sparsmat_10LargeVecF2_loose, __pyx_setprop_5lurrn_8sparsmat_10LargeVecF2_loose, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_LargeVecF2 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.LargeVecF2", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecF2, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecF2, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_LargeVecF2, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecF2_11__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_LargeVecF2, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5lurrn_8sparsmat_LargeVecF2, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecF2_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_LargeVecF2, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecF3_iter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter *)o);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_IVecF3_iter(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->vec);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_IVecF3_iter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter *)o;
  if (p->vec) {
    e = (*v)(((PyObject*)p->vec), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_IVecF3_iter(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter *)o;
  tmp = ((PyObject*)p->vec);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_IVecF3_iter[] = {
  {"__next__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_11IVecF3_iter_5__next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_IVecF3_iter = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.IVecF3_iter", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_IVecF3_iter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_IVecF3_iter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_IVecF3_iter, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_IVecF3_iter, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecF3_iter_3__iter__, /*tp_iter*/
  __pyx_pw_5lurrn_8sparsmat_11IVecF3_iter_5__next__, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_IVecF3_iter, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecF3_iter_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_IVecF3_iter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecF3(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *)o);
  p->compact = Py_None; Py_INCREF(Py_None);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecF3(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->compact);
  Py_CLEAR(p->loose);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecF3(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *)o;
  if (p->compact) {
    e = (*v)(p->compact, a); if (e) return e;
  }
  if (p->loose) {
    e = (*v)(((PyObject*)p->loose), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_LargeVecF3(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3 *)o;
  tmp = ((PyObject*)p->compact);
  p->compact = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->loose);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecF3 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecF3_compact(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecF3_7compact_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecF3_compact(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecF3_7compact_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecF3_7compact_5__del__(o);
  }
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecF3_loose(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecF3_5loose_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecF3_loose(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecF3_5loose_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecF3_5loose_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_LargeVecF3[] = {
  {"ensure_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_3ensure_compact, METH_NOARGS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_5add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_7get_compact, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_9get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_13get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecF3_15remap, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5lurrn_8sparsmat_LargeVecF3[] = {
  {(char *)"compact", __pyx_getprop_5lurrn_8sparsmat_10LargeVecF3_compact, __pyx_setprop_5lurrn_8sparsmat_10LargeVecF3_compact, 0, 0},
  {(char *)"loose", __pyx_getprop_5lurrn_8sparsmat_10LargeVecF3_loose, __pyx_setprop_5lurrn_8sparsmat_10LargeVecF3_loose, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_LargeVecF3 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.LargeVecF3", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF3), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecF3, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecF3, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_LargeVecF3, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecF3_11__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_LargeVecF3, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5lurrn_8sparsmat_LargeVecF3, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecF3_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_LargeVecF3, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecD1_iter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter *)o);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_IVecD1_iter(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->vec);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_IVecD1_iter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter *)o;
  if (p->vec) {
    e = (*v)(((PyObject*)p->vec), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_IVecD1_iter(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter *)o;
  tmp = ((PyObject*)p->vec);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_IVecD1_iter[] = {
  {"__next__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_11IVecD1_iter_5__next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_IVecD1_iter = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.IVecD1_iter", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_IVecD1_iter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_IVecD1_iter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_IVecD1_iter, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_IVecD1_iter, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecD1_iter_3__iter__, /*tp_iter*/
  __pyx_pw_5lurrn_8sparsmat_11IVecD1_iter_5__next__, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_IVecD1_iter, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecD1_iter_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_IVecD1_iter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecD1(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *)o);
  p->compact = Py_None; Py_INCREF(Py_None);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecD1(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->compact);
  Py_CLEAR(p->loose);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecD1(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *)o;
  if (p->compact) {
    e = (*v)(p->compact, a); if (e) return e;
  }
  if (p->loose) {
    e = (*v)(((PyObject*)p->loose), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_LargeVecD1(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1 *)o;
  tmp = ((PyObject*)p->compact);
  p->compact = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->loose);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD1 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecD1_compact(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecD1_7compact_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecD1_compact(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecD1_7compact_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecD1_7compact_5__del__(o);
  }
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecD1_loose(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecD1_5loose_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecD1_loose(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecD1_5loose_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecD1_5loose_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_LargeVecD1[] = {
  {"ensure_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_3ensure_compact, METH_NOARGS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_5add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_7get_compact, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_9get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_13get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD1_15remap, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5lurrn_8sparsmat_LargeVecD1[] = {
  {(char *)"compact", __pyx_getprop_5lurrn_8sparsmat_10LargeVecD1_compact, __pyx_setprop_5lurrn_8sparsmat_10LargeVecD1_compact, 0, 0},
  {(char *)"loose", __pyx_getprop_5lurrn_8sparsmat_10LargeVecD1_loose, __pyx_setprop_5lurrn_8sparsmat_10LargeVecD1_loose, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_LargeVecD1 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.LargeVecD1", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD1), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecD1, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecD1, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_LargeVecD1, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecD1_11__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_LargeVecD1, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5lurrn_8sparsmat_LargeVecD1, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecD1_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_LargeVecD1, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecD2_iter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter *)o);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_IVecD2_iter(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->vec);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_IVecD2_iter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter *)o;
  if (p->vec) {
    e = (*v)(((PyObject*)p->vec), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_IVecD2_iter(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter *)o;
  tmp = ((PyObject*)p->vec);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_IVecD2_iter[] = {
  {"__next__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_11IVecD2_iter_5__next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_IVecD2_iter = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.IVecD2_iter", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_IVecD2_iter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_IVecD2_iter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_IVecD2_iter, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_IVecD2_iter, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecD2_iter_3__iter__, /*tp_iter*/
  __pyx_pw_5lurrn_8sparsmat_11IVecD2_iter_5__next__, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_IVecD2_iter, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecD2_iter_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_IVecD2_iter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_5lurrn_8sparsmat_LargeVecD2 __pyx_vtable_5lurrn_8sparsmat_LargeVecD2;

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecD2(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *)o);
  p->__pyx_vtab = __pyx_vtabptr_5lurrn_8sparsmat_LargeVecD2;
  p->compact = Py_None; Py_INCREF(Py_None);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecD2(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->compact);
  Py_CLEAR(p->loose);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecD2(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *)o;
  if (p->compact) {
    e = (*v)(p->compact, a); if (e) return e;
  }
  if (p->loose) {
    e = (*v)(((PyObject*)p->loose), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_LargeVecD2(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *)o;
  tmp = ((PyObject*)p->compact);
  p->compact = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->loose);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD2 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecD2_compact(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecD2_7compact_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecD2_compact(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecD2_7compact_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecD2_7compact_5__del__(o);
  }
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecD2_loose(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecD2_5loose_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecD2_loose(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecD2_5loose_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecD2_5loose_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_LargeVecD2[] = {
  {"ensure_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_3ensure_compact, METH_NOARGS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_5add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_7get_compact, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_9get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"to_csr", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_13to_csr, METH_NOARGS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_15get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD2_17remap, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5lurrn_8sparsmat_LargeVecD2[] = {
  {(char *)"compact", __pyx_getprop_5lurrn_8sparsmat_10LargeVecD2_compact, __pyx_setprop_5lurrn_8sparsmat_10LargeVecD2_compact, 0, 0},
  {(char *)"loose", __pyx_getprop_5lurrn_8sparsmat_10LargeVecD2_loose, __pyx_setprop_5lurrn_8sparsmat_10LargeVecD2_loose, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_LargeVecD2 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.LargeVecD2", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecD2, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecD2, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_LargeVecD2, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecD2_11__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_LargeVecD2, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5lurrn_8sparsmat_LargeVecD2, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecD2_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_LargeVecD2, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecD3_iter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter *)o);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_IVecD3_iter(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->vec);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_IVecD3_iter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter *)o;
  if (p->vec) {
    e = (*v)(((PyObject*)p->vec), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_IVecD3_iter(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter *)o;
  tmp = ((PyObject*)p->vec);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_IVecD3_iter[] = {
  {"__next__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_11IVecD3_iter_5__next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_IVecD3_iter = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.IVecD3_iter", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_IVecD3_iter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_IVecD3_iter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_IVecD3_iter, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_IVecD3_iter, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecD3_iter_3__iter__, /*tp_iter*/
  __pyx_pw_5lurrn_8sparsmat_11IVecD3_iter_5__next__, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_IVecD3_iter, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecD3_iter_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_IVecD3_iter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecD3(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *)o);
  p->compact = Py_None; Py_INCREF(Py_None);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecD3(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->compact);
  Py_CLEAR(p->loose);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecD3(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *)o;
  if (p->compact) {
    e = (*v)(p->compact, a); if (e) return e;
  }
  if (p->loose) {
    e = (*v)(((PyObject*)p->loose), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_LargeVecD3(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3 *)o;
  tmp = ((PyObject*)p->compact);
  p->compact = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->loose);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecD3 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecD3_compact(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecD3_7compact_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecD3_compact(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecD3_7compact_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecD3_7compact_5__del__(o);
  }
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecD3_loose(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecD3_5loose_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecD3_loose(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecD3_5loose_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecD3_5loose_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_LargeVecD3[] = {
  {"ensure_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_3ensure_compact, METH_NOARGS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_5add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_7get_compact, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_9get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_13get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecD3_15remap, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5lurrn_8sparsmat_LargeVecD3[] = {
  {(char *)"compact", __pyx_getprop_5lurrn_8sparsmat_10LargeVecD3_compact, __pyx_setprop_5lurrn_8sparsmat_10LargeVecD3_compact, 0, 0},
  {(char *)"loose", __pyx_getprop_5lurrn_8sparsmat_10LargeVecD3_loose, __pyx_setprop_5lurrn_8sparsmat_10LargeVecD3_loose, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_LargeVecD3 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.LargeVecD3", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD3), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecD3, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecD3, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_LargeVecD3, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecD3_11__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_LargeVecD3, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5lurrn_8sparsmat_LargeVecD3, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecD3_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_LargeVecD3, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecV1_iter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter *)o);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_IVecV1_iter(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->vec);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_IVecV1_iter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter *)o;
  if (p->vec) {
    e = (*v)(((PyObject*)p->vec), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_IVecV1_iter(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter *)o;
  tmp = ((PyObject*)p->vec);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_IVecV1_iter[] = {
  {"__next__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_11IVecV1_iter_5__next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_IVecV1_iter = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.IVecV1_iter", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_IVecV1_iter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_IVecV1_iter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_IVecV1_iter, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_IVecV1_iter, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecV1_iter_3__iter__, /*tp_iter*/
  __pyx_pw_5lurrn_8sparsmat_11IVecV1_iter_5__next__, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_IVecV1_iter, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecV1_iter_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_IVecV1_iter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecV1(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *)o);
  p->compact = Py_None; Py_INCREF(Py_None);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecV1(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->compact);
  Py_CLEAR(p->loose);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecV1(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *)o;
  if (p->compact) {
    e = (*v)(p->compact, a); if (e) return e;
  }
  if (p->loose) {
    e = (*v)(((PyObject*)p->loose), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_LargeVecV1(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1 *)o;
  tmp = ((PyObject*)p->compact);
  p->compact = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->loose);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV1 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecV1_compact(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecV1_7compact_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecV1_compact(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecV1_7compact_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecV1_7compact_5__del__(o);
  }
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecV1_loose(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecV1_5loose_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecV1_loose(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecV1_5loose_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecV1_5loose_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_LargeVecV1[] = {
  {"ensure_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_3ensure_compact, METH_NOARGS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_5add_count, METH_O, 0},
  {"get_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_7get_compact, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_9get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_13get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecV1_15remap, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5lurrn_8sparsmat_LargeVecV1[] = {
  {(char *)"compact", __pyx_getprop_5lurrn_8sparsmat_10LargeVecV1_compact, __pyx_setprop_5lurrn_8sparsmat_10LargeVecV1_compact, 0, 0},
  {(char *)"loose", __pyx_getprop_5lurrn_8sparsmat_10LargeVecV1_loose, __pyx_setprop_5lurrn_8sparsmat_10LargeVecV1_loose, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_LargeVecV1 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.LargeVecV1", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV1), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecV1, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecV1, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_LargeVecV1, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecV1_11__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_LargeVecV1, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5lurrn_8sparsmat_LargeVecV1, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecV1_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_LargeVecV1, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecV2_iter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter *)o);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_IVecV2_iter(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->vec);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_IVecV2_iter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter *)o;
  if (p->vec) {
    e = (*v)(((PyObject*)p->vec), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_IVecV2_iter(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter *)o;
  tmp = ((PyObject*)p->vec);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_IVecV2_iter[] = {
  {"__next__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_11IVecV2_iter_5__next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_IVecV2_iter = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.IVecV2_iter", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_IVecV2_iter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_IVecV2_iter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_IVecV2_iter, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_IVecV2_iter, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecV2_iter_3__iter__, /*tp_iter*/
  __pyx_pw_5lurrn_8sparsmat_11IVecV2_iter_5__next__, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_IVecV2_iter, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecV2_iter_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_IVecV2_iter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecV2(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *)o);
  p->compact = Py_None; Py_INCREF(Py_None);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecV2(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->compact);
  Py_CLEAR(p->loose);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecV2(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *)o;
  if (p->compact) {
    e = (*v)(p->compact, a); if (e) return e;
  }
  if (p->loose) {
    e = (*v)(((PyObject*)p->loose), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_LargeVecV2(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2 *)o;
  tmp = ((PyObject*)p->compact);
  p->compact = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->loose);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV2 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecV2_compact(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecV2_7compact_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecV2_compact(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecV2_7compact_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecV2_7compact_5__del__(o);
  }
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecV2_loose(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecV2_5loose_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecV2_loose(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecV2_5loose_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecV2_5loose_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_LargeVecV2[] = {
  {"ensure_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_3ensure_compact, METH_NOARGS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_5add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_7get_compact, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_9get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_13get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecV2_15remap, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5lurrn_8sparsmat_LargeVecV2[] = {
  {(char *)"compact", __pyx_getprop_5lurrn_8sparsmat_10LargeVecV2_compact, __pyx_setprop_5lurrn_8sparsmat_10LargeVecV2_compact, 0, 0},
  {(char *)"loose", __pyx_getprop_5lurrn_8sparsmat_10LargeVecV2_loose, __pyx_setprop_5lurrn_8sparsmat_10LargeVecV2_loose, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_LargeVecV2 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.LargeVecV2", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV2), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecV2, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecV2, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_LargeVecV2, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecV2_11__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_LargeVecV2, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5lurrn_8sparsmat_LargeVecV2, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecV2_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_LargeVecV2, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_IVecV3_iter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter *)o);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_IVecV3_iter(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->vec);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_IVecV3_iter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter *)o;
  if (p->vec) {
    e = (*v)(((PyObject*)p->vec), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_IVecV3_iter(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter *p = (struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter *)o;
  tmp = ((PyObject*)p->vec);
  p->vec = ((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_IVecV3_iter[] = {
  {"__next__", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_11IVecV3_iter_5__next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_IVecV3_iter = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.IVecV3_iter", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_IVecV3_iter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_IVecV3_iter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_IVecV3_iter, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_IVecV3_iter, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecV3_iter_3__iter__, /*tp_iter*/
  __pyx_pw_5lurrn_8sparsmat_11IVecV3_iter_5__next__, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_IVecV3_iter, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_11IVecV3_iter_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_IVecV3_iter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5lurrn_8sparsmat_LargeVecV3(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *)o);
  p->compact = Py_None; Py_INCREF(Py_None);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecV3(PyObject *o) {
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->compact);
  Py_CLEAR(p->loose);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecV3(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *)o;
  if (p->compact) {
    e = (*v)(p->compact, a); if (e) return e;
  }
  if (p->loose) {
    e = (*v)(((PyObject*)p->loose), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5lurrn_8sparsmat_LargeVecV3(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *p = (struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3 *)o;
  tmp = ((PyObject*)p->compact);
  p->compact = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->loose);
  p->loose = ((struct __pyx_obj_5lurrn_8sparsmat_VecV3 *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecV3_compact(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecV3_7compact_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecV3_compact(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecV3_7compact_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecV3_7compact_5__del__(o);
  }
}

static PyObject *__pyx_getprop_5lurrn_8sparsmat_10LargeVecV3_loose(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5lurrn_8sparsmat_10LargeVecV3_5loose_1__get__(o);
}

static int __pyx_setprop_5lurrn_8sparsmat_10LargeVecV3_loose(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecV3_5loose_3__set__(o, v);
  }
  else {
    return __pyx_pw_5lurrn_8sparsmat_10LargeVecV3_5loose_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_5lurrn_8sparsmat_LargeVecV3[] = {
  {"ensure_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_3ensure_compact, METH_NOARGS, 0},
  {"add_count", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_5add_count, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_compact", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_7get_compact, METH_NOARGS, 0},
  {"get_size", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_9get_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_type_counts", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_13get_type_counts, METH_VARARGS|METH_KEYWORDS, 0},
  {"remap", (PyCFunction)__pyx_pw_5lurrn_8sparsmat_10LargeVecV3_15remap, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5lurrn_8sparsmat_LargeVecV3[] = {
  {(char *)"compact", __pyx_getprop_5lurrn_8sparsmat_10LargeVecV3_compact, __pyx_setprop_5lurrn_8sparsmat_10LargeVecV3_compact, 0, 0},
  {(char *)"loose", __pyx_getprop_5lurrn_8sparsmat_10LargeVecV3_loose, __pyx_setprop_5lurrn_8sparsmat_10LargeVecV3_loose, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5lurrn_8sparsmat_LargeVecV3 = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.LargeVecV3", /*tp_name*/
  sizeof(struct __pyx_obj_5lurrn_8sparsmat_LargeVecV3), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5lurrn_8sparsmat_LargeVecV3, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5lurrn_8sparsmat_LargeVecV3, /*tp_traverse*/
  __pyx_tp_clear_5lurrn_8sparsmat_LargeVecV3, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecV3_11__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5lurrn_8sparsmat_LargeVecV3, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5lurrn_8sparsmat_LargeVecV3, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5lurrn_8sparsmat_10LargeVecV3_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5lurrn_8sparsmat_LargeVecV3, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_array_obj *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_array_obj *)o);
  p->mode = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_format = ((PyObject*)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_array(PyObject *o) {
  struct __pyx_array_obj *p = (struct __pyx_array_obj *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_array___dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->mode);
  Py_CLEAR(p->_format);
  (*Py_TYPE(o)->tp_free)(o);
}
static PyObject *__pyx_sq_item_array(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_array(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_array___setitem__(o, i, v);
  }
  else {
    PyErr_Format(PyExc_NotImplementedError,
      "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
    return -1;
  }
}

static PyObject *__pyx_tp_getattro_array(PyObject *o, PyObject *n) {
  PyObject *v = PyObject_GenericGetAttr(o, n);
  if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
    PyErr_Clear();
    v = __pyx_array___getattr__(o, n);
  }
  return v;
}

static PyObject *__pyx_getprop___pyx_array_memview(PyObject *o, CYTHON_UNUSED void *x) {
  return get_memview(o);
}

static PyMethodDef __pyx_methods_array[] = {
  {"__getattr__", (PyCFunction)__pyx_array___getattr__, METH_O|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_array[] = {
  {(char *)"memview", __pyx_getprop___pyx_array_memview, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PySequenceMethods __pyx_tp_as_sequence_array = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_array, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_array = {
  0, /*mp_length*/
  __pyx_array___getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_array, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_array = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  __pyx_array_getbuffer, /*bf_getbuffer*/
  0, /*bf_releasebuffer*/
};

static PyTypeObject __pyx_type___pyx_array = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.array", /*tp_name*/
  sizeof(struct __pyx_array_obj), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_array, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  &__pyx_tp_as_sequence_array, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_array, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  __pyx_tp_getattro_array, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_array, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_array, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_array, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_array, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_MemviewEnum_obj *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_MemviewEnum_obj *)o);
  p->name = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_Enum(PyObject *o) {
  struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->name);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_Enum(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
  if (p->name) {
    e = (*v)(p->name, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_Enum(PyObject *o) {
  PyObject* tmp;
  struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
  tmp = ((PyObject*)p->name);
  p->name = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_Enum[] = {
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type___pyx_MemviewEnum = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.Enum", /*tp_name*/
  sizeof(struct __pyx_MemviewEnum_obj), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_Enum, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_MemviewEnum___repr__, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_Enum, /*tp_traverse*/
  __pyx_tp_clear_Enum, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_Enum, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_MemviewEnum___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_Enum, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_memoryview __pyx_vtable_memoryview;

static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_memoryview_obj *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_memoryview_obj *)o);
  p->__pyx_vtab = __pyx_vtabptr_memoryview;
  p->obj = Py_None; Py_INCREF(Py_None);
  p->_size = Py_None; Py_INCREF(Py_None);
  p->_array_interface = Py_None; Py_INCREF(Py_None);
  p->view.obj = NULL;
  if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_memoryview(PyObject *o) {
  struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_memoryview___dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->obj);
  Py_CLEAR(p->_size);
  Py_CLEAR(p->_array_interface);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_memoryview(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
  if (p->obj) {
    e = (*v)(p->obj, a); if (e) return e;
  }
  if (p->_size) {
    e = (*v)(p->_size, a); if (e) return e;
  }
  if (p->_array_interface) {
    e = (*v)(p->_array_interface, a); if (e) return e;
  }
  if (p->view.obj) {
    e = (*v)(p->view.obj, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_memoryview(PyObject *o) {
  PyObject* tmp;
  struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
  tmp = ((PyObject*)p->obj);
  p->obj = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_size);
  p->_size = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_array_interface);
  p->_array_interface = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  Py_CLEAR(p->view.obj);
  return 0;
}
static PyObject *__pyx_sq_item_memoryview(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_memoryview(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_memoryview___setitem__(o, i, v);
  }
  else {
    PyErr_Format(PyExc_NotImplementedError,
      "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
    return -1;
  }
}

static PyObject *__pyx_getprop___pyx_memoryview_T(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryview_transpose(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_base(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryview__get__base(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_shape(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryview_get_shape(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_strides(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryview_get_strides(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_suboffsets(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryview_get_suboffsets(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_ndim(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryview_get_ndim(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_itemsize(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryview_get_itemsize(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_nbytes(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryview_get_nbytes(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_size(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryview_get_size(o);
}

static PyMethodDef __pyx_methods_memoryview[] = {
  {"is_c_contig", (PyCFunction)__pyx_memoryview_is_c_contig, METH_NOARGS, 0},
  {"is_f_contig", (PyCFunction)__pyx_memoryview_is_f_contig, METH_NOARGS, 0},
  {"copy", (PyCFunction)__pyx_memoryview_copy, METH_NOARGS, 0},
  {"copy_fortran", (PyCFunction)__pyx_memoryview_copy_fortran, METH_NOARGS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_memoryview[] = {
  {(char *)"T", __pyx_getprop___pyx_memoryview_T, 0, 0, 0},
  {(char *)"base", __pyx_getprop___pyx_memoryview_base, 0, 0, 0},
  {(char *)"shape", __pyx_getprop___pyx_memoryview_shape, 0, 0, 0},
  {(char *)"strides", __pyx_getprop___pyx_memoryview_strides, 0, 0, 0},
  {(char *)"suboffsets", __pyx_getprop___pyx_memoryview_suboffsets, 0, 0, 0},
  {(char *)"ndim", __pyx_getprop___pyx_memoryview_ndim, 0, 0, 0},
  {(char *)"itemsize", __pyx_getprop___pyx_memoryview_itemsize, 0, 0, 0},
  {(char *)"nbytes", __pyx_getprop___pyx_memoryview_nbytes, 0, 0, 0},
  {(char *)"size", __pyx_getprop___pyx_memoryview_size, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PySequenceMethods __pyx_tp_as_sequence_memoryview = {
  __pyx_memoryview___len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_memoryview, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_memoryview = {
  __pyx_memoryview___len__, /*mp_length*/
  __pyx_memoryview___getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_memoryview, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_memoryview = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  __pyx_memoryview_getbuffer, /*bf_getbuffer*/
  0, /*bf_releasebuffer*/
};

static PyTypeObject __pyx_type___pyx_memoryview = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat.memoryview", /*tp_name*/
  sizeof(struct __pyx_memoryview_obj), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_memoryview, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_memoryview___repr__, /*tp_repr*/
  0, /*tp_as_number*/
  &__pyx_tp_as_sequence_memoryview, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_memoryview, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_memoryview___str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_memoryview, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_memoryview, /*tp_traverse*/
  __pyx_tp_clear_memoryview, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_memoryview, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_memoryview, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_memoryview, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct__memoryviewslice __pyx_vtable__memoryviewslice;

static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_memoryviewslice_obj *p;
  PyObject *o = __pyx_tp_new_memoryview(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_memoryviewslice_obj *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_memoryview*)__pyx_vtabptr__memoryviewslice;
  p->from_object = Py_None; Py_INCREF(Py_None);
  p->from_slice.memview = NULL;
  return o;
}

static void __pyx_tp_dealloc__memoryviewslice(PyObject *o) {
  struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_memoryviewslice___dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->from_object);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_memoryview(o);
}

static int __pyx_tp_traverse__memoryviewslice(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
  e = __pyx_tp_traverse_memoryview(o, v, a); if (e) return e;
  if (p->from_object) {
    e = (*v)(p->from_object, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear__memoryviewslice(PyObject *o) {
  PyObject* tmp;
  struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
  __pyx_tp_clear_memoryview(o);
  tmp = ((PyObject*)p->from_object);
  p->from_object = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  __PYX_XDEC_MEMVIEW(&p->from_slice, 1);
  return 0;
}

static PyObject *__pyx_getprop___pyx_memoryviewslice_base(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryviewslice__get__base(o);
}

static PyMethodDef __pyx_methods__memoryviewslice[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets__memoryviewslice[] = {
  {(char *)"base", __pyx_getprop___pyx_memoryviewslice_base, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type___pyx_memoryviewslice = {
  PyVarObject_HEAD_INIT(0, 0)
  "lurrn.sparsmat._memoryviewslice", /*tp_name*/
  sizeof(struct __pyx_memoryviewslice_obj), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc__memoryviewslice, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_memoryview___repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_memoryview___str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Internal class for passing memoryview slices to Python", /*tp_doc*/
  __pyx_tp_traverse__memoryviewslice, /*tp_traverse*/
  __pyx_tp_clear__memoryviewslice, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods__memoryviewslice, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets__memoryviewslice, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new__memoryviewslice, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
  #if PY_VERSION_HEX < 0x03020000
    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  #else
    PyModuleDef_HEAD_INIT,
  #endif
    "sparsmat",
    0, /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_s_ACCESS_READ, __pyx_k_ACCESS_READ, sizeof(__pyx_k_ACCESS_READ), 0, 0, 1, 1},
  {&__pyx_kp_s_Buffer_view_does_not_expose_stri, __pyx_k_Buffer_view_does_not_expose_stri, sizeof(__pyx_k_Buffer_view_does_not_expose_stri), 0, 0, 1, 0},
  {&__pyx_kp_s_Can_only_create_a_buffer_that_is, __pyx_k_Can_only_create_a_buffer_that_is, sizeof(__pyx_k_Can_only_create_a_buffer_that_is), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_index_with_type_s, __pyx_k_Cannot_index_with_type_s, sizeof(__pyx_k_Cannot_index_with_type_s), 0, 0, 1, 0},
  {&__pyx_n_s_D1, __pyx_k_D1, sizeof(__pyx_k_D1), 0, 0, 1, 1},
  {&__pyx_kp_s_D1_d, __pyx_k_D1_d, sizeof(__pyx_k_D1_d), 0, 0, 1, 0},
  {&__pyx_n_s_D2, __pyx_k_D2, sizeof(__pyx_k_D2), 0, 0, 1, 1},
  {&__pyx_kp_s_D2_d, __pyx_k_D2_d, sizeof(__pyx_k_D2_d), 0, 0, 1, 0},
  {&__pyx_n_s_D3, __pyx_k_D3, sizeof(__pyx_k_D3), 0, 0, 1, 1},
  {&__pyx_kp_s_D3_d, __pyx_k_D3_d, sizeof(__pyx_k_D3_d), 0, 0, 1, 0},
  {&__pyx_n_s_Ellipsis, __pyx_k_Ellipsis, sizeof(__pyx_k_Ellipsis), 0, 0, 1, 1},
  {&__pyx_kp_s_Empty_shape_tuple_for_cython_arr, __pyx_k_Empty_shape_tuple_for_cython_arr, sizeof(__pyx_k_Empty_shape_tuple_for_cython_arr), 0, 0, 1, 0},
  {&__pyx_n_s_F1, __pyx_k_F1, sizeof(__pyx_k_F1), 0, 0, 1, 1},
  {&__pyx_kp_s_F1_d, __pyx_k_F1_d, sizeof(__pyx_k_F1_d), 0, 0, 1, 0},
  {&__pyx_n_s_F2, __pyx_k_F2, sizeof(__pyx_k_F2), 0, 0, 1, 1},
  {&__pyx_kp_s_F2_d, __pyx_k_F2_d, sizeof(__pyx_k_F2_d), 0, 0, 1, 0},
  {&__pyx_n_s_F3, __pyx_k_F3, sizeof(__pyx_k_F3), 0, 0, 1, 1},
  {&__pyx_kp_s_F3_d, __pyx_k_F3_d, sizeof(__pyx_k_F3_d), 0, 0, 1, 0},
  {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0},
  {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0},
  {&__pyx_n_s_I1, __pyx_k_I1, sizeof(__pyx_k_I1), 0, 0, 1, 1},
  {&__pyx_kp_s_I1_d, __pyx_k_I1_d, sizeof(__pyx_k_I1_d), 0, 0, 1, 0},
  {&__pyx_n_s_I2, __pyx_k_I2, sizeof(__pyx_k_I2), 0, 0, 1, 1},
  {&__pyx_kp_s_I2_d, __pyx_k_I2_d, sizeof(__pyx_k_I2_d), 0, 0, 1, 0},
  {&__pyx_n_s_I3, __pyx_k_I3, sizeof(__pyx_k_I3), 0, 0, 1, 1},
  {&__pyx_kp_s_I3_d, __pyx_k_I3_d, sizeof(__pyx_k_I3_d), 0, 0, 1, 0},
  {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
  {&__pyx_kp_s_Indirect_dimensions_not_supporte, __pyx_k_Indirect_dimensions_not_supporte, sizeof(__pyx_k_Indirect_dimensions_not_supporte), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_k_Invalid_mode_expected_c_or_fortr, sizeof(__pyx_k_Invalid_mode_expected_c_or_fortr), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_k_Invalid_shape_in_axis_d_d, sizeof(__pyx_k_Invalid_shape_in_axis_d_d), 0, 0, 1, 0},
  {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
  {&__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_k_MemoryView_of_r_at_0x_x, sizeof(__pyx_k_MemoryView_of_r_at_0x_x), 0, 0, 1, 0},
  {&__pyx_kp_s_MemoryView_of_r_object, __pyx_k_MemoryView_of_r_object, sizeof(__pyx_k_MemoryView_of_r_object), 0, 0, 1, 0},
  {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0},
  {&__pyx_n_b_O, __pyx_k_O, sizeof(__pyx_k_O), 0, 0, 0, 1},
  {&__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_k_Out_of_bounds_on_buffer_access_a, sizeof(__pyx_k_Out_of_bounds_on_buffer_access_a), 0, 0, 1, 0},
  {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  {&__pyx_kp_s_SparseVectorD_s, __pyx_k_SparseVectorD_s, sizeof(__pyx_k_SparseVectorD_s), 0, 0, 1, 0},
  {&__pyx_kp_s_SparseVectorF_s, __pyx_k_SparseVectorF_s, sizeof(__pyx_k_SparseVectorF_s), 0, 0, 1, 0},
  {&__pyx_kp_s_SparseVectorI_s, __pyx_k_SparseVectorI_s, sizeof(__pyx_k_SparseVectorI_s), 0, 0, 1, 0},
  {&__pyx_n_s_StopIteration, __pyx_k_StopIteration, sizeof(__pyx_k_StopIteration), 0, 0, 1, 1},
  {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  {&__pyx_kp_s_Unable_to_convert_item_to_object, __pyx_k_Unable_to_convert_item_to_object, sizeof(__pyx_k_Unable_to_convert_item_to_object), 0, 0, 1, 0},
  {&__pyx_n_s_V1, __pyx_k_V1, sizeof(__pyx_k_V1), 0, 0, 1, 1},
  {&__pyx_kp_s_V1_d, __pyx_k_V1_d, sizeof(__pyx_k_V1_d), 0, 0, 1, 0},
  {&__pyx_n_s_V2, __pyx_k_V2, sizeof(__pyx_k_V2), 0, 0, 1, 1},
  {&__pyx_kp_s_V2_d, __pyx_k_V2_d, sizeof(__pyx_k_V2_d), 0, 0, 1, 0},
  {&__pyx_n_s_V3, __pyx_k_V3, sizeof(__pyx_k_V3), 0, 0, 1, 1},
  {&__pyx_kp_s_V3_d, __pyx_k_V3_d, sizeof(__pyx_k_V3_d), 0, 0, 1, 0},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_kp_s_VecD1_s, __pyx_k_VecD1_s, sizeof(__pyx_k_VecD1_s), 0, 0, 1, 0},
  {&__pyx_kp_s_VecD2_s, __pyx_k_VecD2_s, sizeof(__pyx_k_VecD2_s), 0, 0, 1, 0},
  {&__pyx_kp_s_VecD3_s, __pyx_k_VecD3_s, sizeof(__pyx_k_VecD3_s), 0, 0, 1, 0},
  {&__pyx_kp_s_VecF1_s, __pyx_k_VecF1_s, sizeof(__pyx_k_VecF1_s), 0, 0, 1, 0},
  {&__pyx_kp_s_VecF2_s, __pyx_k_VecF2_s, sizeof(__pyx_k_VecF2_s), 0, 0, 1, 0},
  {&__pyx_kp_s_VecF3_s, __pyx_k_VecF3_s, sizeof(__pyx_k_VecF3_s), 0, 0, 1, 0},
  {&__pyx_kp_s_VecI1_s, __pyx_k_VecI1_s, sizeof(__pyx_k_VecI1_s), 0, 0, 1, 0},
  {&__pyx_kp_s_VecI2_s, __pyx_k_VecI2_s, sizeof(__pyx_k_VecI2_s), 0, 0, 1, 0},
  {&__pyx_kp_s_VecI3_s, __pyx_k_VecI3_s, sizeof(__pyx_k_VecI3_s), 0, 0, 1, 0},
  {&__pyx_kp_s_VecV1_s, __pyx_k_VecV1_s, sizeof(__pyx_k_VecV1_s), 0, 0, 1, 0},
  {&__pyx_kp_s_VecV2_s, __pyx_k_VecV2_s, sizeof(__pyx_k_VecV2_s), 0, 0, 1, 0},
  {&__pyx_kp_s_VecV3_s, __pyx_k_VecV3_s, sizeof(__pyx_k_VecV3_s), 0, 0, 1, 0},
  {&__pyx_kp_s__24, __pyx_k__24, sizeof(__pyx_k__24), 0, 0, 1, 0},
  {&__pyx_kp_s__25, __pyx_k__25, sizeof(__pyx_k__25), 0, 0, 1, 0},
  {&__pyx_kp_s__94, __pyx_k__94, sizeof(__pyx_k__94), 0, 0, 1, 0},
  {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1},
  {&__pyx_n_s_access, __pyx_k_access, sizeof(__pyx_k_access), 0, 0, 1, 1},
  {&__pyx_n_s_add, __pyx_k_add, sizeof(__pyx_k_add), 0, 0, 1, 1},
  {&__pyx_n_s_add_count, __pyx_k_add_count, sizeof(__pyx_k_add_count), 0, 0, 1, 1},
  {&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1},
  {&__pyx_n_s_alpha, __pyx_k_alpha, sizeof(__pyx_k_alpha), 0, 0, 1, 1},
  {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
  {&__pyx_n_s_apply_scaling, __pyx_k_apply_scaling, sizeof(__pyx_k_apply_scaling), 0, 0, 1, 1},
  {&__pyx_n_s_apply_threshold, __pyx_k_apply_threshold, sizeof(__pyx_k_apply_threshold), 0, 0, 1, 1},
  {&__pyx_n_s_astype, __pyx_k_astype, sizeof(__pyx_k_astype), 0, 0, 1, 1},
  {&__pyx_n_s_at, __pyx_k_at, sizeof(__pyx_k_at), 0, 0, 1, 1},
  {&__pyx_n_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 1},
  {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
  {&__pyx_n_s_buf, __pyx_k_buf, sizeof(__pyx_k_buf), 0, 0, 1, 1},
  {&__pyx_n_s_buffer, __pyx_k_buffer, sizeof(__pyx_k_buffer), 0, 0, 1, 1},
  {&__pyx_n_s_buffer_len, __pyx_k_buffer_len, sizeof(__pyx_k_buffer_len), 0, 0, 1, 1},
  {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1},
  {&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1},
  {&__pyx_n_s_c_matD, __pyx_k_c_matD, sizeof(__pyx_k_c_matD), 0, 0, 1, 1},
  {&__pyx_n_s_c_matF, __pyx_k_c_matF, sizeof(__pyx_k_c_matF), 0, 0, 1, 1},
  {&__pyx_n_s_c_matI, __pyx_k_c_matI, sizeof(__pyx_k_c_matI), 0, 0, 1, 1},
  {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
  {&__pyx_n_s_clear, __pyx_k_clear, sizeof(__pyx_k_clear), 0, 0, 1, 1},
  {&__pyx_n_s_compactify, __pyx_k_compactify, sizeof(__pyx_k_compactify), 0, 0, 1, 1},
  {&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0},
  {&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0},
  {&__pyx_n_s_cosine, __pyx_k_cosine, sizeof(__pyx_k_cosine), 0, 0, 1, 1},
  {&__pyx_n_s_counts, __pyx_k_counts, sizeof(__pyx_k_counts), 0, 0, 1, 1},
  {&__pyx_n_s_csrFromBuffer, __pyx_k_csrFromBuffer, sizeof(__pyx_k_csrFromBuffer), 0, 0, 1, 1},
  {&__pyx_n_s_cumsum, __pyx_k_cumsum, sizeof(__pyx_k_cumsum), 0, 0, 1, 1},
  {&__pyx_kp_s_d_s, __pyx_k_d_s, sizeof(__pyx_k_d_s), 0, 0, 1, 0},
  {&__pyx_kp_s_d_s_s, __pyx_k_d_s_s, sizeof(__pyx_k_d_s_s), 0, 0, 1, 0},
  {&__pyx_n_s_delim, __pyx_k_delim, sizeof(__pyx_k_delim), 0, 0, 1, 1},
  {&__pyx_n_s_dotSelf, __pyx_k_dotSelf, sizeof(__pyx_k_dotSelf), 0, 0, 1, 1},
  {&__pyx_n_s_dotSparse, __pyx_k_dotSparse, sizeof(__pyx_k_dotSparse), 0, 0, 1, 1},
  {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1},
  {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1},
  {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1},
  {&__pyx_n_s_ensure_compact, __pyx_k_ensure_compact, sizeof(__pyx_k_ensure_compact), 0, 0, 1, 1},
  {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
  {&__pyx_n_s_extend, __pyx_k_extend, sizeof(__pyx_k_extend), 0, 0, 1, 1},
  {&__pyx_n_s_f, __pyx_k_f, sizeof(__pyx_k_f), 0, 0, 1, 1},
  {&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1},
  {&__pyx_n_s_fileno, __pyx_k_fileno, sizeof(__pyx_k_fileno), 0, 0, 1, 1},
  {&__pyx_n_s_filt, __pyx_k_filt, sizeof(__pyx_k_filt), 0, 0, 1, 1},
  {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
  {&__pyx_n_s_flen, __pyx_k_flen, sizeof(__pyx_k_flen), 0, 0, 1, 1},
  {&__pyx_n_s_float32, __pyx_k_float32, sizeof(__pyx_k_float32), 0, 0, 1, 1},
  {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1},
  {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  {&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1},
  {&__pyx_n_u_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 1, 0, 1},
  {&__pyx_n_s_fromVectors, __pyx_k_fromVectors, sizeof(__pyx_k_fromVectors), 0, 0, 1, 1},
  {&__pyx_n_s_from_dense, __pyx_k_from_dense, sizeof(__pyx_k_from_dense), 0, 0, 1, 1},
  {&__pyx_n_s_get_compact, __pyx_k_get_compact, sizeof(__pyx_k_get_compact), 0, 0, 1, 1},
  {&__pyx_n_s_get_count, __pyx_k_get_count, sizeof(__pyx_k_get_count), 0, 0, 1, 1},
  {&__pyx_n_s_get_maxcol, __pyx_k_get_maxcol, sizeof(__pyx_k_get_maxcol), 0, 0, 1, 1},
  {&__pyx_n_s_get_size, __pyx_k_get_size, sizeof(__pyx_k_get_size), 0, 0, 1, 1},
  {&__pyx_n_s_get_type_counts, __pyx_k_get_type_counts, sizeof(__pyx_k_get_type_counts), 0, 0, 1, 1},
  {&__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_k_got_differing_extents_in_dimensi, sizeof(__pyx_k_got_differing_extents_in_dimensi), 0, 0, 1, 0},
  {&__pyx_kp_s_home_yannick_proj_lurrn_pyx_src, __pyx_k_home_yannick_proj_lurrn_pyx_src, sizeof(__pyx_k_home_yannick_proj_lurrn_pyx_src), 0, 0, 1, 0},
  {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
  {&__pyx_n_s_idx_ptr, __pyx_k_idx_ptr, sizeof(__pyx_k_idx_ptr), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_indices, __pyx_k_indices, sizeof(__pyx_k_indices), 0, 0, 1, 1},
  {&__pyx_n_s_int32, __pyx_k_int32, sizeof(__pyx_k_int32), 0, 0, 1, 1},
  {&__pyx_n_s_item, __pyx_k_item, sizeof(__pyx_k_item), 0, 0, 1, 1},
  {&__pyx_n_s_item_iter, __pyx_k_item_iter, sizeof(__pyx_k_item_iter), 0, 0, 1, 1},
  {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1},
  {&__pyx_kp_s_itemsize_0_for_cython_array, __pyx_k_itemsize_0_for_cython_array, sizeof(__pyx_k_itemsize_0_for_cython_array), 0, 0, 1, 0},
  {&__pyx_n_s_jaccard, __pyx_k_jaccard, sizeof(__pyx_k_jaccard), 0, 0, 1, 1},
  {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
  {&__pyx_n_s_jsd_unnorm, __pyx_k_jsd_unnorm, sizeof(__pyx_k_jsd_unnorm), 0, 0, 1, 1},
  {&__pyx_n_s_k, __pyx_k_k, sizeof(__pyx_k_k), 0, 0, 1, 1},
  {&__pyx_n_s_k0, __pyx_k_k0, sizeof(__pyx_k_k0), 0, 0, 1, 1},
  {&__pyx_n_s_k1, __pyx_k_k1, sizeof(__pyx_k_k1), 0, 0, 1, 1},
  {&__pyx_n_s_k2, __pyx_k_k2, sizeof(__pyx_k_k2), 0, 0, 1, 1},
  {&__pyx_n_s_left_marginals, __pyx_k_left_marginals, sizeof(__pyx_k_left_marginals), 0, 0, 1, 1},
  {&__pyx_n_s_lurrn_sparsmat, __pyx_k_lurrn_sparsmat, sizeof(__pyx_k_lurrn_sparsmat), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_mat, __pyx_k_mat, sizeof(__pyx_k_mat), 0, 0, 1, 1},
  {&__pyx_n_s_mat2, __pyx_k_mat2, sizeof(__pyx_k_mat2), 0, 0, 1, 1},
  {&__pyx_n_s_mat3, __pyx_k_mat3, sizeof(__pyx_k_mat3), 0, 0, 1, 1},
  {&__pyx_n_s_mat4, __pyx_k_mat4, sizeof(__pyx_k_mat4), 0, 0, 1, 1},
  {&__pyx_n_s_mat5, __pyx_k_mat5, sizeof(__pyx_k_mat5), 0, 0, 1, 1},
  {&__pyx_n_s_mat6, __pyx_k_mat6, sizeof(__pyx_k_mat6), 0, 0, 1, 1},
  {&__pyx_n_s_matD, __pyx_k_matD, sizeof(__pyx_k_matD), 0, 0, 1, 1},
  {&__pyx_n_s_matF, __pyx_k_matF, sizeof(__pyx_k_matF), 0, 0, 1, 1},
  {&__pyx_n_s_matI, __pyx_k_matI, sizeof(__pyx_k_matI), 0, 0, 1, 1},
  {&__pyx_kp_s_mat_0_1_d, __pyx_k_mat_0_1_d, sizeof(__pyx_k_mat_0_1_d), 0, 0, 1, 0},
  {&__pyx_n_s_memview, __pyx_k_memview, sizeof(__pyx_k_memview), 0, 0, 1, 1},
  {&__pyx_n_s_min_sum, __pyx_k_min_sum, sizeof(__pyx_k_min_sum), 0, 0, 1, 1},
  {&__pyx_n_s_min_vals, __pyx_k_min_vals, sizeof(__pyx_k_min_vals), 0, 0, 1, 1},
  {&__pyx_n_s_mmap, __pyx_k_mmap, sizeof(__pyx_k_mmap), 0, 0, 1, 1},
  {&__pyx_n_s_mmapCSR, __pyx_k_mmapCSR, sizeof(__pyx_k_mmapCSR), 0, 0, 1, 1},
  {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
  {&__pyx_n_s_my_len, __pyx_k_my_len, sizeof(__pyx_k_my_len), 0, 0, 1, 1},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
  {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0},
  {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0},
  {&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1},
  {&__pyx_n_s_norm_l1, __pyx_k_norm_l1, sizeof(__pyx_k_norm_l1), 0, 0, 1, 1},
  {&__pyx_n_s_norm_l2, __pyx_k_norm_l2, sizeof(__pyx_k_norm_l2), 0, 0, 1, 1},
  {&__pyx_n_s_norm_lp, __pyx_k_norm_lp, sizeof(__pyx_k_norm_lp), 0, 0, 1, 1},
  {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
  {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1},
  {&__pyx_n_s_other, __pyx_k_other, sizeof(__pyx_k_other), 0, 0, 1, 1},
  {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1},
  {&__pyx_n_s_pairs, __pyx_k_pairs, sizeof(__pyx_k_pairs), 0, 0, 1, 1},
  {&__pyx_n_s_print, __pyx_k_print, sizeof(__pyx_k_print), 0, 0, 1, 1},
  {&__pyx_n_s_print_csr, __pyx_k_print_csr, sizeof(__pyx_k_print_csr), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_getbuffer, __pyx_k_pyx_getbuffer, sizeof(__pyx_k_pyx_getbuffer), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_read, __pyx_k_read, sizeof(__pyx_k_read), 0, 0, 1, 1},
  {&__pyx_n_s_readline, __pyx_k_readline, sizeof(__pyx_k_readline), 0, 0, 1, 1},
  {&__pyx_n_s_remap, __pyx_k_remap, sizeof(__pyx_k_remap), 0, 0, 1, 1},
  {&__pyx_n_s_result, __pyx_k_result, sizeof(__pyx_k_result), 0, 0, 1, 1},
  {&__pyx_n_s_right_marginals, __pyx_k_right_marginals, sizeof(__pyx_k_right_marginals), 0, 0, 1, 1},
  {&__pyx_n_s_right_squared_marginals, __pyx_k_right_squared_marginals, sizeof(__pyx_k_right_squared_marginals), 0, 0, 1, 1},
  {&__pyx_n_s_run_test, __pyx_k_run_test, sizeof(__pyx_k_run_test), 0, 0, 1, 1},
  {&__pyx_n_s_seek, __pyx_k_seek, sizeof(__pyx_k_seek), 0, 0, 1, 1},
  {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
  {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
  {&__pyx_n_s_skew_unnorm, __pyx_k_skew_unnorm, sizeof(__pyx_k_skew_unnorm), 0, 0, 1, 1},
  {&__pyx_n_s_sort, __pyx_k_sort, sizeof(__pyx_k_sort), 0, 0, 1, 1},
  {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
  {&__pyx_n_s_sqdist, __pyx_k_sqdist, sizeof(__pyx_k_sqdist), 0, 0, 1, 1},
  {&__pyx_n_s_sqrt, __pyx_k_sqrt, sizeof(__pyx_k_sqrt), 0, 0, 1, 1},
  {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
  {&__pyx_n_s_step, __pyx_k_step, sizeof(__pyx_k_step), 0, 0, 1, 1},
  {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
  {&__pyx_kp_s_strided_and_direct, __pyx_k_strided_and_direct, sizeof(__pyx_k_strided_and_direct), 0, 0, 1, 0},
  {&__pyx_kp_s_strided_and_direct_or_indirect, __pyx_k_strided_and_direct_or_indirect, sizeof(__pyx_k_strided_and_direct_or_indirect), 0, 0, 1, 0},
  {&__pyx_kp_s_strided_and_indirect, __pyx_k_strided_and_indirect, sizeof(__pyx_k_strided_and_indirect), 0, 0, 1, 0},
  {&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1},
  {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1},
  {&__pyx_n_s_sum, __pyx_k_sum, sizeof(__pyx_k_sum), 0, 0, 1, 1},
  {&__pyx_n_s_sv, __pyx_k_sv, sizeof(__pyx_k_sv), 0, 0, 1, 1},
  {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
  {&__pyx_n_s_tcode, __pyx_k_tcode, sizeof(__pyx_k_tcode), 0, 0, 1, 1},
  {&__pyx_n_s_tell, __pyx_k_tell, sizeof(__pyx_k_tell), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_tmp, __pyx_k_tmp, sizeof(__pyx_k_tmp), 0, 0, 1, 1},
  {&__pyx_kp_s_tmp_mat3, __pyx_k_tmp_mat3, sizeof(__pyx_k_tmp_mat3), 0, 0, 1, 0},
  {&__pyx_n_s_to_csr, __pyx_k_to_csr, sizeof(__pyx_k_to_csr), 0, 0, 1, 1},
  {&__pyx_n_s_to_sparse, __pyx_k_to_sparse, sizeof(__pyx_k_to_sparse), 0, 0, 1, 1},
  {&__pyx_n_s_to_vec, __pyx_k_to_vec, sizeof(__pyx_k_to_vec), 0, 0, 1, 1},
  {&__pyx_n_s_transform_l1, __pyx_k_transform_l1, sizeof(__pyx_k_transform_l1), 0, 0, 1, 1},
  {&__pyx_n_s_transform_ll, __pyx_k_transform_ll, sizeof(__pyx_k_transform_ll), 0, 0, 1, 1},
  {&__pyx_n_s_transform_mi, __pyx_k_transform_mi, sizeof(__pyx_k_transform_mi), 0, 0, 1, 1},
  {&__pyx_n_s_transform_mi_discount, __pyx_k_transform_mi_discount, sizeof(__pyx_k_transform_mi_discount), 0, 0, 1, 1},
  {&__pyx_n_s_transpose, __pyx_k_transpose, sizeof(__pyx_k_transpose), 0, 0, 1, 1},
  {&__pyx_kp_s_unable_to_allocate_array_data, __pyx_k_unable_to_allocate_array_data, sizeof(__pyx_k_unable_to_allocate_array_data), 0, 0, 1, 0},
  {&__pyx_kp_s_unable_to_allocate_shape_and_str, __pyx_k_unable_to_allocate_shape_and_str, sizeof(__pyx_k_unable_to_allocate_shape_and_str), 0, 0, 1, 0},
  {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0},
  {&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1},
  {&__pyx_n_s_vals_ptr, __pyx_k_vals_ptr, sizeof(__pyx_k_vals_ptr), 0, 0, 1, 1},
  {&__pyx_n_s_vec, __pyx_k_vec, sizeof(__pyx_k_vec), 0, 0, 1, 1},
  {&__pyx_n_s_vecs, __pyx_k_vecs, sizeof(__pyx_k_vecs), 0, 0, 1, 1},
  {&__pyx_n_s_w, __pyx_k_w, sizeof(__pyx_k_w), 0, 0, 1, 1},
  {&__pyx_n_s_weight, __pyx_k_weight, sizeof(__pyx_k_weight), 0, 0, 1, 1},
  {&__pyx_n_s_weights, __pyx_k_weights, sizeof(__pyx_k_weights), 0, 0, 1, 1},
  {&__pyx_n_s_write, __pyx_k_write, sizeof(__pyx_k_write), 0, 0, 1, 1},
  {&__pyx_n_s_write_binary, __pyx_k_write_binary, sizeof(__pyx_k_write_binary), 0, 0, 1, 1},
  {&__pyx_kp_s_wrong_tcode, __pyx_k_wrong_tcode, sizeof(__pyx_k_wrong_tcode), 0, 0, 1, 0},
  {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1},
  {&__pyx_n_s_xrange, __pyx_k_xrange, sizeof(__pyx_k_xrange), 0, 0, 1, 1},
  {&__pyx_n_s_xs, __pyx_k_xs, sizeof(__pyx_k_xs), 0, 0, 1, 1},
  {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_StopIteration = __Pyx_GetBuiltinName(__pyx_n_s_StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_sum = __Pyx_GetBuiltinName(__pyx_n_s_sum); if (!__pyx_builtin_sum) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_file = __Pyx_GetBuiltinName(__pyx_n_s_file); if (!__pyx_builtin_file) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if PY_MAJOR_VERSION >= 3
  __pyx_builtin_xrange = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #else
  __pyx_builtin_xrange = __Pyx_GetBuiltinName(__pyx_n_s_xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "lurrn/sparsmat.pyx":1434
 *     ## instead of passing length=0
 *     # go to end of file and note position
 *     f.seek(0,2)             # <<<<<<<<<<<<<<
 *     flen=f.tell()
 *     a=mmap.mmap(f.fileno(),flen,access=mmap.ACCESS_READ)
 */
  __pyx_tuple_ = PyTuple_Pack(2, __pyx_int_0, __pyx_int_2); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);

  /* "lurrn/sparsmat.pyx":1456
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_tuple__2 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);

  /* "lurrn/sparsmat.pyx":1537
 *           idx_ptr[i]=c.addr[0]
 *           vals_ptr[i]=c.item
 *         result=SparseVectorI(None)             # <<<<<<<<<<<<<<
 *         result.idx_ptr=idx_ptr
 *         result.vals_ptr=vals_ptr
 */
  __pyx_tuple__3 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);

  /* "lurrn/sparsmat.pyx":1602
 *         return result
 *     cpdef VecI1 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_n_s_b); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "lurrn/sparsmat.pyx":1663
 *         self.loose=VecI1()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.loose.c_add(k0, item)
 */
  __pyx_slice__5 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__5);
  __Pyx_GIVEREF(__pyx_slice__5);

  /* "lurrn/sparsmat.pyx":1666
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.loose.c_add(k0, item)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_tuple__6 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "lurrn/sparsmat.pyx":1673
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
  __pyx_slice__7 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__7);
  __Pyx_GIVEREF(__pyx_slice__7);

  /* "lurrn/sparsmat.pyx":1689
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
  __pyx_tuple__8 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "lurrn/sparsmat.pyx":1690
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
  __pyx_tuple__9 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);

  /* "lurrn/sparsmat.pyx":1719
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_tuple__10 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);

  /* "lurrn/sparsmat.pyx":1854
 *         return result
 *     cpdef VecI2 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_tuple__11 = PyTuple_Pack(1, __pyx_n_s_b); if (unlikely(!__pyx_tuple__11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);

  /* "lurrn/sparsmat.pyx":1916
 *         self.loose=VecI2()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.loose.c_add(k0,k1, item)
 */
  __pyx_slice__12 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__12);
  __Pyx_GIVEREF(__pyx_slice__12);

  /* "lurrn/sparsmat.pyx":1919
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.loose.c_add(k0,k1, item)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_tuple__13 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);

  /* "lurrn/sparsmat.pyx":1926
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
  __pyx_slice__14 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__14);
  __Pyx_GIVEREF(__pyx_slice__14);

  /* "lurrn/sparsmat.pyx":1942
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
  __pyx_tuple__15 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "lurrn/sparsmat.pyx":1943
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
  __pyx_tuple__16 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);

  /* "lurrn/sparsmat.pyx":1976
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_tuple__17 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);

  /* "lurrn/sparsmat.pyx":2106
 *         return result
 *     cpdef VecI3 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_tuple__18 = PyTuple_Pack(1, __pyx_n_s_b); if (unlikely(!__pyx_tuple__18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);

  /* "lurrn/sparsmat.pyx":2169
 *         self.loose=VecI3()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.loose.c_add(k0,k1,k2, item)
 */
  __pyx_slice__19 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__19);
  __Pyx_GIVEREF(__pyx_slice__19);

  /* "lurrn/sparsmat.pyx":2172
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.loose.c_add(k0,k1,k2, item)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_tuple__20 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "lurrn/sparsmat.pyx":2179
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
  __pyx_slice__21 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__21);
  __Pyx_GIVEREF(__pyx_slice__21);

  /* "lurrn/sparsmat.pyx":2195
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
  __pyx_tuple__22 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);

  /* "lurrn/sparsmat.pyx":2196
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
  __pyx_tuple__23 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);

  /* "lurrn/sparsmat.pyx":2811
 *             s_idx=PyString_FromStringAndSize(<char *>self.idx_ptr,self.my_len*sizeof(coordinate_t))
 *             s_vals=PyString_FromStringAndSize(<char *>self.vals_ptr,self.my_len*sizeof(int))
 *             return (SparseVectorI,(None,),(s_idx,s_vals))             # <<<<<<<<<<<<<<
 *     def __setstate__(self,state):
 *         cdef coordinate_t *p_idx
 */
  __pyx_tuple__26 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);

  /* "lurrn/sparsmat.pyx":2940
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_tuple__27 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);

  /* "lurrn/sparsmat.pyx":3021
 *           idx_ptr[i]=c.addr[0]
 *           vals_ptr[i]=c.item
 *         result=SparseVectorF(None)             # <<<<<<<<<<<<<<
 *         result.idx_ptr=idx_ptr
 *         result.vals_ptr=vals_ptr
 */
  __pyx_tuple__28 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__28);
  __Pyx_GIVEREF(__pyx_tuple__28);

  /* "lurrn/sparsmat.pyx":3086
 *         return result
 *     cpdef VecF1 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_tuple__29 = PyTuple_Pack(1, __pyx_n_s_b); if (unlikely(!__pyx_tuple__29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);

  /* "lurrn/sparsmat.pyx":3147
 *         self.loose=VecF1()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.loose.c_add(k0, item)
 */
  __pyx_slice__30 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__30);
  __Pyx_GIVEREF(__pyx_slice__30);

  /* "lurrn/sparsmat.pyx":3150
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.loose.c_add(k0, item)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_tuple__31 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);

  /* "lurrn/sparsmat.pyx":3157
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
  __pyx_slice__32 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__32);
  __Pyx_GIVEREF(__pyx_slice__32);

  /* "lurrn/sparsmat.pyx":3173
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
  __pyx_tuple__33 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);

  /* "lurrn/sparsmat.pyx":3174
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
  __pyx_tuple__34 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);

  /* "lurrn/sparsmat.pyx":3203
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_tuple__35 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__35);
  __Pyx_GIVEREF(__pyx_tuple__35);

  /* "lurrn/sparsmat.pyx":3338
 *         return result
 *     cpdef VecF2 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_tuple__36 = PyTuple_Pack(1, __pyx_n_s_b); if (unlikely(!__pyx_tuple__36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);

  /* "lurrn/sparsmat.pyx":3400
 *         self.loose=VecF2()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.loose.c_add(k0,k1, item)
 */
  __pyx_slice__37 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__37);
  __Pyx_GIVEREF(__pyx_slice__37);

  /* "lurrn/sparsmat.pyx":3403
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.loose.c_add(k0,k1, item)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_tuple__38 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);

  /* "lurrn/sparsmat.pyx":3410
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
  __pyx_slice__39 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__39);
  __Pyx_GIVEREF(__pyx_slice__39);

  /* "lurrn/sparsmat.pyx":3426
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
  __pyx_tuple__40 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__40);
  __Pyx_GIVEREF(__pyx_tuple__40);

  /* "lurrn/sparsmat.pyx":3427
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
  __pyx_tuple__41 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__41)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);

  /* "lurrn/sparsmat.pyx":3460
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_tuple__42 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__42)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);

  /* "lurrn/sparsmat.pyx":3590
 *         return result
 *     cpdef VecF3 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_tuple__43 = PyTuple_Pack(1, __pyx_n_s_b); if (unlikely(!__pyx_tuple__43)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);

  /* "lurrn/sparsmat.pyx":3653
 *         self.loose=VecF3()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.loose.c_add(k0,k1,k2, item)
 */
  __pyx_slice__44 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__44)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__44);
  __Pyx_GIVEREF(__pyx_slice__44);

  /* "lurrn/sparsmat.pyx":3656
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.loose.c_add(k0,k1,k2, item)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_tuple__45 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__45)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__45);
  __Pyx_GIVEREF(__pyx_tuple__45);

  /* "lurrn/sparsmat.pyx":3663
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
  __pyx_slice__46 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__46)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__46);
  __Pyx_GIVEREF(__pyx_slice__46);

  /* "lurrn/sparsmat.pyx":3679
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
  __pyx_tuple__47 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);

  /* "lurrn/sparsmat.pyx":3680
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
  __pyx_tuple__48 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__48)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__48);
  __Pyx_GIVEREF(__pyx_tuple__48);

  /* "lurrn/sparsmat.pyx":4295
 *             s_idx=PyString_FromStringAndSize(<char *>self.idx_ptr,self.my_len*sizeof(coordinate_t))
 *             s_vals=PyString_FromStringAndSize(<char *>self.vals_ptr,self.my_len*sizeof(float))
 *             return (SparseVectorF,(None,),(s_idx,s_vals))             # <<<<<<<<<<<<<<
 *     def __setstate__(self,state):
 *         cdef coordinate_t *p_idx
 */
  __pyx_tuple__49 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__49)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__49);
  __Pyx_GIVEREF(__pyx_tuple__49);

  /* "lurrn/sparsmat.pyx":4424
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_tuple__50 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__50)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__50);
  __Pyx_GIVEREF(__pyx_tuple__50);

  /* "lurrn/sparsmat.pyx":4505
 *           idx_ptr[i]=c.addr[0]
 *           vals_ptr[i]=c.item
 *         result=SparseVectorD(None)             # <<<<<<<<<<<<<<
 *         result.idx_ptr=idx_ptr
 *         result.vals_ptr=vals_ptr
 */
  __pyx_tuple__51 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__51);
  __Pyx_GIVEREF(__pyx_tuple__51);

  /* "lurrn/sparsmat.pyx":4570
 *         return result
 *     cpdef VecD1 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_tuple__52 = PyTuple_Pack(1, __pyx_n_s_b); if (unlikely(!__pyx_tuple__52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__52);
  __Pyx_GIVEREF(__pyx_tuple__52);

  /* "lurrn/sparsmat.pyx":4631
 *         self.loose=VecD1()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.loose.c_add(k0, item)
 */
  __pyx_slice__53 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__53)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__53);
  __Pyx_GIVEREF(__pyx_slice__53);

  /* "lurrn/sparsmat.pyx":4634
 *     def add_count(self, coordinate_t k0, item=1):
 *         self.loose.c_add(k0, item)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_tuple__54 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__54)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__54);
  __Pyx_GIVEREF(__pyx_tuple__54);

  /* "lurrn/sparsmat.pyx":4641
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
  __pyx_slice__55 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__55)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__55);
  __Pyx_GIVEREF(__pyx_slice__55);

  /* "lurrn/sparsmat.pyx":4657
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
  __pyx_tuple__56 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__56)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__56);
  __Pyx_GIVEREF(__pyx_tuple__56);

  /* "lurrn/sparsmat.pyx":4658
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
  __pyx_tuple__57 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__57)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__57);
  __Pyx_GIVEREF(__pyx_tuple__57);

  /* "lurrn/sparsmat.pyx":4687
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_tuple__58 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__58)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__58);
  __Pyx_GIVEREF(__pyx_tuple__58);

  /* "lurrn/sparsmat.pyx":4822
 *         return result
 *     cpdef VecD2 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_tuple__59 = PyTuple_Pack(1, __pyx_n_s_b); if (unlikely(!__pyx_tuple__59)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__59);
  __Pyx_GIVEREF(__pyx_tuple__59);

  /* "lurrn/sparsmat.pyx":4884
 *         self.loose=VecD2()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.loose.c_add(k0,k1, item)
 */
  __pyx_slice__60 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__60);
  __Pyx_GIVEREF(__pyx_slice__60);

  /* "lurrn/sparsmat.pyx":4887
 *     def add_count(self, coordinate_t k0,coordinate_t k1, item=1):
 *         self.loose.c_add(k0,k1, item)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_tuple__61 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__61);
  __Pyx_GIVEREF(__pyx_tuple__61);

  /* "lurrn/sparsmat.pyx":4894
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
  __pyx_slice__62 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__62)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__62);
  __Pyx_GIVEREF(__pyx_slice__62);

  /* "lurrn/sparsmat.pyx":4910
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
  __pyx_tuple__63 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__63);
  __Pyx_GIVEREF(__pyx_tuple__63);

  /* "lurrn/sparsmat.pyx":4911
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
  __pyx_tuple__64 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__64);
  __Pyx_GIVEREF(__pyx_tuple__64);

  /* "lurrn/sparsmat.pyx":4944
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_tuple__65 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__65)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__65);
  __Pyx_GIVEREF(__pyx_tuple__65);

  /* "lurrn/sparsmat.pyx":5074
 *         return result
 *     cpdef VecD3 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_tuple__66 = PyTuple_Pack(1, __pyx_n_s_b); if (unlikely(!__pyx_tuple__66)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__66);
  __Pyx_GIVEREF(__pyx_tuple__66);

  /* "lurrn/sparsmat.pyx":5137
 *         self.loose=VecD3()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.loose.c_add(k0,k1,k2, item)
 */
  __pyx_slice__67 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__67)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__67);
  __Pyx_GIVEREF(__pyx_slice__67);

  /* "lurrn/sparsmat.pyx":5140
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2, item=1):
 *         self.loose.c_add(k0,k1,k2, item)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_tuple__68 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__68)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__68);
  __Pyx_GIVEREF(__pyx_tuple__68);

  /* "lurrn/sparsmat.pyx":5147
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
  __pyx_slice__69 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__69)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__69);
  __Pyx_GIVEREF(__pyx_slice__69);

  /* "lurrn/sparsmat.pyx":5163
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
  __pyx_tuple__70 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__70)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__70);
  __Pyx_GIVEREF(__pyx_tuple__70);

  /* "lurrn/sparsmat.pyx":5164
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
  __pyx_tuple__71 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__71)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__71);
  __Pyx_GIVEREF(__pyx_tuple__71);

  /* "lurrn/sparsmat.pyx":5779
 *             s_idx=PyString_FromStringAndSize(<char *>self.idx_ptr,self.my_len*sizeof(coordinate_t))
 *             s_vals=PyString_FromStringAndSize(<char *>self.vals_ptr,self.my_len*sizeof(double))
 *             return (SparseVectorD,(None,),(s_idx,s_vals))             # <<<<<<<<<<<<<<
 *     def __setstate__(self,state):
 *         cdef coordinate_t *p_idx
 */
  __pyx_tuple__72 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__72)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__72);
  __Pyx_GIVEREF(__pyx_tuple__72);

  /* "lurrn/sparsmat.pyx":5908
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_tuple__73 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__73)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__73);
  __Pyx_GIVEREF(__pyx_tuple__73);

  /* "lurrn/sparsmat.pyx":6042
 *         return result
 *     cpdef VecV1 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_tuple__74 = PyTuple_Pack(1, __pyx_n_s_b); if (unlikely(!__pyx_tuple__74)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__74);
  __Pyx_GIVEREF(__pyx_tuple__74);

  /* "lurrn/sparsmat.pyx":6101
 *         self.loose=VecV1()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0):
 *         self.loose.c_add(k0)
 */
  __pyx_slice__75 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__75)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__75);
  __Pyx_GIVEREF(__pyx_slice__75);

  /* "lurrn/sparsmat.pyx":6104
 *     def add_count(self, coordinate_t k0):
 *         self.loose.c_add(k0)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_tuple__76 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__76)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__76);
  __Pyx_GIVEREF(__pyx_tuple__76);

  /* "lurrn/sparsmat.pyx":6111
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
  __pyx_slice__77 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__77)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__77);
  __Pyx_GIVEREF(__pyx_slice__77);

  /* "lurrn/sparsmat.pyx":6127
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
  __pyx_tuple__78 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__78)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__78);
  __Pyx_GIVEREF(__pyx_tuple__78);

  /* "lurrn/sparsmat.pyx":6128
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
  __pyx_tuple__79 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__79)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__79);
  __Pyx_GIVEREF(__pyx_tuple__79);

  /* "lurrn/sparsmat.pyx":6157
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_tuple__80 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__80)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__80);
  __Pyx_GIVEREF(__pyx_tuple__80);

  /* "lurrn/sparsmat.pyx":6283
 *         return result
 *     cpdef VecV2 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_tuple__81 = PyTuple_Pack(1, __pyx_n_s_b); if (unlikely(!__pyx_tuple__81)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__81);
  __Pyx_GIVEREF(__pyx_tuple__81);

  /* "lurrn/sparsmat.pyx":6344
 *         self.loose=VecV2()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1):
 *         self.loose.c_add(k0,k1)
 */
  __pyx_slice__82 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__82)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__82);
  __Pyx_GIVEREF(__pyx_slice__82);

  /* "lurrn/sparsmat.pyx":6347
 *     def add_count(self, coordinate_t k0,coordinate_t k1):
 *         self.loose.c_add(k0,k1)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_tuple__83 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__83)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__83);
  __Pyx_GIVEREF(__pyx_tuple__83);

  /* "lurrn/sparsmat.pyx":6354
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
  __pyx_slice__84 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__84)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__84);
  __Pyx_GIVEREF(__pyx_slice__84);

  /* "lurrn/sparsmat.pyx":6370
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
  __pyx_tuple__85 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__85)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__85);
  __Pyx_GIVEREF(__pyx_tuple__85);

  /* "lurrn/sparsmat.pyx":6371
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
  __pyx_tuple__86 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__86)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__86);
  __Pyx_GIVEREF(__pyx_tuple__86);

  /* "lurrn/sparsmat.pyx":6400
 *         return self.vec.size()
 *     def __len__(self):
 *         return self.get_size(True)             # <<<<<<<<<<<<<<
 *     def clear(self):
 *         self.vec.resize(0)
 */
  __pyx_tuple__87 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__87)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__87);
  __Pyx_GIVEREF(__pyx_tuple__87);

  /* "lurrn/sparsmat.pyx":6528
 *         return result
 *     cpdef VecV3 remap(self, int k, numpy.ndarray filt):
 *         cdef numpy.ndarray[numpy.int8_t, ndim=1] wanted=filt.astype('b')             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.int_t, ndim=1] target=filt.cumsum()-1
 *         self.ensure_compact()
 */
  __pyx_tuple__88 = PyTuple_Pack(1, __pyx_n_s_b); if (unlikely(!__pyx_tuple__88)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__88);
  __Pyx_GIVEREF(__pyx_tuple__88);

  /* "lurrn/sparsmat.pyx":6590
 *         self.loose=VecV3()
 *         while len(self.compact)>=2:
 *             self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):
 *         self.loose.c_add(k0,k1,k2)
 */
  __pyx_slice__89 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__89)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__89);
  __Pyx_GIVEREF(__pyx_slice__89);

  /* "lurrn/sparsmat.pyx":6593
 *     def add_count(self, coordinate_t k0,coordinate_t k1,coordinate_t k2):
 *         self.loose.c_add(k0,k1,k2)
 *         if self.loose.get_size(False)>=100000:             # <<<<<<<<<<<<<<
 *             self.loose.ensure_compact()
 *             self.compact.append(self.loose)
 */
  __pyx_tuple__90 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__90)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__90);
  __Pyx_GIVEREF(__pyx_tuple__90);

  /* "lurrn/sparsmat.pyx":6600
 *             while (len(self.compact)>=2 and
 *                    self.compact[-1].get_size()>=0.6*self.compact[-2].get_size()):
 *                 self.compact[-2:]=[self.compact[-2]+self.compact[-1]]             # <<<<<<<<<<<<<<
 *     def get_compact(self):
 *         self.ensure_compact()
 */
  __pyx_slice__91 = PySlice_New(__pyx_int_neg_2, Py_None, Py_None); if (unlikely(!__pyx_slice__91)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__91);
  __Pyx_GIVEREF(__pyx_slice__91);

  /* "lurrn/sparsmat.pyx":6616
 *                 return 0
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])             # <<<<<<<<<<<<<<
 *             n+=self.loose.get_size(False)
 *             return n
 */
  __pyx_tuple__92 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__92)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__92);
  __Pyx_GIVEREF(__pyx_tuple__92);

  /* "lurrn/sparsmat.pyx":6617
 *         else:
 *             n=sum([c.get_size(False) for c in self.compact])
 *             n+=self.loose.get_size(False)             # <<<<<<<<<<<<<<
 *             return n
 *     def __iter__(self):
 */
  __pyx_tuple__93 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__93)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__93);
  __Pyx_GIVEREF(__pyx_tuple__93);

  /* "lurrn/sparsmat.pyx":6662
 *     mat3=mat+mat2
 *     mat3.print_csr()
 *     mat3.write_binary(file('/tmp/mat3','w'))             # <<<<<<<<<<<<<<
 *     mat4=mmapCSR(file('/tmp/mat3'))
 *     mat4.print_csr()
 */
  __pyx_tuple__95 = PyTuple_Pack(2, __pyx_kp_s_tmp_mat3, __pyx_n_s_w); if (unlikely(!__pyx_tuple__95)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__95);
  __Pyx_GIVEREF(__pyx_tuple__95);

  /* "lurrn/sparsmat.pyx":6663
 *     mat3.print_csr()
 *     mat3.write_binary(file('/tmp/mat3','w'))
 *     mat4=mmapCSR(file('/tmp/mat3'))             # <<<<<<<<<<<<<<
 *     mat4.print_csr()
 *     mat4=None
 */
  __pyx_tuple__96 = PyTuple_Pack(1, __pyx_kp_s_tmp_mat3); if (unlikely(!__pyx_tuple__96)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__96);
  __Pyx_GIVEREF(__pyx_tuple__96);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":215
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 */
  __pyx_tuple__97 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__97)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__97);
  __Pyx_GIVEREF(__pyx_tuple__97);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":219
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")             # <<<<<<<<<<<<<<
 * 
 *             info.buf = PyArray_DATA(self)
 */
  __pyx_tuple__98 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__98)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__98);
  __Pyx_GIVEREF(__pyx_tuple__98);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":257
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 */
  __pyx_tuple__99 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__99)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__99);
  __Pyx_GIVEREF(__pyx_tuple__99);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":799
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")             # <<<<<<<<<<<<<<
 * 
 *         if ((child.byteorder == c'>' and little_endian) or
 */
  __pyx_tuple__100 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__100)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__100);
  __Pyx_GIVEREF(__pyx_tuple__100);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":803
 *         if ((child.byteorder == c'>' and little_endian) or
 *             (child.byteorder == c'<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *             # One could encode it in the format string and have Cython
 *             # complain instead, BUT: < and > in format strings also imply
 */
  __pyx_tuple__101 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__101)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__101);
  __Pyx_GIVEREF(__pyx_tuple__101);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":823
 *             t = child.type_num
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")             # <<<<<<<<<<<<<<
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 */
  __pyx_tuple__102 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__102)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__102);
  __Pyx_GIVEREF(__pyx_tuple__102);

  /* "View.MemoryView":127
 * 
 *         if not self.ndim:
 *             raise ValueError("Empty shape tuple for cython.array")             # <<<<<<<<<<<<<<
 * 
 *         if itemsize <= 0:
 */
  __pyx_tuple__103 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__103)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__103);
  __Pyx_GIVEREF(__pyx_tuple__103);

  /* "View.MemoryView":130
 * 
 *         if itemsize <= 0:
 *             raise ValueError("itemsize <= 0 for cython.array")             # <<<<<<<<<<<<<<
 * 
 *         if isinstance(format, unicode):
 */
  __pyx_tuple__104 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__104)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__104);
  __Pyx_GIVEREF(__pyx_tuple__104);

  /* "View.MemoryView":142
 * 
 *         if not self._shape:
 *             raise MemoryError("unable to allocate shape and strides.")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__105 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__105)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__105);
  __Pyx_GIVEREF(__pyx_tuple__105);

  /* "View.MemoryView":170
 *             self.data = <char *>malloc(self.len)
 *             if not self.data:
 *                 raise MemoryError("unable to allocate array data.")             # <<<<<<<<<<<<<<
 * 
 *             if self.dtype_is_object:
 */
  __pyx_tuple__106 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__106)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__106);
  __Pyx_GIVEREF(__pyx_tuple__106);

  /* "View.MemoryView":186
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         if not (flags & bufmode):
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")             # <<<<<<<<<<<<<<
 *         info.buf = self.data
 *         info.len = self.len
 */
  __pyx_tuple__107 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__107)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__107);
  __Pyx_GIVEREF(__pyx_tuple__107);

  /* "View.MemoryView":445
 *             result = struct.unpack(self.view.format, bytesitem)
 *         except struct.error:
 *             raise ValueError("Unable to convert item to object")             # <<<<<<<<<<<<<<
 *         else:
 *             if len(self.view.format) == 1:
 */
  __pyx_tuple__108 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__108)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__108);
  __Pyx_GIVEREF(__pyx_tuple__108);

  /* "View.MemoryView":521
 *             if self.view.strides == NULL:
 * 
 *                 raise ValueError("Buffer view does not expose strides")             # <<<<<<<<<<<<<<
 * 
 *             return tuple([self.view.strides[i] for i in xrange(self.view.ndim)])
 */
  __pyx_tuple__109 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__109)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__109);
  __Pyx_GIVEREF(__pyx_tuple__109);

  /* "View.MemoryView":638
 *         if item is Ellipsis:
 *             if not seen_ellipsis:
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))             # <<<<<<<<<<<<<<
 *                 seen_ellipsis = True
 *             else:
 */
  __pyx_slice__110 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__110)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__110);
  __Pyx_GIVEREF(__pyx_slice__110);

  /* "View.MemoryView":641
 *                 seen_ellipsis = True
 *             else:
 *                 result.append(slice(None))             # <<<<<<<<<<<<<<
 *             have_slices = True
 *         else:
 */
  __pyx_slice__111 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__111)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__111);
  __Pyx_GIVEREF(__pyx_slice__111);

  /* "View.MemoryView":652
 *     nslices = ndim - len(result)
 *     if nslices:
 *         result.extend([slice(None)] * nslices)             # <<<<<<<<<<<<<<
 * 
 *     return have_slices or nslices, tuple(result)
 */
  __pyx_slice__112 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__112)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__112);
  __Pyx_GIVEREF(__pyx_slice__112);

  /* "View.MemoryView":660
 *     for i in range(ndim):
 *         if suboffsets[i] >= 0:
 *             raise ValueError("Indirect dimensions not supported")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__113 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__113)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__113);
  __Pyx_GIVEREF(__pyx_tuple__113);

  /* "lurrn/sparsmat.pyx":1384
 * 
 * 
 * def csrFromBuffer(object buf):             # <<<<<<<<<<<<<<
 *     """takes an object conforming to the Buffer protocol and
 *     creates a CSR matrix from that."""
 */
  __pyx_tuple__114 = PyTuple_Pack(12, __pyx_n_s_buf, __pyx_n_s_buffer, __pyx_n_s_buffer_len, __pyx_n_s_tmp, __pyx_n_s_c_matI, __pyx_n_s_matI, __pyx_n_s_c_matF, __pyx_n_s_matF, __pyx_n_s_c_matD, __pyx_n_s_matD, __pyx_n_s_result, __pyx_n_s_tcode); if (unlikely(!__pyx_tuple__114)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__114);
  __Pyx_GIVEREF(__pyx_tuple__114);
  __pyx_codeobj__115 = (PyObject*)__Pyx_PyCode_New(1, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__114, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_yannick_proj_lurrn_pyx_src, __pyx_n_s_csrFromBuffer, 1384, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__115)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lurrn/sparsmat.pyx":1430
 *         raise ValueError("wrong tcode "+tcode)
 * 
 * def mmapCSR(f):             # <<<<<<<<<<<<<<
 *     ## py2.4 compat: determine length
 *     ## instead of passing length=0
 */
  __pyx_tuple__116 = PyTuple_Pack(3, __pyx_n_s_f, __pyx_n_s_flen, __pyx_n_s_a); if (unlikely(!__pyx_tuple__116)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__116);
  __Pyx_GIVEREF(__pyx_tuple__116);
  __pyx_codeobj__117 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__116, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_yannick_proj_lurrn_pyx_src, __pyx_n_s_mmapCSR, 1430, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__117)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lurrn/sparsmat.pyx":6633
 * 
 * 
 * def run_test():             # <<<<<<<<<<<<<<
 *     cdef VecI2 counts
 *     counts=VecI2()
 */
  __pyx_tuple__118 = PyTuple_Pack(10, __pyx_n_s_counts, __pyx_n_s_xs, __pyx_n_s_mat, __pyx_n_s_mat2, __pyx_n_s_mat3, __pyx_n_s_mat4, __pyx_n_s_mat5, __pyx_n_s_mat6, __pyx_n_s_sv, __pyx_n_s_x); if (unlikely(!__pyx_tuple__118)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__118);
  __Pyx_GIVEREF(__pyx_tuple__118);
  __pyx_codeobj__119 = (PyObject*)__Pyx_PyCode_New(0, 0, 10, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__118, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_yannick_proj_lurrn_pyx_src, __pyx_n_s_run_test, 6633, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__119)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "View.MemoryView":276
 *         return self.name
 * 
 * cdef generic = Enum("<strided and direct or indirect>")             # <<<<<<<<<<<<<<
 * cdef strided = Enum("<strided and direct>") # default
 * cdef indirect = Enum("<strided and indirect>")
 */
  __pyx_tuple__120 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__120)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__120);
  __Pyx_GIVEREF(__pyx_tuple__120);

  /* "View.MemoryView":277
 * 
 * cdef generic = Enum("<strided and direct or indirect>")
 * cdef strided = Enum("<strided and direct>") # default             # <<<<<<<<<<<<<<
 * cdef indirect = Enum("<strided and indirect>")
 * 
 */
  __pyx_tuple__121 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__121)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__121);
  __Pyx_GIVEREF(__pyx_tuple__121);

  /* "View.MemoryView":278
 * cdef generic = Enum("<strided and direct or indirect>")
 * cdef strided = Enum("<strided and direct>") # default
 * cdef indirect = Enum("<strided and indirect>")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__122 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__122)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__122);
  __Pyx_GIVEREF(__pyx_tuple__122);

  /* "View.MemoryView":281
 * 
 * 
 * cdef contiguous = Enum("<contiguous and direct>")             # <<<<<<<<<<<<<<
 * cdef indirect_contiguous = Enum("<contiguous and indirect>")
 * 
 */
  __pyx_tuple__123 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__123)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__123);
  __Pyx_GIVEREF(__pyx_tuple__123);

  /* "View.MemoryView":282
 * 
 * cdef contiguous = Enum("<contiguous and direct>")
 * cdef indirect_contiguous = Enum("<contiguous and indirect>")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__124 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__124)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__124);
  __Pyx_GIVEREF(__pyx_tuple__124);
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_float_0_5 = PyFloat_FromDouble(0.5); if (unlikely(!__pyx_float_0_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_float_0_6 = PyFloat_FromDouble(0.6); if (unlikely(!__pyx_float_0_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_float_1_0 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_float_1_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_float_2_0 = PyFloat_FromDouble(2.0); if (unlikely(!__pyx_float_2_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_256 = PyInt_FromLong(256); if (unlikely(!__pyx_int_256)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_100000 = PyInt_FromLong(100000L); if (unlikely(!__pyx_int_100000)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_neg_2 = PyInt_FromLong(-2); if (unlikely(!__pyx_int_neg_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initsparsmat(void); /*proto*/
PyMODINIT_FUNC initsparsmat(void)
#else
PyMODINIT_FUNC PyInit_sparsmat(void); /*proto*/
PyMODINIT_FUNC PyInit_sparsmat(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  #if CYTHON_REFNANNY
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  #endif
  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_sparsmat(void)", 0);
  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __Pyx_CyFunction_USED
  if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("sparsmat", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  if (__pyx_module_is_main_lurrn__sparsmat) {
    if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!PyDict_GetItemString(modules, "lurrn.sparsmat")) {
      if (unlikely(PyDict_SetItemString(modules, "lurrn.sparsmat", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  __pyx_v_5lurrn_8sparsmat_emptyvec_I = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)Py_None); Py_INCREF(Py_None);
  __pyx_v_5lurrn_8sparsmat_emptyvec_F = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)Py_None); Py_INCREF(Py_None);
  __pyx_v_5lurrn_8sparsmat_emptyvec_D = ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)Py_None); Py_INCREF(Py_None);
  generic = Py_None; Py_INCREF(Py_None);
  strided = Py_None; Py_INCREF(Py_None);
  indirect = Py_None; Py_INCREF(Py_None);
  contiguous = Py_None; Py_INCREF(Py_None);
  indirect_contiguous = Py_None; Py_INCREF(Py_None);
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_5lurrn_8sparsmat_CSRMatrixD = &__pyx_vtable_5lurrn_8sparsmat_CSRMatrixD;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixD.set_matrix = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, struct CSRMatrix<double> *))__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_set_matrix;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixD.get_count = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, coordinate_t, coordinate_t, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_get_count;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixD.get_maxcol = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_get_maxcol;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixD.transform_mi = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_transform_mi;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixD.transform_mi_discount = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_transform_mi_discount;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixD.transform_ll = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_transform_ll;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixD.transform_l1 = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_transform_l1;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixD.apply_threshold = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_apply_threshold;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixD.apply_scaling = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_apply_scaling;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixD.fromVectors = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *, PyObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixD_fromVectors;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_CSRMatrixD) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_CSRMatrixD.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_CSRMatrixD.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_CSRMatrixD) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "CSRMatrixD", (PyObject *)&__pyx_type_5lurrn_8sparsmat_CSRMatrixD) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD = &__pyx_type_5lurrn_8sparsmat_CSRMatrixD;
  __pyx_vtabptr_5lurrn_8sparsmat_CSRMatrixI = &__pyx_vtable_5lurrn_8sparsmat_CSRMatrixI;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixI.set_matrix = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, struct CSRMatrix<int> *))__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_set_matrix;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixI.get_count = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, coordinate_t, coordinate_t, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_get_count;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixI.get_maxcol = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_get_maxcol;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixI.transform_mi = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_transform_mi;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixI.transform_mi_discount = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_transform_mi_discount;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixI.transform_ll = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_transform_ll;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixI.transform_l1 = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_transform_l1;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixI.apply_threshold = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_apply_threshold;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixI.apply_scaling = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_apply_scaling;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixI.fromVectors = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *, PyObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixI_fromVectors;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_CSRMatrixI) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_CSRMatrixI.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_CSRMatrixI.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_CSRMatrixI) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "CSRMatrixI", (PyObject *)&__pyx_type_5lurrn_8sparsmat_CSRMatrixI) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_CSRMatrixI = &__pyx_type_5lurrn_8sparsmat_CSRMatrixI;
  __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorI = &__pyx_vtable_5lurrn_8sparsmat_SparseVectorI;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorI.from_dense = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, __Pyx_memviewslice, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorI_from_dense;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorI.dotSelf = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorI_dotSelf;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorI._dotFull = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, const int *))__pyx_f_5lurrn_8sparsmat_13SparseVectorI__dotFull;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorI._dotFull_partial = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, const int *, int))__pyx_f_5lurrn_8sparsmat_13SparseVectorI__dotFull_partial;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorI.dotSparse = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorI_dotSparse;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorI._axpy = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int *, int))__pyx_f_5lurrn_8sparsmat_13SparseVectorI__axpy;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorI.sqdist = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorI_sqdist;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorI.jaccard = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorI_jaccard;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorI.cosine = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorI_cosine;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorI.min_sum = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorI_min_sum;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorI.jsd_unnorm = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorI_jsd_unnorm;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorI.skew_unnorm = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, double, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorI_skew_unnorm;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorI.min_vals = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *(*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorI_min_vals;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorI.norm_l1 = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorI_norm_l1;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorI.norm_l2 = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorI_norm_l2;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorI.norm_lp = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, double, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorI_norm_lp;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_SparseVectorI) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_SparseVectorI.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_SparseVectorI.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorI) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "SparseVectorI", (PyObject *)&__pyx_type_5lurrn_8sparsmat_SparseVectorI) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_SparseVectorI = &__pyx_type_5lurrn_8sparsmat_SparseVectorI;
  __pyx_vtabptr_5lurrn_8sparsmat_VecI1 = &__pyx_vtable_5lurrn_8sparsmat_VecI1;
  __pyx_vtable_5lurrn_8sparsmat_VecI1.get_count = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *, coordinate_t, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecI1_get_count;
  __pyx_vtable_5lurrn_8sparsmat_VecI1.compactify = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *))__pyx_f_5lurrn_8sparsmat_5VecI1_compactify;
  __pyx_vtable_5lurrn_8sparsmat_VecI1.ensure_compact = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *))__pyx_f_5lurrn_8sparsmat_5VecI1_ensure_compact;
  __pyx_vtable_5lurrn_8sparsmat_VecI1.c_add = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *, coordinate_t, int))__pyx_f_5lurrn_8sparsmat_5VecI1_c_add;
  __pyx_vtable_5lurrn_8sparsmat_VecI1.to_sparse = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecI1_to_sparse;
  __pyx_vtable_5lurrn_8sparsmat_VecI1.get_maxcol = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI1_get_maxcol *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecI1_get_maxcol;
  __pyx_vtable_5lurrn_8sparsmat_VecI1.get_type_counts = (PyArrayObject *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI1_get_type_counts *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecI1_get_type_counts;
  __pyx_vtable_5lurrn_8sparsmat_VecI1.remap = (struct __pyx_obj_5lurrn_8sparsmat_VecI1 *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecI1 *, int, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecI1_remap;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_VecI1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_VecI1.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_VecI1.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_VecI1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "VecI1", (PyObject *)&__pyx_type_5lurrn_8sparsmat_VecI1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_VecI1 = &__pyx_type_5lurrn_8sparsmat_VecI1;
  __pyx_vtabptr_5lurrn_8sparsmat_VecI2 = &__pyx_vtable_5lurrn_8sparsmat_VecI2;
  __pyx_vtable_5lurrn_8sparsmat_VecI2.get_count = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *, coordinate_t, coordinate_t, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecI2_get_count;
  __pyx_vtable_5lurrn_8sparsmat_VecI2.compactify = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *))__pyx_f_5lurrn_8sparsmat_5VecI2_compactify;
  __pyx_vtable_5lurrn_8sparsmat_VecI2.ensure_compact = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *))__pyx_f_5lurrn_8sparsmat_5VecI2_ensure_compact;
  __pyx_vtable_5lurrn_8sparsmat_VecI2.c_add = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *, coordinate_t, coordinate_t, int))__pyx_f_5lurrn_8sparsmat_5VecI2_c_add;
  __pyx_vtable_5lurrn_8sparsmat_VecI2.to_csr = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecI2_to_csr;
  __pyx_vtable_5lurrn_8sparsmat_VecI2.get_maxcol = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI2_get_maxcol *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecI2_get_maxcol;
  __pyx_vtable_5lurrn_8sparsmat_VecI2.get_type_counts = (PyArrayObject *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI2_get_type_counts *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecI2_get_type_counts;
  __pyx_vtable_5lurrn_8sparsmat_VecI2.remap = (struct __pyx_obj_5lurrn_8sparsmat_VecI2 *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecI2 *, int, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecI2_remap;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_VecI2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_VecI2.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_VecI2.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_VecI2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "VecI2", (PyObject *)&__pyx_type_5lurrn_8sparsmat_VecI2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_VecI2 = &__pyx_type_5lurrn_8sparsmat_VecI2;
  __pyx_vtabptr_5lurrn_8sparsmat_VecI3 = &__pyx_vtable_5lurrn_8sparsmat_VecI3;
  __pyx_vtable_5lurrn_8sparsmat_VecI3.get_count = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *, coordinate_t, coordinate_t, coordinate_t, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecI3_get_count;
  __pyx_vtable_5lurrn_8sparsmat_VecI3.compactify = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *))__pyx_f_5lurrn_8sparsmat_5VecI3_compactify;
  __pyx_vtable_5lurrn_8sparsmat_VecI3.ensure_compact = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *))__pyx_f_5lurrn_8sparsmat_5VecI3_ensure_compact;
  __pyx_vtable_5lurrn_8sparsmat_VecI3.c_add = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *, coordinate_t, coordinate_t, coordinate_t, int))__pyx_f_5lurrn_8sparsmat_5VecI3_c_add;
  __pyx_vtable_5lurrn_8sparsmat_VecI3.get_maxcol = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI3_get_maxcol *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecI3_get_maxcol;
  __pyx_vtable_5lurrn_8sparsmat_VecI3.get_type_counts = (PyArrayObject *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecI3_get_type_counts *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecI3_get_type_counts;
  __pyx_vtable_5lurrn_8sparsmat_VecI3.remap = (struct __pyx_obj_5lurrn_8sparsmat_VecI3 *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecI3 *, int, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecI3_remap;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_VecI3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_VecI3.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_VecI3.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_VecI3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "VecI3", (PyObject *)&__pyx_type_5lurrn_8sparsmat_VecI3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_VecI3 = &__pyx_type_5lurrn_8sparsmat_VecI3;
  __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorsI = &__pyx_vtable_5lurrn_8sparsmat_SparseVectorsI;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorsI.to_vec = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *(*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_14SparseVectorsI_to_vec;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorsI.add = (PyObject *(*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsI_add *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_14SparseVectorsI_add;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorsI._dotFull = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsI *, const int *))__pyx_f_5lurrn_8sparsmat_14SparseVectorsI__dotFull;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_SparseVectorsI) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_SparseVectorsI.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_SparseVectorsI.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorsI) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "SparseVectorsI", (PyObject *)&__pyx_type_5lurrn_8sparsmat_SparseVectorsI) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_SparseVectorsI = &__pyx_type_5lurrn_8sparsmat_SparseVectorsI;
  __pyx_vtabptr_5lurrn_8sparsmat_CSRMatrixF = &__pyx_vtable_5lurrn_8sparsmat_CSRMatrixF;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixF.set_matrix = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, struct CSRMatrix<float> *))__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_set_matrix;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixF.get_count = (float (*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, coordinate_t, coordinate_t, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_get_count;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixF.get_maxcol = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_get_maxcol;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixF.transform_mi = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_transform_mi;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixF.transform_mi_discount = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_transform_mi_discount;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixF.transform_ll = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_transform_ll;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixF.transform_l1 = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_transform_l1;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixF.apply_threshold = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_apply_threshold;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixF.apply_scaling = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_apply_scaling;
  __pyx_vtable_5lurrn_8sparsmat_CSRMatrixF.fromVectors = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *(*)(struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *, PyObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10CSRMatrixF_fromVectors;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_CSRMatrixF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_CSRMatrixF.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_CSRMatrixF.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_CSRMatrixF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "CSRMatrixF", (PyObject *)&__pyx_type_5lurrn_8sparsmat_CSRMatrixF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_CSRMatrixF = &__pyx_type_5lurrn_8sparsmat_CSRMatrixF;
  __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorF = &__pyx_vtable_5lurrn_8sparsmat_SparseVectorF;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorF.from_dense = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, __Pyx_memviewslice, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorF_from_dense;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorF.dotSelf = (float (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorF_dotSelf;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorF._dotFull = (float (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, const float *))__pyx_f_5lurrn_8sparsmat_13SparseVectorF__dotFull;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorF._dotFull_partial = (float (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, const float *, int))__pyx_f_5lurrn_8sparsmat_13SparseVectorF__dotFull_partial;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorF.dotSparse = (float (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorF_dotSparse;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorF._axpy = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, float *, float))__pyx_f_5lurrn_8sparsmat_13SparseVectorF__axpy;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorF.sqdist = (float (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorF_sqdist;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorF.jaccard = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorF_jaccard;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorF.cosine = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorF_cosine;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorF.min_sum = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorF_min_sum;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorF.jsd_unnorm = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorF_jsd_unnorm;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorF.skew_unnorm = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, double, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorF_skew_unnorm;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorF.min_vals = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *(*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorF_min_vals;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorF.norm_l1 = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorF_norm_l1;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorF.norm_l2 = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorF_norm_l2;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorF.norm_lp = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, double, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorF_norm_lp;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_SparseVectorF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_SparseVectorF.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_SparseVectorF.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "SparseVectorF", (PyObject *)&__pyx_type_5lurrn_8sparsmat_SparseVectorF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_SparseVectorF = &__pyx_type_5lurrn_8sparsmat_SparseVectorF;
  __pyx_vtabptr_5lurrn_8sparsmat_VecF1 = &__pyx_vtable_5lurrn_8sparsmat_VecF1;
  __pyx_vtable_5lurrn_8sparsmat_VecF1.get_count = (float (*)(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *, coordinate_t, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecF1_get_count;
  __pyx_vtable_5lurrn_8sparsmat_VecF1.compactify = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *))__pyx_f_5lurrn_8sparsmat_5VecF1_compactify;
  __pyx_vtable_5lurrn_8sparsmat_VecF1.ensure_compact = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *))__pyx_f_5lurrn_8sparsmat_5VecF1_ensure_compact;
  __pyx_vtable_5lurrn_8sparsmat_VecF1.c_add = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *, coordinate_t, float))__pyx_f_5lurrn_8sparsmat_5VecF1_c_add;
  __pyx_vtable_5lurrn_8sparsmat_VecF1.to_sparse = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecF1_to_sparse;
  __pyx_vtable_5lurrn_8sparsmat_VecF1.get_maxcol = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF1_get_maxcol *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecF1_get_maxcol;
  __pyx_vtable_5lurrn_8sparsmat_VecF1.get_type_counts = (PyArrayObject *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF1_get_type_counts *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecF1_get_type_counts;
  __pyx_vtable_5lurrn_8sparsmat_VecF1.remap = (struct __pyx_obj_5lurrn_8sparsmat_VecF1 *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecF1 *, int, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecF1_remap;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_VecF1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_VecF1.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_VecF1.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_VecF1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "VecF1", (PyObject *)&__pyx_type_5lurrn_8sparsmat_VecF1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_VecF1 = &__pyx_type_5lurrn_8sparsmat_VecF1;
  __pyx_vtabptr_5lurrn_8sparsmat_VecF2 = &__pyx_vtable_5lurrn_8sparsmat_VecF2;
  __pyx_vtable_5lurrn_8sparsmat_VecF2.get_count = (float (*)(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *, coordinate_t, coordinate_t, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecF2_get_count;
  __pyx_vtable_5lurrn_8sparsmat_VecF2.compactify = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *))__pyx_f_5lurrn_8sparsmat_5VecF2_compactify;
  __pyx_vtable_5lurrn_8sparsmat_VecF2.ensure_compact = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *))__pyx_f_5lurrn_8sparsmat_5VecF2_ensure_compact;
  __pyx_vtable_5lurrn_8sparsmat_VecF2.c_add = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *, coordinate_t, coordinate_t, float))__pyx_f_5lurrn_8sparsmat_5VecF2_c_add;
  __pyx_vtable_5lurrn_8sparsmat_VecF2.to_csr = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecF2_to_csr;
  __pyx_vtable_5lurrn_8sparsmat_VecF2.get_maxcol = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF2_get_maxcol *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecF2_get_maxcol;
  __pyx_vtable_5lurrn_8sparsmat_VecF2.get_type_counts = (PyArrayObject *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF2_get_type_counts *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecF2_get_type_counts;
  __pyx_vtable_5lurrn_8sparsmat_VecF2.remap = (struct __pyx_obj_5lurrn_8sparsmat_VecF2 *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecF2 *, int, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecF2_remap;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_VecF2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_VecF2.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_VecF2.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_VecF2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "VecF2", (PyObject *)&__pyx_type_5lurrn_8sparsmat_VecF2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_VecF2 = &__pyx_type_5lurrn_8sparsmat_VecF2;
  __pyx_vtabptr_5lurrn_8sparsmat_VecF3 = &__pyx_vtable_5lurrn_8sparsmat_VecF3;
  __pyx_vtable_5lurrn_8sparsmat_VecF3.get_count = (float (*)(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *, coordinate_t, coordinate_t, coordinate_t, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecF3_get_count;
  __pyx_vtable_5lurrn_8sparsmat_VecF3.compactify = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *))__pyx_f_5lurrn_8sparsmat_5VecF3_compactify;
  __pyx_vtable_5lurrn_8sparsmat_VecF3.ensure_compact = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *))__pyx_f_5lurrn_8sparsmat_5VecF3_ensure_compact;
  __pyx_vtable_5lurrn_8sparsmat_VecF3.c_add = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *, coordinate_t, coordinate_t, coordinate_t, float))__pyx_f_5lurrn_8sparsmat_5VecF3_c_add;
  __pyx_vtable_5lurrn_8sparsmat_VecF3.get_maxcol = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF3_get_maxcol *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecF3_get_maxcol;
  __pyx_vtable_5lurrn_8sparsmat_VecF3.get_type_counts = (PyArrayObject *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecF3_get_type_counts *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecF3_get_type_counts;
  __pyx_vtable_5lurrn_8sparsmat_VecF3.remap = (struct __pyx_obj_5lurrn_8sparsmat_VecF3 *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecF3 *, int, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecF3_remap;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_VecF3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_VecF3.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_VecF3.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_VecF3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "VecF3", (PyObject *)&__pyx_type_5lurrn_8sparsmat_VecF3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_VecF3 = &__pyx_type_5lurrn_8sparsmat_VecF3;
  __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorsF = &__pyx_vtable_5lurrn_8sparsmat_SparseVectorsF;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorsF.to_vec = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *(*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_14SparseVectorsF_to_vec;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorsF.add = (PyObject *(*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsF_add *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_14SparseVectorsF_add;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorsF._dotFull = (float (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsF *, const float *))__pyx_f_5lurrn_8sparsmat_14SparseVectorsF__dotFull;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_SparseVectorsF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_SparseVectorsF.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_SparseVectorsF.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorsF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "SparseVectorsF", (PyObject *)&__pyx_type_5lurrn_8sparsmat_SparseVectorsF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_SparseVectorsF = &__pyx_type_5lurrn_8sparsmat_SparseVectorsF;
  __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorD = &__pyx_vtable_5lurrn_8sparsmat_SparseVectorD;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorD.from_dense = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, __Pyx_memviewslice, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorD_from_dense;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorD.dotSelf = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorD_dotSelf;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorD._dotFull = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, const double *))__pyx_f_5lurrn_8sparsmat_13SparseVectorD__dotFull;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorD._dotFull_partial = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, const double *, int))__pyx_f_5lurrn_8sparsmat_13SparseVectorD__dotFull_partial;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorD.dotSparse = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorD_dotSparse;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorD._axpy = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, double *, double))__pyx_f_5lurrn_8sparsmat_13SparseVectorD__axpy;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorD.sqdist = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorD_sqdist;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorD.jaccard = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorD_jaccard;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorD.cosine = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorD_cosine;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorD.min_sum = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorD_min_sum;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorD.jsd_unnorm = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorD_jsd_unnorm;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorD.skew_unnorm = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, double, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorD_skew_unnorm;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorD.min_vals = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *(*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorD_min_vals;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorD.norm_l1 = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorD_norm_l1;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorD.norm_l2 = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorD_norm_l2;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorD.norm_lp = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, double, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_13SparseVectorD_norm_lp;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_SparseVectorD) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_SparseVectorD.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_SparseVectorD.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorD) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "SparseVectorD", (PyObject *)&__pyx_type_5lurrn_8sparsmat_SparseVectorD) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_SparseVectorD = &__pyx_type_5lurrn_8sparsmat_SparseVectorD;
  __pyx_vtabptr_5lurrn_8sparsmat_VecD1 = &__pyx_vtable_5lurrn_8sparsmat_VecD1;
  __pyx_vtable_5lurrn_8sparsmat_VecD1.get_count = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *, coordinate_t, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecD1_get_count;
  __pyx_vtable_5lurrn_8sparsmat_VecD1.compactify = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *))__pyx_f_5lurrn_8sparsmat_5VecD1_compactify;
  __pyx_vtable_5lurrn_8sparsmat_VecD1.ensure_compact = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *))__pyx_f_5lurrn_8sparsmat_5VecD1_ensure_compact;
  __pyx_vtable_5lurrn_8sparsmat_VecD1.c_add = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *, coordinate_t, double))__pyx_f_5lurrn_8sparsmat_5VecD1_c_add;
  __pyx_vtable_5lurrn_8sparsmat_VecD1.to_sparse = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecD1_to_sparse;
  __pyx_vtable_5lurrn_8sparsmat_VecD1.get_maxcol = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD1_get_maxcol *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecD1_get_maxcol;
  __pyx_vtable_5lurrn_8sparsmat_VecD1.get_type_counts = (PyArrayObject *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD1_get_type_counts *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecD1_get_type_counts;
  __pyx_vtable_5lurrn_8sparsmat_VecD1.remap = (struct __pyx_obj_5lurrn_8sparsmat_VecD1 *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecD1 *, int, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecD1_remap;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_VecD1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_VecD1.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_VecD1.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_VecD1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "VecD1", (PyObject *)&__pyx_type_5lurrn_8sparsmat_VecD1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_VecD1 = &__pyx_type_5lurrn_8sparsmat_VecD1;
  __pyx_vtabptr_5lurrn_8sparsmat_VecD2 = &__pyx_vtable_5lurrn_8sparsmat_VecD2;
  __pyx_vtable_5lurrn_8sparsmat_VecD2.get_count = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *, coordinate_t, coordinate_t, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecD2_get_count;
  __pyx_vtable_5lurrn_8sparsmat_VecD2.compactify = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *))__pyx_f_5lurrn_8sparsmat_5VecD2_compactify;
  __pyx_vtable_5lurrn_8sparsmat_VecD2.ensure_compact = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *))__pyx_f_5lurrn_8sparsmat_5VecD2_ensure_compact;
  __pyx_vtable_5lurrn_8sparsmat_VecD2.c_add = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *, coordinate_t, coordinate_t, double))__pyx_f_5lurrn_8sparsmat_5VecD2_c_add;
  __pyx_vtable_5lurrn_8sparsmat_VecD2.to_csr = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecD2_to_csr;
  __pyx_vtable_5lurrn_8sparsmat_VecD2.get_maxcol = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD2_get_maxcol *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecD2_get_maxcol;
  __pyx_vtable_5lurrn_8sparsmat_VecD2.get_type_counts = (PyArrayObject *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD2_get_type_counts *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecD2_get_type_counts;
  __pyx_vtable_5lurrn_8sparsmat_VecD2.remap = (struct __pyx_obj_5lurrn_8sparsmat_VecD2 *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecD2 *, int, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecD2_remap;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_VecD2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_VecD2.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_VecD2.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_VecD2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "VecD2", (PyObject *)&__pyx_type_5lurrn_8sparsmat_VecD2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_VecD2 = &__pyx_type_5lurrn_8sparsmat_VecD2;
  __pyx_vtabptr_5lurrn_8sparsmat_VecD3 = &__pyx_vtable_5lurrn_8sparsmat_VecD3;
  __pyx_vtable_5lurrn_8sparsmat_VecD3.get_count = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *, coordinate_t, coordinate_t, coordinate_t, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecD3_get_count;
  __pyx_vtable_5lurrn_8sparsmat_VecD3.compactify = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *))__pyx_f_5lurrn_8sparsmat_5VecD3_compactify;
  __pyx_vtable_5lurrn_8sparsmat_VecD3.ensure_compact = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *))__pyx_f_5lurrn_8sparsmat_5VecD3_ensure_compact;
  __pyx_vtable_5lurrn_8sparsmat_VecD3.c_add = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *, coordinate_t, coordinate_t, coordinate_t, double))__pyx_f_5lurrn_8sparsmat_5VecD3_c_add;
  __pyx_vtable_5lurrn_8sparsmat_VecD3.get_maxcol = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD3_get_maxcol *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecD3_get_maxcol;
  __pyx_vtable_5lurrn_8sparsmat_VecD3.get_type_counts = (PyArrayObject *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecD3_get_type_counts *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecD3_get_type_counts;
  __pyx_vtable_5lurrn_8sparsmat_VecD3.remap = (struct __pyx_obj_5lurrn_8sparsmat_VecD3 *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecD3 *, int, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecD3_remap;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_VecD3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_VecD3.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_VecD3.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_VecD3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "VecD3", (PyObject *)&__pyx_type_5lurrn_8sparsmat_VecD3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_VecD3 = &__pyx_type_5lurrn_8sparsmat_VecD3;
  __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorsD = &__pyx_vtable_5lurrn_8sparsmat_SparseVectorsD;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorsD.to_vec = (struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *(*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_14SparseVectorsD_to_vec;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorsD.add = (PyObject *(*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *, struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_14SparseVectorsD_add *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_14SparseVectorsD_add;
  __pyx_vtable_5lurrn_8sparsmat_SparseVectorsD._dotFull = (double (*)(struct __pyx_obj_5lurrn_8sparsmat_SparseVectorsD *, const double *))__pyx_f_5lurrn_8sparsmat_14SparseVectorsD__dotFull;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_SparseVectorsD) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_SparseVectorsD.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_SparseVectorsD.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_SparseVectorsD) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "SparseVectorsD", (PyObject *)&__pyx_type_5lurrn_8sparsmat_SparseVectorsD) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_SparseVectorsD = &__pyx_type_5lurrn_8sparsmat_SparseVectorsD;
  __pyx_vtabptr_5lurrn_8sparsmat_VecV1 = &__pyx_vtable_5lurrn_8sparsmat_VecV1;
  __pyx_vtable_5lurrn_8sparsmat_VecV1.get_count = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *, coordinate_t, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecV1_get_count;
  __pyx_vtable_5lurrn_8sparsmat_VecV1.compactify = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *))__pyx_f_5lurrn_8sparsmat_5VecV1_compactify;
  __pyx_vtable_5lurrn_8sparsmat_VecV1.ensure_compact = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *))__pyx_f_5lurrn_8sparsmat_5VecV1_ensure_compact;
  __pyx_vtable_5lurrn_8sparsmat_VecV1.c_add = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *, coordinate_t))__pyx_f_5lurrn_8sparsmat_5VecV1_c_add;
  __pyx_vtable_5lurrn_8sparsmat_VecV1.get_maxcol = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV1_get_maxcol *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecV1_get_maxcol;
  __pyx_vtable_5lurrn_8sparsmat_VecV1.get_type_counts = (PyArrayObject *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV1_get_type_counts *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecV1_get_type_counts;
  __pyx_vtable_5lurrn_8sparsmat_VecV1.remap = (struct __pyx_obj_5lurrn_8sparsmat_VecV1 *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecV1 *, int, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecV1_remap;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_VecV1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_VecV1.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_VecV1.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_VecV1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "VecV1", (PyObject *)&__pyx_type_5lurrn_8sparsmat_VecV1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_VecV1 = &__pyx_type_5lurrn_8sparsmat_VecV1;
  __pyx_vtabptr_5lurrn_8sparsmat_VecV2 = &__pyx_vtable_5lurrn_8sparsmat_VecV2;
  __pyx_vtable_5lurrn_8sparsmat_VecV2.get_count = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *, coordinate_t, coordinate_t, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecV2_get_count;
  __pyx_vtable_5lurrn_8sparsmat_VecV2.compactify = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *))__pyx_f_5lurrn_8sparsmat_5VecV2_compactify;
  __pyx_vtable_5lurrn_8sparsmat_VecV2.ensure_compact = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *))__pyx_f_5lurrn_8sparsmat_5VecV2_ensure_compact;
  __pyx_vtable_5lurrn_8sparsmat_VecV2.c_add = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *, coordinate_t, coordinate_t))__pyx_f_5lurrn_8sparsmat_5VecV2_c_add;
  __pyx_vtable_5lurrn_8sparsmat_VecV2.get_maxcol = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV2_get_maxcol *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecV2_get_maxcol;
  __pyx_vtable_5lurrn_8sparsmat_VecV2.get_type_counts = (PyArrayObject *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV2_get_type_counts *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecV2_get_type_counts;
  __pyx_vtable_5lurrn_8sparsmat_VecV2.remap = (struct __pyx_obj_5lurrn_8sparsmat_VecV2 *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecV2 *, int, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecV2_remap;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_VecV2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_VecV2.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_VecV2.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_VecV2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "VecV2", (PyObject *)&__pyx_type_5lurrn_8sparsmat_VecV2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_VecV2 = &__pyx_type_5lurrn_8sparsmat_VecV2;
  __pyx_vtabptr_5lurrn_8sparsmat_VecV3 = &__pyx_vtable_5lurrn_8sparsmat_VecV3;
  __pyx_vtable_5lurrn_8sparsmat_VecV3.get_count = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *, coordinate_t, coordinate_t, coordinate_t, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecV3_get_count;
  __pyx_vtable_5lurrn_8sparsmat_VecV3.compactify = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *))__pyx_f_5lurrn_8sparsmat_5VecV3_compactify;
  __pyx_vtable_5lurrn_8sparsmat_VecV3.ensure_compact = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *))__pyx_f_5lurrn_8sparsmat_5VecV3_ensure_compact;
  __pyx_vtable_5lurrn_8sparsmat_VecV3.c_add = (void (*)(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *, coordinate_t, coordinate_t, coordinate_t))__pyx_f_5lurrn_8sparsmat_5VecV3_c_add;
  __pyx_vtable_5lurrn_8sparsmat_VecV3.get_maxcol = (int (*)(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV3_get_maxcol *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecV3_get_maxcol;
  __pyx_vtable_5lurrn_8sparsmat_VecV3.get_type_counts = (PyArrayObject *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *, int __pyx_skip_dispatch, struct __pyx_opt_args_5lurrn_8sparsmat_5VecV3_get_type_counts *__pyx_optional_args))__pyx_f_5lurrn_8sparsmat_5VecV3_get_type_counts;
  __pyx_vtable_5lurrn_8sparsmat_VecV3.remap = (struct __pyx_obj_5lurrn_8sparsmat_VecV3 *(*)(struct __pyx_obj_5lurrn_8sparsmat_VecV3 *, int, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_5VecV3_remap;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_VecV3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_VecV3.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_VecV3.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_VecV3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "VecV3", (PyObject *)&__pyx_type_5lurrn_8sparsmat_VecV3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_VecV3 = &__pyx_type_5lurrn_8sparsmat_VecV3;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_CSRMatrixI_item_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_CSRMatrixI_item_iter.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "CSRMatrixI_item_iter", (PyObject *)&__pyx_type_5lurrn_8sparsmat_CSRMatrixI_item_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_CSRMatrixI_item_iter = &__pyx_type_5lurrn_8sparsmat_CSRMatrixI_item_iter;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_CSRMatrixF_item_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_CSRMatrixF_item_iter.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "CSRMatrixF_item_iter", (PyObject *)&__pyx_type_5lurrn_8sparsmat_CSRMatrixF_item_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_CSRMatrixF_item_iter = &__pyx_type_5lurrn_8sparsmat_CSRMatrixF_item_iter;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_CSRMatrixD_item_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_CSRMatrixD_item_iter.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "CSRMatrixD_item_iter", (PyObject *)&__pyx_type_5lurrn_8sparsmat_CSRMatrixD_item_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_CSRMatrixD_item_iter = &__pyx_type_5lurrn_8sparsmat_CSRMatrixD_item_iter;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_IVecI1_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_IVecI1_iter.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "IVecI1_iter", (PyObject *)&__pyx_type_5lurrn_8sparsmat_IVecI1_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_IVecI1_iter = &__pyx_type_5lurrn_8sparsmat_IVecI1_iter;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_LargeVecI1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_LargeVecI1.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "LargeVecI1", (PyObject *)&__pyx_type_5lurrn_8sparsmat_LargeVecI1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_LargeVecI1 = &__pyx_type_5lurrn_8sparsmat_LargeVecI1;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_IVecI2_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_IVecI2_iter.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "IVecI2_iter", (PyObject *)&__pyx_type_5lurrn_8sparsmat_IVecI2_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_IVecI2_iter = &__pyx_type_5lurrn_8sparsmat_IVecI2_iter;
  __pyx_vtabptr_5lurrn_8sparsmat_LargeVecI2 = &__pyx_vtable_5lurrn_8sparsmat_LargeVecI2;
  __pyx_vtable_5lurrn_8sparsmat_LargeVecI2.to_csr = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixI *(*)(struct __pyx_obj_5lurrn_8sparsmat_LargeVecI2 *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10LargeVecI2_to_csr;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_LargeVecI2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_LargeVecI2.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_LargeVecI2.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_LargeVecI2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "LargeVecI2", (PyObject *)&__pyx_type_5lurrn_8sparsmat_LargeVecI2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_LargeVecI2 = &__pyx_type_5lurrn_8sparsmat_LargeVecI2;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_IVecI3_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_IVecI3_iter.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "IVecI3_iter", (PyObject *)&__pyx_type_5lurrn_8sparsmat_IVecI3_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_IVecI3_iter = &__pyx_type_5lurrn_8sparsmat_IVecI3_iter;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_LargeVecI3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_LargeVecI3.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "LargeVecI3", (PyObject *)&__pyx_type_5lurrn_8sparsmat_LargeVecI3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_LargeVecI3 = &__pyx_type_5lurrn_8sparsmat_LargeVecI3;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_IVecF1_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_IVecF1_iter.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "IVecF1_iter", (PyObject *)&__pyx_type_5lurrn_8sparsmat_IVecF1_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_IVecF1_iter = &__pyx_type_5lurrn_8sparsmat_IVecF1_iter;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_LargeVecF1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_LargeVecF1.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "LargeVecF1", (PyObject *)&__pyx_type_5lurrn_8sparsmat_LargeVecF1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_LargeVecF1 = &__pyx_type_5lurrn_8sparsmat_LargeVecF1;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_IVecF2_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_IVecF2_iter.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "IVecF2_iter", (PyObject *)&__pyx_type_5lurrn_8sparsmat_IVecF2_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_IVecF2_iter = &__pyx_type_5lurrn_8sparsmat_IVecF2_iter;
  __pyx_vtabptr_5lurrn_8sparsmat_LargeVecF2 = &__pyx_vtable_5lurrn_8sparsmat_LargeVecF2;
  __pyx_vtable_5lurrn_8sparsmat_LargeVecF2.to_csr = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixF *(*)(struct __pyx_obj_5lurrn_8sparsmat_LargeVecF2 *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10LargeVecF2_to_csr;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_LargeVecF2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_LargeVecF2.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_LargeVecF2.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_LargeVecF2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "LargeVecF2", (PyObject *)&__pyx_type_5lurrn_8sparsmat_LargeVecF2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_LargeVecF2 = &__pyx_type_5lurrn_8sparsmat_LargeVecF2;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_IVecF3_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_IVecF3_iter.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "IVecF3_iter", (PyObject *)&__pyx_type_5lurrn_8sparsmat_IVecF3_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_IVecF3_iter = &__pyx_type_5lurrn_8sparsmat_IVecF3_iter;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_LargeVecF3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_LargeVecF3.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "LargeVecF3", (PyObject *)&__pyx_type_5lurrn_8sparsmat_LargeVecF3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_LargeVecF3 = &__pyx_type_5lurrn_8sparsmat_LargeVecF3;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_IVecD1_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_IVecD1_iter.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "IVecD1_iter", (PyObject *)&__pyx_type_5lurrn_8sparsmat_IVecD1_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_IVecD1_iter = &__pyx_type_5lurrn_8sparsmat_IVecD1_iter;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_LargeVecD1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_LargeVecD1.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "LargeVecD1", (PyObject *)&__pyx_type_5lurrn_8sparsmat_LargeVecD1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_LargeVecD1 = &__pyx_type_5lurrn_8sparsmat_LargeVecD1;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_IVecD2_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_IVecD2_iter.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "IVecD2_iter", (PyObject *)&__pyx_type_5lurrn_8sparsmat_IVecD2_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_IVecD2_iter = &__pyx_type_5lurrn_8sparsmat_IVecD2_iter;
  __pyx_vtabptr_5lurrn_8sparsmat_LargeVecD2 = &__pyx_vtable_5lurrn_8sparsmat_LargeVecD2;
  __pyx_vtable_5lurrn_8sparsmat_LargeVecD2.to_csr = (struct __pyx_obj_5lurrn_8sparsmat_CSRMatrixD *(*)(struct __pyx_obj_5lurrn_8sparsmat_LargeVecD2 *, int __pyx_skip_dispatch))__pyx_f_5lurrn_8sparsmat_10LargeVecD2_to_csr;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_LargeVecD2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_LargeVecD2.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_5lurrn_8sparsmat_LargeVecD2.tp_dict, __pyx_vtabptr_5lurrn_8sparsmat_LargeVecD2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "LargeVecD2", (PyObject *)&__pyx_type_5lurrn_8sparsmat_LargeVecD2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_LargeVecD2 = &__pyx_type_5lurrn_8sparsmat_LargeVecD2;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_IVecD3_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_IVecD3_iter.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "IVecD3_iter", (PyObject *)&__pyx_type_5lurrn_8sparsmat_IVecD3_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_IVecD3_iter = &__pyx_type_5lurrn_8sparsmat_IVecD3_iter;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_LargeVecD3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_LargeVecD3.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "LargeVecD3", (PyObject *)&__pyx_type_5lurrn_8sparsmat_LargeVecD3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_LargeVecD3 = &__pyx_type_5lurrn_8sparsmat_LargeVecD3;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_IVecV1_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_IVecV1_iter.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "IVecV1_iter", (PyObject *)&__pyx_type_5lurrn_8sparsmat_IVecV1_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_IVecV1_iter = &__pyx_type_5lurrn_8sparsmat_IVecV1_iter;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_LargeVecV1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_LargeVecV1.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "LargeVecV1", (PyObject *)&__pyx_type_5lurrn_8sparsmat_LargeVecV1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_LargeVecV1 = &__pyx_type_5lurrn_8sparsmat_LargeVecV1;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_IVecV2_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_IVecV2_iter.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "IVecV2_iter", (PyObject *)&__pyx_type_5lurrn_8sparsmat_IVecV2_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_IVecV2_iter = &__pyx_type_5lurrn_8sparsmat_IVecV2_iter;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_LargeVecV2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_LargeVecV2.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "LargeVecV2", (PyObject *)&__pyx_type_5lurrn_8sparsmat_LargeVecV2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_LargeVecV2 = &__pyx_type_5lurrn_8sparsmat_LargeVecV2;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_IVecV3_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_IVecV3_iter.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "IVecV3_iter", (PyObject *)&__pyx_type_5lurrn_8sparsmat_IVecV3_iter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_IVecV3_iter = &__pyx_type_5lurrn_8sparsmat_IVecV3_iter;
  if (PyType_Ready(&__pyx_type_5lurrn_8sparsmat_LargeVecV3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_5lurrn_8sparsmat_LargeVecV3.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "LargeVecV3", (PyObject *)&__pyx_type_5lurrn_8sparsmat_LargeVecV3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5lurrn_8sparsmat_LargeVecV3 = &__pyx_type_5lurrn_8sparsmat_LargeVecV3;
  if (PyType_Ready(&__pyx_type___pyx_array) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type___pyx_array.tp_print = 0;
  __pyx_array_type = &__pyx_type___pyx_array;
  if (PyType_Ready(&__pyx_type___pyx_MemviewEnum) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type___pyx_MemviewEnum.tp_print = 0;
  __pyx_MemviewEnum_type = &__pyx_type___pyx_MemviewEnum;
  __pyx_vtabptr_memoryview = &__pyx_vtable_memoryview;
  __pyx_vtable_memoryview.get_item_pointer = (char *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_get_item_pointer;
  __pyx_vtable_memoryview.is_slice = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_is_slice;
  __pyx_vtable_memoryview.setitem_slice_assignment = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_slice_assignment;
  __pyx_vtable_memoryview.setitem_slice_assign_scalar = (PyObject *(*)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_setitem_slice_assign_scalar;
  __pyx_vtable_memoryview.setitem_indexed = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_indexed;
  __pyx_vtable_memoryview.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryview_convert_item_to_object;
  __pyx_vtable_memoryview.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryview_assign_item_from_object;
  if (PyType_Ready(&__pyx_type___pyx_memoryview) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type___pyx_memoryview.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type___pyx_memoryview.tp_dict, __pyx_vtabptr_memoryview) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_memoryview_type = &__pyx_type___pyx_memoryview;
  __pyx_vtabptr__memoryviewslice = &__pyx_vtable__memoryviewslice;
  __pyx_vtable__memoryviewslice.__pyx_base = *__pyx_vtabptr_memoryview;
  __pyx_vtable__memoryviewslice.__pyx_base.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryviewslice_convert_item_to_object;
  __pyx_vtable__memoryviewslice.__pyx_base.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryviewslice_assign_item_from_object;
  __pyx_type___pyx_memoryviewslice.tp_base = __pyx_memoryview_type;
  if (PyType_Ready(&__pyx_type___pyx_memoryviewslice) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type___pyx_memoryviewslice.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_memoryviewslice_type = &__pyx_type___pyx_memoryviewslice;
  /*--- Type import code ---*/
  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", 
  #if CYTHON_COMPILING_IN_PYPY
  sizeof(PyTypeObject),
  #else
  sizeof(PyHeapTypeObject),
  #endif
  0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "lurrn/sparsmat.pyx":3
 * # -*- mode:cython *-
 * # vi:ft=python
 * import mmap             # <<<<<<<<<<<<<<
 * import sys
 * import numpy
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_mmap, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_mmap, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4
 * # vi:ft=python
 * import mmap
 * import sys             # <<<<<<<<<<<<<<
 * import numpy
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5
 * import mmap
 * import sys
 * import numpy             # <<<<<<<<<<<<<<
 * 
 * cdef unsigned int BIG_ITEMS=1000000
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":7
 * import numpy
 * 
 * cdef unsigned int BIG_ITEMS=1000000             # <<<<<<<<<<<<<<
 * DEF CHUNK_SIZE = 256
 * 
 */
  __pyx_v_5lurrn_8sparsmat_BIG_ITEMS = 1000000;

  /* "lurrn/sparsmat.pyx":1384
 * 
 * 
 * def csrFromBuffer(object buf):             # <<<<<<<<<<<<<<
 *     """takes an object conforming to the Buffer protocol and
 *     creates a CSR matrix from that."""
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5lurrn_8sparsmat_1csrFromBuffer, NULL, __pyx_n_s_lurrn_sparsmat); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_csrFromBuffer, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1430
 *         raise ValueError("wrong tcode "+tcode)
 * 
 * def mmapCSR(f):             # <<<<<<<<<<<<<<
 *     ## py2.4 compat: determine length
 *     ## instead of passing length=0
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5lurrn_8sparsmat_3mmapCSR, NULL, __pyx_n_s_lurrn_sparsmat); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_mmapCSR, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":2852
 *         return (data,indices,indptr)
 * 
 * emptyvec_I=SparseVectorI([])             # <<<<<<<<<<<<<<
 * 
 * cdef class SparseVectorsI:
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorI)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_XGOTREF(((PyObject *)__pyx_v_5lurrn_8sparsmat_emptyvec_I));
  __Pyx_DECREF_SET(__pyx_v_5lurrn_8sparsmat_emptyvec_I, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorI *)__pyx_t_1));
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":4336
 *         return (data,indices,indptr)
 * 
 * emptyvec_F=SparseVectorF([])             # <<<<<<<<<<<<<<
 * 
 * cdef class SparseVectorsF:
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorF)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_XGOTREF(((PyObject *)__pyx_v_5lurrn_8sparsmat_emptyvec_F));
  __Pyx_DECREF_SET(__pyx_v_5lurrn_8sparsmat_emptyvec_F, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorF *)__pyx_t_1));
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":5820
 *         return (data,indices,indptr)
 * 
 * emptyvec_D=SparseVectorD([])             # <<<<<<<<<<<<<<
 * 
 * cdef class SparseVectorsD:
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5lurrn_8sparsmat_SparseVectorD)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_XGOTREF(((PyObject *)__pyx_v_5lurrn_8sparsmat_emptyvec_D));
  __Pyx_DECREF_SET(__pyx_v_5lurrn_8sparsmat_emptyvec_D, ((struct __pyx_obj_5lurrn_8sparsmat_SparseVectorD *)__pyx_t_1));
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":6633
 * 
 * 
 * def run_test():             # <<<<<<<<<<<<<<
 *     cdef VecI2 counts
 *     counts=VecI2()
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5lurrn_8sparsmat_5run_test, NULL, __pyx_n_s_lurrn_sparsmat); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_run_test, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lurrn/sparsmat.pyx":1
 * # -*- mode:cython *-             # <<<<<<<<<<<<<<
 * # vi:ft=python
 * import mmap
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "View.MemoryView":203
 *         info.obj = self
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(array self):
 */
  __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_array_getbuffer)), __pyx_k_getbuffer_obj_view_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_array_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_array_type);

  /* "View.MemoryView":276
 *         return self.name
 * 
 * cdef generic = Enum("<strided and direct or indirect>")             # <<<<<<<<<<<<<<
 * cdef strided = Enum("<strided and direct>") # default
 * cdef indirect = Enum("<strided and indirect>")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_MemviewEnum_type)), __pyx_tuple__120, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XGOTREF(generic);
  __Pyx_DECREF_SET(generic, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":277
 * 
 * cdef generic = Enum("<strided and direct or indirect>")
 * cdef strided = Enum("<strided and direct>") # default             # <<<<<<<<<<<<<<
 * cdef indirect = Enum("<strided and indirect>")
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_MemviewEnum_type)), __pyx_tuple__121, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XGOTREF(strided);
  __Pyx_DECREF_SET(strided, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":278
 * cdef generic = Enum("<strided and direct or indirect>")
 * cdef strided = Enum("<strided and direct>") # default
 * cdef indirect = Enum("<strided and indirect>")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_MemviewEnum_type)), __pyx_tuple__122, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XGOTREF(indirect);
  __Pyx_DECREF_SET(indirect, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":281
 * 
 * 
 * cdef contiguous = Enum("<contiguous and direct>")             # <<<<<<<<<<<<<<
 * cdef indirect_contiguous = Enum("<contiguous and indirect>")
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_MemviewEnum_type)), __pyx_tuple__123, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XGOTREF(contiguous);
  __Pyx_DECREF_SET(contiguous, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":282
 * 
 * cdef contiguous = Enum("<contiguous and direct>")
 * cdef indirect_contiguous = Enum("<contiguous and indirect>")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_MemviewEnum_type)), __pyx_tuple__124, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XGOTREF(indirect_contiguous);
  __Pyx_DECREF_SET(indirect_contiguous, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":496
 *         info.obj = self
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), __pyx_k_getbuffer_obj_view_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_memoryview_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_memoryview_type);

  /* "View.MemoryView":953
 *             return self.from_object
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), __pyx_k_getbuffer_obj_view_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_memoryviewslice_type);

  /* "View.MemoryView":1361
 * 
 * @cname('__pyx_memoryview__slice_assign_scalar')
 * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                               Py_ssize_t *strides, int ndim,
 *                               size_t itemsize, void *item) nogil:
 */

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init lurrn.sparsmat", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init lurrn.sparsmat");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* Runtime support code */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = func->ob_type->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
#else
    if (likely(PyCFunction_Check(func))) {
#endif
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject* args = PyTuple_Pack(1, arg);
    return (likely(args)) ? __Pyx_PyObject_Call(func, args, NULL) : NULL;
}
#endif

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) {
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
}
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (likely(Py_TYPE(obj) == type)) return 1;
        #if PY_MAJOR_VERSION == 2
        else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(PyObject_TypeCheck(obj, type))) return 1;
    }
    __Pyx_RaiseArgumentTypeInvalid(name, obj, type);
    return 0;
}

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_Restore(type, value, tb);
#endif
}
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(type, value, tb);
#endif
}

#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
    }
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                if (PyObject_IsSubclass(instance_class, type)) {
                    type = instance_class;
                } else {
                    instance_class = NULL;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
#if PY_VERSION_HEX >= 0x03030000
    if (cause) {
#else
    if (cause && cause != Py_None) {
#endif
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(tmp_type, tmp_value, tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#else
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON
    result = PyDict_GetItem(__pyx_d, name);
    if (likely(result)) {
        Py_INCREF(result);
    } else {
#else
    result = PyObject_GetItem(__pyx_d, name);
    if (!result) {
        PyErr_Clear();
#endif
        result = __Pyx_GetBuiltinName(name);
    }
    return result;
}

static CYTHON_INLINE int __Pyx_IsLittleEndian(void) {
  unsigned int n = 1;
  return *(unsigned char*)(&n) != 0;
}
static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
                              __Pyx_BufFmt_StackElem* stack,
                              __Pyx_TypeInfo* type) {
  stack[0].field = &ctx->root;
  stack[0].parent_offset = 0;
  ctx->root.type = type;
  ctx->root.name = "buffer dtype";
  ctx->root.offset = 0;
  ctx->head = stack;
  ctx->head->field = &ctx->root;
  ctx->fmt_offset = 0;
  ctx->head->parent_offset = 0;
  ctx->new_packmode = '@';
  ctx->enc_packmode = '@';
  ctx->new_count = 1;
  ctx->enc_count = 0;
  ctx->enc_type = 0;
  ctx->is_complex = 0;
  ctx->is_valid_array = 0;
  ctx->struct_alignment = 0;
  while (type->typegroup == 'S') {
    ++ctx->head;
    ctx->head->field = type->fields;
    ctx->head->parent_offset = 0;
    type = type->fields->type;
  }
}
static int __Pyx_BufFmt_ParseNumber(const char** ts) {
    int count;
    const char* t = *ts;
    if (*t < '0' || *t > '9') {
      return -1;
    } else {
        count = *t++ - '0';
        while (*t >= '0' && *t < '9') {
            count *= 10;
            count += *t++ - '0';
        }
    }
    *ts = t;
    return count;
}
static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
    int number = __Pyx_BufFmt_ParseNumber(ts);
    if (number == -1)
        PyErr_Format(PyExc_ValueError,\
                     "Does not understand character buffer dtype format string ('%c')", **ts);
    return number;
}
static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
  PyErr_Format(PyExc_ValueError,
               "Unexpected format string character: '%c'", ch);
}
static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
  switch (ch) {
    case 'c': return "'char'";
    case 'b': return "'signed char'";
    case 'B': return "'unsigned char'";
    case 'h': return "'short'";
    case 'H': return "'unsigned short'";
    case 'i': return "'int'";
    case 'I': return "'unsigned int'";
    case 'l': return "'long'";
    case 'L': return "'unsigned long'";
    case 'q': return "'long long'";
    case 'Q': return "'unsigned long long'";
    case 'f': return (is_complex ? "'complex float'" : "'float'");
    case 'd': return (is_complex ? "'complex double'" : "'double'");
    case 'g': return (is_complex ? "'complex long double'" : "'long double'");
    case 'T': return "a struct";
    case 'O': return "Python object";
    case 'P': return "a pointer";
    case 's': case 'p': return "a string";
    case 0: return "end";
    default: return "unparseable format string";
  }
}
static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return 2;
    case 'i': case 'I': case 'l': case 'L': return 4;
    case 'q': case 'Q': return 8;
    case 'f': return (is_complex ? 8 : 4);
    case 'd': return (is_complex ? 16 : 8);
    case 'g': {
      PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
      return 0;
    }
    case 'O': case 'P': return sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
  switch (ch) {
    case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(short);
    case 'i': case 'I': return sizeof(int);
    case 'l': case 'L': return sizeof(long);
    #ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(PY_LONG_LONG);
    #endif
    case 'f': return sizeof(float) * (is_complex ? 2 : 1);
    case 'd': return sizeof(double) * (is_complex ? 2 : 1);
    case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
    case 'O': case 'P': return sizeof(void*);
    default: {
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
  }
}
typedef struct { char c; short x; } __Pyx_st_short;
typedef struct { char c; int x; } __Pyx_st_int;
typedef struct { char c; long x; } __Pyx_st_long;
typedef struct { char c; float x; } __Pyx_st_float;
typedef struct { char c; double x; } __Pyx_st_double;
typedef struct { char c; long double x; } __Pyx_st_longdouble;
typedef struct { char c; void *x; } __Pyx_st_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
    case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
    case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
#endif
    case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
    case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
    case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
    case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
/* These are for computing the padding at the end of the struct to align
   on the first member of the struct. This will probably the same as above,
   but we don't have any guarantees.
 */
typedef struct { short x; char c; } __Pyx_pad_short;
typedef struct { int x; char c; } __Pyx_pad_int;
typedef struct { long x; char c; } __Pyx_pad_long;
typedef struct { float x; char c; } __Pyx_pad_float;
typedef struct { double x; char c; } __Pyx_pad_double;
typedef struct { long double x; char c; } __Pyx_pad_longdouble;
typedef struct { void *x; char c; } __Pyx_pad_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
    case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
    case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
#endif
    case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
    case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
    case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
    case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
  switch (ch) {
    case 'c':
        return 'H';
    case 'b': case 'h': case 'i':
    case 'l': case 'q': case 's': case 'p':
        return 'I';
    case 'B': case 'H': case 'I': case 'L': case 'Q':
        return 'U';
    case 'f': case 'd': case 'g':
        return (is_complex ? 'C' : 'R');
    case 'O':
        return 'O';
    case 'P':
        return 'P';
    default: {
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
  }
}
static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
  if (ctx->head == NULL || ctx->head->field == &ctx->root) {
    const char* expected;
    const char* quote;
    if (ctx->head == NULL) {
      expected = "end";
      quote = "";
    } else {
      expected = ctx->head->field->type->name;
      quote = "'";
    }
    PyErr_Format(PyExc_ValueError,
                 "Buffer dtype mismatch, expected %s%s%s but got %s",
                 quote, expected, quote,
                 __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
  } else {
    __Pyx_StructField* field = ctx->head->field;
    __Pyx_StructField* parent = (ctx->head - 1)->field;
    PyErr_Format(PyExc_ValueError,
                 "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
                 field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
                 parent->type->name, field->name);
  }
}
static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
  char group;
  size_t size, offset, arraysize = 1;
  if (ctx->enc_type == 0) return 0;
  if (ctx->head->field->type->arraysize[0]) {
    int i, ndim = 0;
    if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
        ctx->is_valid_array = ctx->head->field->type->ndim == 1;
        ndim = 1;
        if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
            PyErr_Format(PyExc_ValueError,
                         "Expected a dimension of size %zu, got %zu",
                         ctx->head->field->type->arraysize[0], ctx->enc_count);
            return -1;
        }
    }
    if (!ctx->is_valid_array) {
      PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
                   ctx->head->field->type->ndim, ndim);
      return -1;
    }
    for (i = 0; i < ctx->head->field->type->ndim; i++) {
      arraysize *= ctx->head->field->type->arraysize[i];
    }
    ctx->is_valid_array = 0;
    ctx->enc_count = 1;
  }
  group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
  do {
    __Pyx_StructField* field = ctx->head->field;
    __Pyx_TypeInfo* type = field->type;
    if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
      size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
    } else {
      size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
    }
    if (ctx->enc_packmode == '@') {
      size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
      size_t align_mod_offset;
      if (align_at == 0) return -1;
      align_mod_offset = ctx->fmt_offset % align_at;
      if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
      if (ctx->struct_alignment == 0)
          ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
                                                                 ctx->is_complex);
    }
    if (type->size != size || type->typegroup != group) {
      if (type->typegroup == 'C' && type->fields != NULL) {
        size_t parent_offset = ctx->head->parent_offset + field->offset;
        ++ctx->head;
        ctx->head->field = type->fields;
        ctx->head->parent_offset = parent_offset;
        continue;
      }
      if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
      } else {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return -1;
      }
    }
    offset = ctx->head->parent_offset + field->offset;
    if (ctx->fmt_offset != offset) {
      PyErr_Format(PyExc_ValueError,
                   "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected",
                   (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
      return -1;
    }
    ctx->fmt_offset += size;
    if (arraysize)
      ctx->fmt_offset += (arraysize - 1) * size;
    --ctx->enc_count;
    while (1) {
      if (field == &ctx->root) {
        ctx->head = NULL;
        if (ctx->enc_count != 0) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return -1;
        }
        break;
      }
      ctx->head->field = ++field;
      if (field->type == NULL) {
        --ctx->head;
        field = ctx->head->field;
        continue;
      } else if (field->type->typegroup == 'S') {
        size_t parent_offset = ctx->head->parent_offset + field->offset;
        if (field->type->fields->type == NULL) continue;
        field = field->type->fields;
        ++ctx->head;
        ctx->head->field = field;
        ctx->head->parent_offset = parent_offset;
        break;
      } else {
        break;
      }
    }
  } while (ctx->enc_count);
  ctx->enc_type = 0;
  ctx->is_complex = 0;
  return 0;
}
static CYTHON_INLINE PyObject *
__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
{
    const char *ts = *tsp;
    int i = 0, number;
    int ndim = ctx->head->field->type->ndim;
;
    ++ts;
    if (ctx->new_count != 1) {
        PyErr_SetString(PyExc_ValueError,
                        "Cannot handle repeated arrays in format string");
        return NULL;
    }
    if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
    while (*ts && *ts != ')') {
        switch (*ts) {
            case ' ': case '\f': case '\r': case '\n': case '\t': case '\v':  continue;
            default:  break;
        }
        number = __Pyx_BufFmt_ExpectNumber(&ts);
        if (number == -1) return NULL;
        if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
            return PyErr_Format(PyExc_ValueError,
                        "Expected a dimension of size %zu, got %d",
                        ctx->head->field->type->arraysize[i], number);
        if (*ts != ',' && *ts != ')')
            return PyErr_Format(PyExc_ValueError,
                                "Expected a comma in format string, got '%c'", *ts);
        if (*ts == ',') ts++;
        i++;
    }
    if (i != ndim)
        return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
                            ctx->head->field->type->ndim, i);
    if (!*ts) {
        PyErr_SetString(PyExc_ValueError,
                        "Unexpected end of format string, expected ')'");
        return NULL;
    }
    ctx->is_valid_array = 1;
    ctx->new_count = 1;
    *tsp = ++ts;
    return Py_None;
}
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
  int got_Z = 0;
  while (1) {
    switch(*ts) {
      case 0:
        if (ctx->enc_type != 0 && ctx->head == NULL) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return NULL;
        }
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        if (ctx->head != NULL) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return NULL;
        }
        return ts;
      case ' ':
      case '\r':
      case '\n':
        ++ts;
        break;
      case '<':
        if (!__Pyx_IsLittleEndian()) {
          PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
          return NULL;
        }
        ctx->new_packmode = '=';
        ++ts;
        break;
      case '>':
      case '!':
        if (__Pyx_IsLittleEndian()) {
          PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
          return NULL;
        }
        ctx->new_packmode = '=';
        ++ts;
        break;
      case '=':
      case '@':
      case '^':
        ctx->new_packmode = *ts++;
        break;
      case 'T':
        {
          const char* ts_after_sub;
          size_t i, struct_count = ctx->new_count;
          size_t struct_alignment = ctx->struct_alignment;
          ctx->new_count = 1;
          ++ts;
          if (*ts != '{') {
            PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
            return NULL;
          }
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_type = 0;
          ctx->enc_count = 0;
          ctx->struct_alignment = 0;
          ++ts;
          ts_after_sub = ts;
          for (i = 0; i != struct_count; ++i) {
            ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
            if (!ts_after_sub) return NULL;
          }
          ts = ts_after_sub;
          if (struct_alignment) ctx->struct_alignment = struct_alignment;
        }
        break;
      case '}':
        {
          size_t alignment = ctx->struct_alignment;
          ++ts;
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_type = 0;
          if (alignment && ctx->fmt_offset % alignment) {
            ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
          }
        }
        return ts;
      case 'x':
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        ctx->fmt_offset += ctx->new_count;
        ctx->new_count = 1;
        ctx->enc_count = 0;
        ctx->enc_type = 0;
        ctx->enc_packmode = ctx->new_packmode;
        ++ts;
        break;
      case 'Z':
        got_Z = 1;
        ++ts;
        if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
          __Pyx_BufFmt_RaiseUnexpectedChar('Z');
          return NULL;
        }
      case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
      case 'l': case 'L': case 'q': case 'Q':
      case 'f': case 'd': case 'g':
      case 'O': case 'p':
        if (ctx->enc_type == *ts && got_Z == ctx->is_complex &&
            ctx->enc_packmode == ctx->new_packmode) {
          ctx->enc_count += ctx->new_count;
          ctx->new_count = 1;
          got_Z = 0;
          ++ts;
          break;
        }
      case 's':
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        ctx->enc_count = ctx->new_count;
        ctx->enc_packmode = ctx->new_packmode;
        ctx->enc_type = *ts;
        ctx->is_complex = got_Z;
        ++ts;
        ctx->new_count = 1;
        got_Z = 0;
        break;
      case ':':
        ++ts;
        while(*ts != ':') ++ts;
        ++ts;
        break;
      case '(':
        if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
        break;
      default:
        {
          int number = __Pyx_BufFmt_ExpectNumber(&ts);
          if (number == -1) return NULL;
          ctx->new_count = (size_t)number;
        }
    }
  }
}
static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) {
  buf->buf = NULL;
  buf->obj = NULL;
  buf->strides = __Pyx_zeros;
  buf->shape = __Pyx_zeros;
  buf->suboffsets = __Pyx_minusones;
}
static CYTHON_INLINE int __Pyx_GetBufferAndValidate(
        Py_buffer* buf, PyObject* obj,  __Pyx_TypeInfo* dtype, int flags,
        int nd, int cast, __Pyx_BufFmt_StackElem* stack)
{
  if (obj == Py_None || obj == NULL) {
    __Pyx_ZeroBuffer(buf);
    return 0;
  }
  buf->buf = NULL;
  if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail;
  if (buf->ndim != nd) {
    PyErr_Format(PyExc_ValueError,
                 "Buffer has wrong number of dimensions (expected %d, got %d)",
                 nd, buf->ndim);
    goto fail;
  }
  if (!cast) {
    __Pyx_BufFmt_Context ctx;
    __Pyx_BufFmt_Init(&ctx, stack, dtype);
    if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
  }
  if ((unsigned)buf->itemsize != dtype->size) {
    PyErr_Format(PyExc_ValueError,
      "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)",
      buf->itemsize, (buf->itemsize > 1) ? "s" : "",
      dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : "");
    goto fail;
  }
  if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
  return 0;
fail:;
  __Pyx_ZeroBuffer(buf);
  return -1;
}
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
  if (info->buf == NULL) return;
  if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
  __Pyx_ReleaseBuffer(info);
}

static void __Pyx_RaiseBufferFallbackError(void) {
  PyErr_SetString(PyExc_ValueError,
     "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!");
}

static void __Pyx_RaiseBufferIndexError(int axis) {
  PyErr_Format(PyExc_IndexError,
     "Out of bounds on buffer access (axis %d)", axis);
}

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
#else
    if (likely(PyCFunction_Check(func))) {
#endif
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
}

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (PyErr_ExceptionMatches(PyExc_OverflowError))
                        PyErr_Clear();
                    else
                        return NULL;
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                 index, (index == 1) ? "" : "s");
}

static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else {
        return __Pyx_IterFinish();
    }
    return 0;
}

static CYTHON_INLINE int __Pyx_div_int(int a, int b) {
    int q = a / b;
    int r = a - q*b;
    q -= ((r != 0) & ((r ^ b) < 0));
    return q;
}

static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
    long q = a / b;
    long r = a - q*b;
    q -= ((r != 0) & ((r ^ b) < 0));
    return q;
}

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
#if CYTHON_COMPILING_IN_PYPY
    if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
        goto invalid_keyword;
    return 1;
#else
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
        #endif
            if (unlikely(!PyUnicode_Check(key)))
                goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    return 0;
#endif
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
    return 0;
}

static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        const char *ps1, *ps2;
        Py_ssize_t length = PyBytes_GET_SIZE(s1);
        if (length != PyBytes_GET_SIZE(s2))
            return (equals == Py_NE);
        ps1 = PyBytes_AS_STRING(s1);
        ps2 = PyBytes_AS_STRING(s2);
        if (ps1[0] != ps2[0]) {
            return (equals == Py_NE);
        } else if (length == 1) {
            return (equals == Py_EQ);
        } else {
            int result = memcmp(ps1, ps2, (size_t)length);
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
#if PY_MAJOR_VERSION < 3
    PyObject* owned_ref = NULL;
#endif
    int s1_is_unicode, s2_is_unicode;
    if (s1 == s2) {
        goto return_eq;
    }
    s1_is_unicode = PyUnicode_CheckExact(s1);
    s2_is_unicode = PyUnicode_CheckExact(s2);
#if PY_MAJOR_VERSION < 3
    if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
        owned_ref = PyUnicode_FromObject(s2);
        if (unlikely(!owned_ref))
            return -1;
        s2 = owned_ref;
        s2_is_unicode = 1;
    } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
        owned_ref = PyUnicode_FromObject(s1);
        if (unlikely(!owned_ref))
            return -1;
        s1 = owned_ref;
        s1_is_unicode = 1;
    } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
        return __Pyx_PyBytes_Equals(s1, s2, equals);
    }
#endif
    if (s1_is_unicode & s2_is_unicode) {
        Py_ssize_t length;
        int kind;
        void *data1, *data2;
        if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
            return -1;
        length = __Pyx_PyUnicode_GET_LENGTH(s1);
        if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
            goto return_ne;
        }
        kind = __Pyx_PyUnicode_KIND(s1);
        if (kind != __Pyx_PyUnicode_KIND(s2)) {
            goto return_ne;
        }
        data1 = __Pyx_PyUnicode_DATA(s1);
        data2 = __Pyx_PyUnicode_DATA(s2);
        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
            goto return_ne;
        } else if (length == 1) {
            goto return_eq;
        } else {
            int result = memcmp(data1, data2, (size_t)(length * kind));
            #if PY_MAJOR_VERSION < 3
            Py_XDECREF(owned_ref);
            #endif
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & s2_is_unicode) {
        goto return_ne;
    } else if ((s2 == Py_None) & s1_is_unicode) {
        goto return_ne;
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
return_eq:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_EQ);
return_ne:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_NE);
#endif
}

static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
    PyObject *method, *result = NULL;
    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
    if (unlikely(!method)) goto bad;
#if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyMethod_Check(method))) {
        PyObject *self = PyMethod_GET_SELF(method);
        if (likely(self)) {
            PyObject *args;
            PyObject *function = PyMethod_GET_FUNCTION(method);
            args = PyTuple_New(2);
            if (unlikely(!args)) goto bad;
            Py_INCREF(self);
            PyTuple_SET_ITEM(args, 0, self);
            Py_INCREF(arg);
            PyTuple_SET_ITEM(args, 1, arg);
            Py_INCREF(function);
            Py_DECREF(method); method = NULL;
            result = __Pyx_PyObject_Call(function, args, NULL);
            Py_DECREF(args);
            Py_DECREF(function);
            return result;
        }
    }
#endif
    result = __Pyx_PyObject_CallOneArg(method, arg);
bad:
    Py_XDECREF(method);
    return result;
}

static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
    if (likely(PyList_CheckExact(L))) {
        if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1;
    } else {
        PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x);
        if (unlikely(!retval))
            return -1;
        Py_DECREF(retval);
    }
    return 0;
}

static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
        PyObject* obj, PyObject* value, Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3
    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
    if (likely(ms && ms->sq_ass_slice)) {
        if (!has_cstart) {
            if (_py_start && (*_py_start != Py_None)) {
                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstart = 0;
        }
        if (!has_cstop) {
            if (_py_stop && (*_py_stop != Py_None)) {
                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstop = PY_SSIZE_T_MAX;
        }
        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
            Py_ssize_t l = ms->sq_length(obj);
            if (likely(l >= 0)) {
                if (cstop < 0) {
                    cstop += l;
                    if (cstop < 0) cstop = 0;
                }
                if (cstart < 0) {
                    cstart += l;
                    if (cstart < 0) cstart = 0;
                }
            } else {
                if (PyErr_ExceptionMatches(PyExc_OverflowError))
                    PyErr_Clear();
                else
                    goto bad;
            }
        }
        return ms->sq_ass_slice(obj, cstart, cstop, value);
    }
#endif
    mp = Py_TYPE(obj)->tp_as_mapping;
    if (likely(mp && mp->mp_ass_subscript))
#endif
    {
        int result;
        PyObject *py_slice, *py_start, *py_stop;
        if (_py_slice) {
            py_slice = *_py_slice;
        } else {
            PyObject* owned_start = NULL;
            PyObject* owned_stop = NULL;
            if (_py_start) {
                py_start = *_py_start;
            } else {
                if (has_cstart) {
                    owned_start = py_start = PyInt_FromSsize_t(cstart);
                    if (unlikely(!py_start)) goto bad;
                } else
                    py_start = Py_None;
            }
            if (_py_stop) {
                py_stop = *_py_stop;
            } else {
                if (has_cstop) {
                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
                    if (unlikely(!py_stop)) {
                        Py_XDECREF(owned_start);
                        goto bad;
                    }
                } else
                    py_stop = Py_None;
            }
            py_slice = PySlice_New(py_start, py_stop, Py_None);
            Py_XDECREF(owned_start);
            Py_XDECREF(owned_stop);
            if (unlikely(!py_slice)) goto bad;
        }
#if CYTHON_COMPILING_IN_CPYTHON
        result = mp->mp_ass_subscript(obj, py_slice, value);
#else
        result = value ? PyObject_SetItem(obj, py_slice, value) : PyObject_DelItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object does not support slice %.10s",
        Py_TYPE(obj)->tp_name, value ? "assignment" : "deletion");
bad:
    return -1;
}

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
#else
    PyErr_GetExcInfo(type, value, tb);
#endif
}
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(type, value, tb);
#endif
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_COMPILING_IN_CPYTHON
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
    #endif
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}

static int
__Pyx_init_memviewslice(struct __pyx_memoryview_obj *memview,
                        int ndim,
                        __Pyx_memviewslice *memviewslice,
                        int memview_is_new_reference)
{
    __Pyx_RefNannyDeclarations
    int i, retval=-1;
    Py_buffer *buf = &memview->view;
    __Pyx_RefNannySetupContext("init_memviewslice", 0);
    if (!buf) {
        PyErr_SetString(PyExc_ValueError,
            "buf is NULL.");
        goto fail;
    } else if (memviewslice->memview || memviewslice->data) {
        PyErr_SetString(PyExc_ValueError,
            "memviewslice is already initialized!");
        goto fail;
    }
    if (buf->strides) {
        for (i = 0; i < ndim; i++) {
            memviewslice->strides[i] = buf->strides[i];
        }
    } else {
        Py_ssize_t stride = buf->itemsize;
        for (i = ndim - 1; i >= 0; i--) {
            memviewslice->strides[i] = stride;
            stride *= buf->shape[i];
        }
    }
    for (i = 0; i < ndim; i++) {
        memviewslice->shape[i]   = buf->shape[i];
        if (buf->suboffsets) {
            memviewslice->suboffsets[i] = buf->suboffsets[i];
        } else {
            memviewslice->suboffsets[i] = -1;
        }
    }
    memviewslice->memview = memview;
    memviewslice->data = (char *)buf->buf;
    if (__pyx_add_acquisition_count(memview) == 0 && !memview_is_new_reference) {
        Py_INCREF(memview);
    }
    retval = 0;
    goto no_fail;
fail:
    memviewslice->memview = 0;
    memviewslice->data = 0;
    retval = -1;
no_fail:
    __Pyx_RefNannyFinishContext();
    return retval;
}
static CYTHON_INLINE void __pyx_fatalerror(const char *fmt, ...) {
    va_list vargs;
    char msg[200];
    va_start(vargs, fmt);
#ifdef HAVE_STDARG_PROTOTYPES
    va_start(vargs, fmt);
#else
    va_start(vargs);
#endif
    vsnprintf(msg, 200, fmt, vargs);
    Py_FatalError(msg);
    va_end(vargs);
}
static CYTHON_INLINE int
__pyx_add_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
                                   PyThread_type_lock lock)
{
    int result;
    PyThread_acquire_lock(lock, 1);
    result = (*acquisition_count)++;
    PyThread_release_lock(lock);
    return result;
}
static CYTHON_INLINE int
__pyx_sub_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
                                   PyThread_type_lock lock)
{
    int result;
    PyThread_acquire_lock(lock, 1);
    result = (*acquisition_count)--;
    PyThread_release_lock(lock);
    return result;
}
static CYTHON_INLINE void
__Pyx_INC_MEMVIEW(__Pyx_memviewslice *memslice, int have_gil, int lineno)
{
    int first_time;
    struct __pyx_memoryview_obj *memview = memslice->memview;
    if (!memview || (PyObject *) memview == Py_None)
        return;
    if (__pyx_get_slice_count(memview) < 0)
        __pyx_fatalerror("Acquisition count is %d (line %d)",
                         __pyx_get_slice_count(memview), lineno);
    first_time = __pyx_add_acquisition_count(memview) == 0;
    if (first_time) {
        if (have_gil) {
            Py_INCREF((PyObject *) memview);
        } else {
            PyGILState_STATE _gilstate = PyGILState_Ensure();
            Py_INCREF((PyObject *) memview);
            PyGILState_Release(_gilstate);
        }
    }
}
static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice,
                                             int have_gil, int lineno) {
    int last_time;
    struct __pyx_memoryview_obj *memview = memslice->memview;
    if (!memview ) {
        return;
    } else if ((PyObject *) memview == Py_None) {
        memslice->memview = NULL;
        return;
    }
    if (__pyx_get_slice_count(memview) <= 0)
        __pyx_fatalerror("Acquisition count is %d (line %d)",
                         __pyx_get_slice_count(memview), lineno);
    last_time = __pyx_sub_acquisition_count(memview) == 1;
    memslice->data = NULL;
    if (last_time) {
        if (have_gil) {
            Py_CLEAR(memslice->memview);
        } else {
            PyGILState_STATE _gilstate = PyGILState_Ensure();
            Py_CLEAR(memslice->memview);
            PyGILState_Release(_gilstate);
        }
    } else {
        memslice->memview = NULL;
    }
}

#if !CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
    return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL);
}
#endif

static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
    Py_ssize_t q = a / b;
    Py_ssize_t r = a - q*b;
    q -= ((r != 0) & ((r ^ b) < 0));
    return q;
}

static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_COMPILING_IN_CPYTHON
#if PY_MAJOR_VERSION >= 3
    if (likely(PyUnicode_Check(n)))
#else
    if (likely(PyString_Check(n)))
#endif
        return __Pyx_PyObject_GetAttrStr(o, n);
#endif
    return PyObject_GetAttr(o, n);
}

static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
         const char* cstring, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
    Py_ssize_t length;
    if (unlikely((start < 0) | (stop < 0))) {
        length = strlen(cstring);
        if (start < 0) {
            start += length;
            if (start < 0)
                start = 0;
        }
        if (stop < 0)
            stop += length;
    }
    length = stop - start;
    if (unlikely(length <= 0))
        return PyUnicode_FromUnicode(NULL, 0);
    cstring += start;
    if (decode_func) {
        return decode_func(cstring, length, errors);
    } else {
        return PyUnicode_Decode(cstring, length, encoding, errors);
    }
}

static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = *type;
    tstate->exc_value = *value;
    tstate->exc_traceback = *tb;
#else
    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
    PyErr_SetExcInfo(*type, *value, *tb);
#endif
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = (start + end) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,
        0,
        0,
        0,
        0,
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
    }
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        __pyx_d,      /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = py_line;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_VERSION_HEX < 0x03030000
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if (strchr(__Pyx_MODULE_NAME, '.')) {
                #if PY_VERSION_HEX < 0x03030000
                PyObject *py_level = PyInt_FromLong(1);
                if (!py_level)
                    goto bad;
                module = PyObject_CallFunctionObjArgs(py_import,
                    name, global_dict, empty_dict, list, py_level, NULL);
                Py_DECREF(py_level);
                #else
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                #endif
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_VERSION_HEX < 0x03030000
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_VERSION_HEX < 0x03030000
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
    if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
        if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags);
        if (PyObject_TypeCheck(obj, __pyx_array_type)) return __pyx_array_getbuffer(obj, view, flags);
        if (PyObject_TypeCheck(obj, __pyx_memoryview_type)) return __pyx_memoryview_getbuffer(obj, view, flags);
    PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
    return -1;
}
static void __Pyx_ReleaseBuffer(Py_buffer *view) {
    PyObject *obj = view->obj;
    if (!obj) return;
    if (PyObject_CheckBuffer(obj)) {
        PyBuffer_Release(view);
        return;
    }
        if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; }
    Py_DECREF(obj);
    view->obj = NULL;
}
#endif


          #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)       \
    {                                                                     \
        func_type value = func_value;                                     \
        if (sizeof(target_type) < sizeof(func_type)) {                    \
            if (unlikely(value != (func_type) (target_type) value)) {     \
                func_type zero = 0;                                       \
                if (is_unsigned && unlikely(value < zero))                \
                    goto raise_neg_overflow;                              \
                else                                                      \
                    goto raise_overflow;                                  \
            }                                                             \
        }                                                                 \
        return (target_type) value;                                       \
    }

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
 #endif
#endif

static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
    const int neg_one = (int) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            switch (Py_SIZE(x)) {
                case  0: return 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, ((PyLongObject*)x)->ob_digit[0]);
            }
 #endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(int) <= sizeof(unsigned long long)) {
                __PYX_VERIFY_RETURN_INT(int, unsigned long long, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            switch (Py_SIZE(x)) {
                case  0: return 0;
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +(((PyLongObject*)x)->ob_digit[0]));
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
            }
 #endif
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong(x))
            } else if (sizeof(int) <= sizeof(long long)) {
                __PYX_VERIFY_RETURN_INT(int, long long, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

static CYTHON_INLINE coordinate_t __Pyx_PyInt_As_coordinate_t(PyObject *x) {
    const coordinate_t neg_one = (coordinate_t) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(coordinate_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(coordinate_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (coordinate_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            switch (Py_SIZE(x)) {
                case  0: return 0;
                case  1: __PYX_VERIFY_RETURN_INT(coordinate_t, digit, ((PyLongObject*)x)->ob_digit[0]);
            }
 #endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
            if (sizeof(coordinate_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT(coordinate_t, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(coordinate_t) <= sizeof(unsigned long long)) {
                __PYX_VERIFY_RETURN_INT(coordinate_t, unsigned long long, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            switch (Py_SIZE(x)) {
                case  0: return 0;
                case  1: __PYX_VERIFY_RETURN_INT(coordinate_t,  digit, +(((PyLongObject*)x)->ob_digit[0]));
                case -1: __PYX_VERIFY_RETURN_INT(coordinate_t, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
            }
 #endif
#endif
            if (sizeof(coordinate_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT(coordinate_t, long, PyLong_AsLong(x))
            } else if (sizeof(coordinate_t) <= sizeof(long long)) {
                __PYX_VERIFY_RETURN_INT(coordinate_t, long long, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            coordinate_t val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (coordinate_t) -1;
        }
    } else {
        coordinate_t val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (coordinate_t) -1;
        val = __Pyx_PyInt_As_coordinate_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to coordinate_t");
    return (coordinate_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to coordinate_t");
    return (coordinate_t) -1;
}

static int
__pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b)
{
    int i;
    if (!a || !b)
        return 0;
    if (a == b)
        return 1;
    if (a->size != b->size || a->typegroup != b->typegroup ||
            a->is_unsigned != b->is_unsigned || a->ndim != b->ndim) {
        if (a->typegroup == 'H' || b->typegroup == 'H') {
            return a->size == b->size;
        } else {
            return 0;
        }
    }
    if (a->ndim) {
        for (i = 0; i < a->ndim; i++)
            if (a->arraysize[i] != b->arraysize[i])
                return 0;
    }
    if (a->typegroup == 'S') {
        if (a->flags != b->flags)
            return 0;
        if (a->fields || b->fields) {
            if (!(a->fields && b->fields))
                return 0;
            for (i = 0; a->fields[i].type && b->fields[i].type; i++) {
                __Pyx_StructField *field_a = a->fields + i;
                __Pyx_StructField *field_b = b->fields + i;
                if (field_a->offset != field_b->offset ||
                    !__pyx_typeinfo_cmp(field_a->type, field_b->type))
                    return 0;
            }
            return !a->fields[i].type && !b->fields[i].type;
        }
    }
    return 1;
}

static int
__pyx_check_strides(Py_buffer *buf, int dim, int ndim, int spec)
{
    if (buf->shape[dim] <= 1)
        return 1;
    if (buf->strides) {
        if (spec & __Pyx_MEMVIEW_CONTIG) {
            if (spec & (__Pyx_MEMVIEW_PTR|__Pyx_MEMVIEW_FULL)) {
                if (buf->strides[dim] != sizeof(void *)) {
                    PyErr_Format(PyExc_ValueError,
                                 "Buffer is not indirectly contiguous "
                                 "in dimension %d.", dim);
                    goto fail;
                }
            } else if (buf->strides[dim] != buf->itemsize) {
                PyErr_SetString(PyExc_ValueError,
                                "Buffer and memoryview are not contiguous "
                                "in the same dimension.");
                goto fail;
            }
        }
        if (spec & __Pyx_MEMVIEW_FOLLOW) {
            Py_ssize_t stride = buf->strides[dim];
            if (stride < 0)
                stride = -stride;
            if (stride < buf->itemsize) {
                PyErr_SetString(PyExc_ValueError,
                                "Buffer and memoryview are not contiguous "
                                "in the same dimension.");
                goto fail;
            }
        }
    } else {
        if (spec & __Pyx_MEMVIEW_CONTIG && dim != ndim - 1) {
            PyErr_Format(PyExc_ValueError,
                         "C-contiguous buffer is not contiguous in "
                         "dimension %d", dim);
            goto fail;
        } else if (spec & (__Pyx_MEMVIEW_PTR)) {
            PyErr_Format(PyExc_ValueError,
                         "C-contiguous buffer is not indirect in "
                         "dimension %d", dim);
            goto fail;
        } else if (buf->suboffsets) {
            PyErr_SetString(PyExc_ValueError,
                            "Buffer exposes suboffsets but no strides");
            goto fail;
        }
    }
    return 1;
fail:
    return 0;
}
static int
__pyx_check_suboffsets(Py_buffer *buf, int dim, CYTHON_UNUSED int ndim, int spec)
{
    if (spec & __Pyx_MEMVIEW_DIRECT) {
        if (buf->suboffsets && buf->suboffsets[dim] >= 0) {
            PyErr_Format(PyExc_ValueError,
                         "Buffer not compatible with direct access "
                         "in dimension %d.", dim);
            goto fail;
        }
    }
    if (spec & __Pyx_MEMVIEW_PTR) {
        if (!buf->suboffsets || (buf->suboffsets && buf->suboffsets[dim] < 0)) {
            PyErr_Format(PyExc_ValueError,
                         "Buffer is not indirectly accessible "
                         "in dimension %d.", dim);
            goto fail;
        }
    }
    return 1;
fail:
    return 0;
}
static int
__pyx_verify_contig(Py_buffer *buf, int ndim, int c_or_f_flag)
{
    int i;
    if (c_or_f_flag & __Pyx_IS_F_CONTIG) {
        Py_ssize_t stride = 1;
        for (i = 0; i < ndim; i++) {
            if (stride * buf->itemsize != buf->strides[i] &&
                    buf->shape[i] > 1)
            {
                PyErr_SetString(PyExc_ValueError,
                    "Buffer not fortran contiguous.");
                goto fail;
            }
            stride = stride * buf->shape[i];
        }
    } else if (c_or_f_flag & __Pyx_IS_C_CONTIG) {
        Py_ssize_t stride = 1;
        for (i = ndim - 1; i >- 1; i--) {
            if (stride * buf->itemsize != buf->strides[i] &&
                    buf->shape[i] > 1) {
                PyErr_SetString(PyExc_ValueError,
                    "Buffer not C contiguous.");
                goto fail;
            }
            stride = stride * buf->shape[i];
        }
    }
    return 1;
fail:
    return 0;
}
static int __Pyx_ValidateAndInit_memviewslice(
                int *axes_specs,
                int c_or_f_flag,
                int buf_flags,
                int ndim,
                __Pyx_TypeInfo *dtype,
                __Pyx_BufFmt_StackElem stack[],
                __Pyx_memviewslice *memviewslice,
                PyObject *original_obj)
{
    struct __pyx_memoryview_obj *memview, *new_memview;
    __Pyx_RefNannyDeclarations
    Py_buffer *buf;
    int i, spec = 0, retval = -1;
    __Pyx_BufFmt_Context ctx;
    int from_memoryview = __pyx_memoryview_check(original_obj);
    __Pyx_RefNannySetupContext("ValidateAndInit_memviewslice", 0);
    if (from_memoryview && __pyx_typeinfo_cmp(dtype, ((struct __pyx_memoryview_obj *)
                                                            original_obj)->typeinfo)) {
        memview = (struct __pyx_memoryview_obj *) original_obj;
        new_memview = NULL;
    } else {
        memview = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
                                            original_obj, buf_flags, 0, dtype);
        new_memview = memview;
        if (unlikely(!memview))
            goto fail;
    }
    buf = &memview->view;
    if (buf->ndim != ndim) {
        PyErr_Format(PyExc_ValueError,
                "Buffer has wrong number of dimensions (expected %d, got %d)",
                ndim, buf->ndim);
        goto fail;
    }
    if (new_memview) {
        __Pyx_BufFmt_Init(&ctx, stack, dtype);
        if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
    }
    if ((unsigned) buf->itemsize != dtype->size) {
        PyErr_Format(PyExc_ValueError,
                     "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "u byte%s) "
                     "does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "u byte%s)",
                     buf->itemsize,
                     (buf->itemsize > 1) ? "s" : "",
                     dtype->name,
                     dtype->size,
                     (dtype->size > 1) ? "s" : "");
        goto fail;
    }
    for (i = 0; i < ndim; i++) {
        spec = axes_specs[i];
        if (!__pyx_check_strides(buf, i, ndim, spec))
            goto fail;
        if (!__pyx_check_suboffsets(buf, i, ndim, spec))
            goto fail;
    }
    if (buf->strides && !__pyx_verify_contig(buf, ndim, c_or_f_flag))
        goto fail;
    if (unlikely(__Pyx_init_memviewslice(memview, ndim, memviewslice,
                                         new_memview != NULL) == -1)) {
        goto fail;
    }
    retval = 0;
    goto no_fail;
fail:
    Py_XDECREF(new_memview);
    retval = -1;
no_fail:
    __Pyx_RefNannyFinishContext();
    return retval;
}

static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_int(PyObject *obj) {
    __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
    __Pyx_BufFmt_StackElem stack[1];
    int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
    int retcode;
    if (obj == Py_None) {
        result.memview = (struct __pyx_memoryview_obj *) Py_None;
        return result;
    }
    retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
                                                 PyBUF_RECORDS, 1,
                                                 &__Pyx_TypeInfo_int, stack,
                                                 &result, obj);
    if (unlikely(retcode == -1))
        goto __pyx_fail;
    return result;
__pyx_fail:
    result.memview = NULL;
    result.data = NULL;
    return result;
}

static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_float(PyObject *obj) {
    __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
    __Pyx_BufFmt_StackElem stack[1];
    int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
    int retcode;
    if (obj == Py_None) {
        result.memview = (struct __pyx_memoryview_obj *) Py_None;
        return result;
    }
    retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
                                                 PyBUF_RECORDS, 1,
                                                 &__Pyx_TypeInfo_float, stack,
                                                 &result, obj);
    if (unlikely(retcode == -1))
        goto __pyx_fail;
    return result;
__pyx_fail:
    result.memview = NULL;
    result.data = NULL;
    return result;
}

static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_double(PyObject *obj) {
    __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
    __Pyx_BufFmt_StackElem stack[1];
    int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
    int retcode;
    if (obj == Py_None) {
        result.memview = (struct __pyx_memoryview_obj *) Py_None;
        return result;
    }
    retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
                                                 PyBUF_RECORDS, 1,
                                                 &__Pyx_TypeInfo_double, stack,
                                                 &result, obj);
    if (unlikely(retcode == -1))
        goto __pyx_fail;
    return result;
__pyx_fail:
    result.memview = NULL;
    result.data = NULL;
    return result;
}

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
    const int neg_one = (int) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(int) <= sizeof(unsigned long long)) {
            return PyLong_FromUnsignedLongLong((unsigned long long) value);
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(long long)) {
            return PyLong_FromLongLong((long long) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_coordinate_t(coordinate_t value) {
    const coordinate_t neg_one = (coordinate_t) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(coordinate_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(coordinate_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(coordinate_t) <= sizeof(unsigned long long)) {
            return PyLong_FromUnsignedLongLong((unsigned long long) value);
        }
    } else {
        if (sizeof(coordinate_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(coordinate_t) <= sizeof(long long)) {
            return PyLong_FromLongLong((long long) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(coordinate_t),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
    const long neg_one = (long) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(long) <= sizeof(unsigned long long)) {
            return PyLong_FromUnsignedLongLong((unsigned long long) value);
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(long long)) {
            return PyLong_FromLongLong((long long) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE npy_int32 __Pyx_PyInt_As_npy_int32(PyObject *x) {
    const npy_int32 neg_one = (npy_int32) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(npy_int32) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(npy_int32, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (npy_int32) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            switch (Py_SIZE(x)) {
                case  0: return 0;
                case  1: __PYX_VERIFY_RETURN_INT(npy_int32, digit, ((PyLongObject*)x)->ob_digit[0]);
            }
 #endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
            if (sizeof(npy_int32) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(npy_int32) <= sizeof(unsigned long long)) {
                __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long long, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            switch (Py_SIZE(x)) {
                case  0: return 0;
                case  1: __PYX_VERIFY_RETURN_INT(npy_int32,  digit, +(((PyLongObject*)x)->ob_digit[0]));
                case -1: __PYX_VERIFY_RETURN_INT(npy_int32, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
            }
 #endif
#endif
            if (sizeof(npy_int32) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT(npy_int32, long, PyLong_AsLong(x))
            } else if (sizeof(npy_int32) <= sizeof(long long)) {
                __PYX_VERIFY_RETURN_INT(npy_int32, long long, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            npy_int32 val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (npy_int32) -1;
        }
    } else {
        npy_int32 val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (npy_int32) -1;
        val = __Pyx_PyInt_As_npy_int32(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to npy_int32");
    return (npy_int32) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to npy_int32");
    return (npy_int32) -1;
}

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_npy_int32(npy_int32 value) {
    const npy_int32 neg_one = (npy_int32) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(npy_int32) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(npy_int32) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(npy_int32) <= sizeof(unsigned long long)) {
            return PyLong_FromUnsignedLongLong((unsigned long long) value);
        }
    } else {
        if (sizeof(npy_int32) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(npy_int32) <= sizeof(long long)) {
            return PyLong_FromLongLong((long long) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(npy_int32),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
    const long neg_one = (long) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            switch (Py_SIZE(x)) {
                case  0: return 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, ((PyLongObject*)x)->ob_digit[0]);
            }
 #endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(long) <= sizeof(unsigned long long)) {
                __PYX_VERIFY_RETURN_INT(long, unsigned long long, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            switch (Py_SIZE(x)) {
                case  0: return 0;
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +(((PyLongObject*)x)->ob_digit[0]));
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
            }
 #endif
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong(x))
            } else if (sizeof(long) <= sizeof(long long)) {
                __PYX_VERIFY_RETURN_INT(long, long long, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
    const size_t neg_one = (size_t) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(size_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (size_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            switch (Py_SIZE(x)) {
                case  0: return 0;
                case  1: __PYX_VERIFY_RETURN_INT(size_t, digit, ((PyLongObject*)x)->ob_digit[0]);
            }
 #endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
            if (sizeof(size_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT(size_t, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(size_t) <= sizeof(unsigned long long)) {
                __PYX_VERIFY_RETURN_INT(size_t, unsigned long long, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            switch (Py_SIZE(x)) {
                case  0: return 0;
                case  1: __PYX_VERIFY_RETURN_INT(size_t,  digit, +(((PyLongObject*)x)->ob_digit[0]));
                case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
            }
 #endif
#endif
            if (sizeof(size_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT(size_t, long, PyLong_AsLong(x))
            } else if (sizeof(size_t) <= sizeof(long long)) {
                __PYX_VERIFY_RETURN_INT(size_t, long long, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            size_t val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (size_t) -1;
        }
    } else {
        size_t val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (size_t) -1;
        val = __Pyx_PyInt_As_size_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to size_t");
    return (size_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to size_t");
    return (size_t) -1;
}

static PyObject *__pyx_memview_get_int(const char *itemp) {
    return (PyObject *) __Pyx_PyInt_From_int(*(int *) itemp);
}
static int __pyx_memview_set_int(const char *itemp, PyObject *obj) {
    int value = __Pyx_PyInt_As_int(obj);
    if ((value == (int)-1) && PyErr_Occurred())
        return 0;
    *(int *) itemp = value;
    return 1;
}

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value) {
    const Py_intptr_t neg_one = (Py_intptr_t) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(Py_intptr_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(Py_intptr_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(Py_intptr_t) <= sizeof(unsigned long long)) {
            return PyLong_FromUnsignedLongLong((unsigned long long) value);
        }
    } else {
        if (sizeof(Py_intptr_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(Py_intptr_t) <= sizeof(long long)) {
            return PyLong_FromLongLong((long long) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(Py_intptr_t),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) {
    const unsigned int neg_one = (unsigned int) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(unsigned int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(unsigned int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (unsigned int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            switch (Py_SIZE(x)) {
                case  0: return 0;
                case  1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, ((PyLongObject*)x)->ob_digit[0]);
            }
 #endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
            if (sizeof(unsigned int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(unsigned int) <= sizeof(unsigned long long)) {
                __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long long, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            switch (Py_SIZE(x)) {
                case  0: return 0;
                case  1: __PYX_VERIFY_RETURN_INT(unsigned int,  digit, +(((PyLongObject*)x)->ob_digit[0]));
                case -1: __PYX_VERIFY_RETURN_INT(unsigned int, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
            }
 #endif
#endif
            if (sizeof(unsigned int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT(unsigned int, long, PyLong_AsLong(x))
            } else if (sizeof(unsigned int) <= sizeof(long long)) {
                __PYX_VERIFY_RETURN_INT(unsigned int, long long, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            unsigned int val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (unsigned int) -1;
        }
    } else {
        unsigned int val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned int) -1;
        val = __Pyx_PyInt_As_unsigned_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to unsigned int");
    return (unsigned int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to unsigned int");
    return (unsigned int) -1;
}

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) {
    const unsigned int neg_one = (unsigned int) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(unsigned int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(unsigned int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(unsigned int) <= sizeof(unsigned long long)) {
            return PyLong_FromUnsignedLongLong((unsigned long long) value);
        }
    } else {
        if (sizeof(unsigned int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(unsigned int) <= sizeof(long long)) {
            return PyLong_FromLongLong((long long) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(unsigned int),
                                     little, !is_unsigned);
    }
}

static PyObject *__pyx_memview_get_float(const char *itemp) {
    return (PyObject *) PyFloat_FromDouble(*(float *) itemp);
}
static int __pyx_memview_set_float(const char *itemp, PyObject *obj) {
    float value = __pyx_PyFloat_AsFloat(obj);
    if ((value == (float)-1) && PyErr_Occurred())
        return 0;
    *(float *) itemp = value;
    return 1;
}

static PyObject *__pyx_memview_get_double(const char *itemp) {
    return (PyObject *) PyFloat_FromDouble(*(double *) itemp);
}
static int __pyx_memview_set_double(const char *itemp, PyObject *obj) {
    double value = __pyx_PyFloat_AsDouble(obj);
    if ((value == (double)-1) && PyErr_Occurred())
        return 0;
    *(double *) itemp = value;
    return 1;
}

#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3
static PyObject *__Pyx_GetStdout(void) {
    PyObject *f = PySys_GetObject((char *)"stdout");
    if (!f) {
        PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
    }
    return f;
}
static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) {
    int i;
    if (!f) {
        if (!(f = __Pyx_GetStdout()))
            return -1;
    }
    Py_INCREF(f);
    for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) {
        PyObject* v;
        if (PyFile_SoftSpace(f, 1)) {
            if (PyFile_WriteString(" ", f) < 0)
                goto error;
        }
        v = PyTuple_GET_ITEM(arg_tuple, i);
        if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0)
            goto error;
        if (PyString_Check(v)) {
            char *s = PyString_AsString(v);
            Py_ssize_t len = PyString_Size(v);
            if (len > 0) {
                switch (s[len-1]) {
                    case ' ': break;
                    case '\f': case '\r': case '\n': case '\t': case '\v':
                        PyFile_SoftSpace(f, 0);
                        break;
                    default:  break;
                }
            }
        }
    }
    if (newline) {
        if (PyFile_WriteString("\n", f) < 0)
            goto error;
        PyFile_SoftSpace(f, 0);
    }
    Py_DECREF(f);
    return 0;
error:
    Py_DECREF(f);
    return -1;
}
#else
static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
    PyObject* kwargs = 0;
    PyObject* result = 0;
    PyObject* end_string;
    if (unlikely(!__pyx_print)) {
        __pyx_print = PyObject_GetAttr(__pyx_b, __pyx_n_s_print);
        if (!__pyx_print)
            return -1;
    }
    if (stream) {
        kwargs = PyDict_New();
        if (unlikely(!kwargs))
            return -1;
        if (unlikely(PyDict_SetItem(kwargs, __pyx_n_s_file, stream) < 0))
            goto bad;
        if (!newline) {
            end_string = PyUnicode_FromStringAndSize(" ", 1);
            if (unlikely(!end_string))
                goto bad;
            if (PyDict_SetItem(kwargs, __pyx_n_s_end, end_string) < 0) {
                Py_DECREF(end_string);
                goto bad;
            }
            Py_DECREF(end_string);
        }
    } else if (!newline) {
        if (unlikely(!__pyx_print_kwargs)) {
            __pyx_print_kwargs = PyDict_New();
            if (unlikely(!__pyx_print_kwargs))
                return -1;
            end_string = PyUnicode_FromStringAndSize(" ", 1);
            if (unlikely(!end_string))
                return -1;
            if (PyDict_SetItem(__pyx_print_kwargs, __pyx_n_s_end, end_string) < 0) {
                Py_DECREF(end_string);
                return -1;
            }
            Py_DECREF(end_string);
        }
        kwargs = __pyx_print_kwargs;
    }
    result = PyObject_Call(__pyx_print, arg_tuple, kwargs);
    if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs))
        Py_DECREF(kwargs);
    if (!result)
        return -1;
    Py_DECREF(result);
    return 0;
bad:
    if (kwargs != __pyx_print_kwargs)
        Py_XDECREF(kwargs);
    return -1;
}
#endif

#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3
static int __Pyx_PrintOne(PyObject* f, PyObject *o) {
    if (!f) {
        if (!(f = __Pyx_GetStdout()))
            return -1;
    }
    Py_INCREF(f);
    if (PyFile_SoftSpace(f, 0)) {
        if (PyFile_WriteString(" ", f) < 0)
            goto error;
    }
    if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0)
        goto error;
    if (PyFile_WriteString("\n", f) < 0)
        goto error;
    Py_DECREF(f);
    return 0;
error:
    Py_DECREF(f);
    return -1;
    /* the line below is just to avoid C compiler
     * warnings about unused functions */
    return __Pyx_Print(f, NULL, 0);
}
#else
static int __Pyx_PrintOne(PyObject* stream, PyObject *o) {
    int res;
    PyObject* arg_tuple = PyTuple_Pack(1, o);
    if (unlikely(!arg_tuple))
        return -1;
    res = __Pyx_Print(stream, arg_tuple, 1);
    Py_DECREF(arg_tuple);
    return res;
}
#endif

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return ::std::complex< float >(x, y);
    }
  #else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return x + y*(__pyx_t_float_complex)_Complex_I;
    }
  #endif
#else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      __pyx_t_float_complex z;
      z.real = x;
      z.imag = y;
      return z;
    }
#endif

#if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
       return (a.real == b.real) && (a.imag == b.imag);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real + b.real;
        z.imag = a.imag + b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real - b.real;
        z.imag = a.imag - b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real * b.real - a.imag * b.imag;
        z.imag = a.real * b.imag + a.imag * b.real;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        float denom = b.real * b.real + b.imag * b.imag;
        z.real = (a.real * b.real + a.imag * b.imag) / denom;
        z.imag = (a.imag * b.real - a.real * b.imag) / denom;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real = -a.real;
        z.imag = -a.imag;
        return z;
    }
    static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real =  a.real;
        z.imag = -a.imag;
        return z;
    }
    #if 1
        static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) {
          #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
            return sqrtf(z.real*z.real + z.imag*z.imag);
          #else
            return hypotf(z.real, z.imag);
          #endif
        }
        static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
            __pyx_t_float_complex z;
            float r, lnr, theta, z_r, z_theta;
            if (b.imag == 0 && b.real == (int)b.real) {
                if (b.real < 0) {
                    float denom = a.real * a.real + a.imag * a.imag;
                    a.real = a.real / denom;
                    a.imag = -a.imag / denom;
                    b.real = -b.real;
                }
                switch ((int)b.real) {
                    case 0:
                        z.real = 1;
                        z.imag = 0;
                        return z;
                    case 1:
                        return a;
                    case 2:
                        z = __Pyx_c_prodf(a, a);
                        return __Pyx_c_prodf(a, a);
                    case 3:
                        z = __Pyx_c_prodf(a, a);
                        return __Pyx_c_prodf(z, a);
                    case 4:
                        z = __Pyx_c_prodf(a, a);
                        return __Pyx_c_prodf(z, z);
                }
            }
            if (a.imag == 0) {
                if (a.real == 0) {
                    return a;
                }
                r = a.real;
                theta = 0;
            } else {
                r = __Pyx_c_absf(a);
                theta = atan2f(a.imag, a.real);
            }
            lnr = logf(r);
            z_r = expf(lnr * b.real - theta * b.imag);
            z_theta = theta * b.real + lnr * b.imag;
            z.real = z_r * cosf(z_theta);
            z.imag = z_r * sinf(z_theta);
            return z;
        }
    #endif
#endif

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      return ::std::complex< double >(x, y);
    }
  #else
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      return x + y*(__pyx_t_double_complex)_Complex_I;
    }
  #endif
#else
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      __pyx_t_double_complex z;
      z.real = x;
      z.imag = y;
      return z;
    }
#endif

#if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) {
       return (a.real == b.real) && (a.imag == b.imag);
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real + b.real;
        z.imag = a.imag + b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real - b.real;
        z.imag = a.imag - b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real * b.real - a.imag * b.imag;
        z.imag = a.real * b.imag + a.imag * b.real;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        double denom = b.real * b.real + b.imag * b.imag;
        z.real = (a.real * b.real + a.imag * b.imag) / denom;
        z.imag = (a.imag * b.real - a.real * b.imag) / denom;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) {
        __pyx_t_double_complex z;
        z.real = -a.real;
        z.imag = -a.imag;
        return z;
    }
    static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) {
        __pyx_t_double_complex z;
        z.real =  a.real;
        z.imag = -a.imag;
        return z;
    }
    #if 1
        static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) {
          #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
            return sqrt(z.real*z.real + z.imag*z.imag);
          #else
            return hypot(z.real, z.imag);
          #endif
        }
        static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) {
            __pyx_t_double_complex z;
            double r, lnr, theta, z_r, z_theta;
            if (b.imag == 0 && b.real == (int)b.real) {
                if (b.real < 0) {
                    double denom = a.real * a.real + a.imag * a.imag;
                    a.real = a.real / denom;
                    a.imag = -a.imag / denom;
                    b.real = -b.real;
                }
                switch ((int)b.real) {
                    case 0:
                        z.real = 1;
                        z.imag = 0;
                        return z;
                    case 1:
                        return a;
                    case 2:
                        z = __Pyx_c_prod(a, a);
                        return __Pyx_c_prod(a, a);
                    case 3:
                        z = __Pyx_c_prod(a, a);
                        return __Pyx_c_prod(z, a);
                    case 4:
                        z = __Pyx_c_prod(a, a);
                        return __Pyx_c_prod(z, z);
                }
            }
            if (a.imag == 0) {
                if (a.real == 0) {
                    return a;
                }
                r = a.real;
                theta = 0;
            } else {
                r = __Pyx_c_abs(a);
                theta = atan2(a.imag, a.real);
            }
            lnr = log(r);
            z_r = exp(lnr * b.real - theta * b.imag);
            z_theta = theta * b.real + lnr * b.imag;
            z.real = z_r * cos(z_theta);
            z.imag = z_r * sin(z_theta);
            return z;
        }
    #endif
#endif

static int
__pyx_memviewslice_is_contig(const __Pyx_memviewslice *mvs,
                             char order, int ndim)
{
    int i, index, step, start;
    Py_ssize_t itemsize = mvs->memview->view.itemsize;
    if (order == 'F') {
        step = 1;
        start = 0;
    } else {
        step = -1;
        start = ndim - 1;
    }
    for (i = 0; i < ndim; i++) {
        index = start + step * i;
        if (mvs->suboffsets[index] >= 0 || mvs->strides[index] != itemsize)
            return 0;
        itemsize *= mvs->shape[index];
    }
    return 1;
}

static void
__pyx_get_array_memory_extents(__Pyx_memviewslice *slice,
                               void **out_start, void **out_end,
                               int ndim, size_t itemsize)
{
    char *start, *end;
    int i;
    start = end = slice->data;
    for (i = 0; i < ndim; i++) {
        Py_ssize_t stride = slice->strides[i];
        Py_ssize_t extent = slice->shape[i];
        if (extent == 0) {
            *out_start = *out_end = start;
            return;
        } else {
            if (stride > 0)
                end += stride * (extent - 1);
            else
                start += stride * (extent - 1);
        }
    }
    *out_start = start;
    *out_end = end + itemsize;
}
static int
__pyx_slices_overlap(__Pyx_memviewslice *slice1,
                     __Pyx_memviewslice *slice2,
                     int ndim, size_t itemsize)
{
    void *start1, *end1, *start2, *end2;
    __pyx_get_array_memory_extents(slice1, &start1, &end1, ndim, itemsize);
    __pyx_get_array_memory_extents(slice2, &start2, &end2, ndim, itemsize);
    return (start1 < end2) && (start2 < end1);
}

static __Pyx_memviewslice
__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
                                 const char *mode, int ndim,
                                 size_t sizeof_dtype, int contig_flag,
                                 int dtype_is_object)
{
    __Pyx_RefNannyDeclarations
    int i;
    __Pyx_memviewslice new_mvs = { 0, 0, { 0 }, { 0 }, { 0 } };
    struct __pyx_memoryview_obj *from_memview = from_mvs->memview;
    Py_buffer *buf = &from_memview->view;
    PyObject *shape_tuple = NULL;
    PyObject *temp_int = NULL;
    struct __pyx_array_obj *array_obj = NULL;
    struct __pyx_memoryview_obj *memview_obj = NULL;
    __Pyx_RefNannySetupContext("__pyx_memoryview_copy_new_contig", 0);
    for (i = 0; i < ndim; i++) {
        if (from_mvs->suboffsets[i] >= 0) {
            PyErr_Format(PyExc_ValueError, "Cannot copy memoryview slice with "
                                           "indirect dimensions (axis %d)", i);
            goto fail;
        }
    }
    shape_tuple = PyTuple_New(ndim);
    if (unlikely(!shape_tuple)) {
        goto fail;
    }
    __Pyx_GOTREF(shape_tuple);
    for(i = 0; i < ndim; i++) {
        temp_int = PyInt_FromSsize_t(from_mvs->shape[i]);
        if(unlikely(!temp_int)) {
            goto fail;
        } else {
            PyTuple_SET_ITEM(shape_tuple, i, temp_int);
            temp_int = NULL;
        }
    }
    array_obj = __pyx_array_new(shape_tuple, sizeof_dtype, buf->format, (char *) mode, NULL);
    if (unlikely(!array_obj)) {
        goto fail;
    }
    __Pyx_GOTREF(array_obj);
    memview_obj = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
                                    (PyObject *) array_obj, contig_flag,
                                    dtype_is_object,
                                    from_mvs->memview->typeinfo);
    if (unlikely(!memview_obj))
        goto fail;
    if (unlikely(__Pyx_init_memviewslice(memview_obj, ndim, &new_mvs, 1) < 0))
        goto fail;
    if (unlikely(__pyx_memoryview_copy_contents(*from_mvs, new_mvs, ndim, ndim,
                                                dtype_is_object) < 0))
        goto fail;
    goto no_fail;
fail:
    __Pyx_XDECREF(new_mvs.memview);
    new_mvs.memview = NULL;
    new_mvs.data = NULL;
no_fail:
    __Pyx_XDECREF(shape_tuple);
    __Pyx_XDECREF(temp_int);
    __Pyx_XDECREF(array_obj);
    __Pyx_RefNannyFinishContext();
    return new_mvs;
}

static CYTHON_INLINE PyObject *
__pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig)
{
    PyObject *cobj;
#if PY_VERSION_HEX >= 0x02070000
    cobj = PyCapsule_New(p, sig, NULL);
#else
    cobj = PyCObject_FromVoidPtr(p, NULL);
#endif
    return cobj;
}

static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
    const char neg_one = (char) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(char) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (char) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            switch (Py_SIZE(x)) {
                case  0: return 0;
                case  1: __PYX_VERIFY_RETURN_INT(char, digit, ((PyLongObject*)x)->ob_digit[0]);
            }
 #endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
            if (sizeof(char) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT(char, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(char) <= sizeof(unsigned long long)) {
                __PYX_VERIFY_RETURN_INT(char, unsigned long long, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            switch (Py_SIZE(x)) {
                case  0: return 0;
                case  1: __PYX_VERIFY_RETURN_INT(char,  digit, +(((PyLongObject*)x)->ob_digit[0]));
                case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
            }
 #endif
#endif
            if (sizeof(char) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT(char, long, PyLong_AsLong(x))
            } else if (sizeof(char) <= sizeof(long long)) {
                __PYX_VERIFY_RETURN_INT(char, long long, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            char val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (char) -1;
        }
    } else {
        char val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (char) -1;
        val = __Pyx_PyInt_As_char(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to char");
    return (char) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to char");
    return (char) -1;
}

static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;
    py_name = __Pyx_PyIdentifier_FromString(name);
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    size_t size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    py_name = __Pyx_PyIdentifier_FromString(class_name);
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if (!strict && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    else if ((size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s has the wrong size, try recompiling",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return NULL;
}
#endif

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
#if PY_VERSION_HEX < 0x03030000
        char* defenc_c;
        PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
        if (!defenc) return NULL;
        defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        {
            char* end = defenc_c + PyBytes_GET_SIZE(defenc);
            char* c;
            for (c = defenc_c; c < end; c++) {
                if ((unsigned char) (*c) >= 128) {
                    PyUnicode_AsASCIIString(o);
                    return NULL;
                }
            }
        }
#endif
        *length = PyBytes_GET_SIZE(defenc);
        return defenc_c;
#else
        if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        if (PyUnicode_IS_ASCII(o)) {
            *length = PyUnicode_GET_LENGTH(o);
            return PyUnicode_AsUTF8(o);
        } else {
            PyUnicode_AsASCIIString(o);
            return NULL;
        }
#else
        return PyUnicode_AsUTF8AndSize(o, length);
#endif
#endif
    } else
#endif
#if !CYTHON_COMPILING_IN_PYPY
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return Py_INCREF(x), x;
  m = Py_TYPE(x)->tp_as_number;
#if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_MAJOR_VERSION < 3
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%.4s__ returned non-%.4s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b)))
      return PyInt_AS_LONG(b);
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
     #if CYTHON_USE_PYLONG_INTERNALS
       switch (Py_SIZE(b)) {
       case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0];
       case  0: return 0;
       case  1: return ((PyLongObject*)b)->ob_digit[0];
       }
     #endif
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
